TOC, 1, 2, 3,
4, 5, 6,
7, 8, 9,
10, 11, 12,
13, 14
10) PROGRAMMING IN C-LINDA
10.1) What are useful sources of
information on programming in Linda?
The C-Linda User's Guide
contains several case studies, and SCIENTIFIC also has reprints of Linda case
studies. The book "How to Write Parallel Programs: A First Course", by Nicholas
Carriero and David Gelernter, published by The MIT Press, is another good source
of information on Linda programming.
10.2) How can I implement a barrier in
Linda?
Very often barriers are over kill, but when necessary, it is
easy to implement. One example is:
void barrier(i, n)
int i; /* My linda id */
int n; /* Number of linda processes in the barrier */
{
int direction;
if (n > 1) {
if (i == 0) {
out("barrier", i + 1, 1);
in("barrier", i, ? direction);
}
else if (i == n - 1) {
out("barrier", i - 1, -1);
in("barrier", i, ? direction);
}
else {
in("barrier", i, ? direction);
out("barrier", i + direction, direction);
in("barrier", i, ? direction);
out("barrier", i + direction, direction);
}
}
}
No initialization or clean up is required for this routine, and it can be
executed any number of times.
TOC, 1, 2, 3,
4, 5, 6,
7, 8, 9,
10, 11, 12,
13, 14