Next: C++-with-Ease language definition Up: C-with-Ease language definition Previous: Communication

An example program

xxx Need more intro and description of program

typedef struct {
   char str[100];
} String;

@process server(@share @reply r, @share @bag s) { double f; int i; String *tmp; while (1) { @resource (r, f) { i = (int)(1000.0 * sin(f)); tmp = (String *) malloc(sizeof *tmp); sprintf(tmp->str, "Resource got %f, writing %d
n", f, i); @put!(s, tmp); } @reply i; } }

@process client(int i, @share @reply r, @share s) {/* @share @bag is equivalent to @share */ String str; double v = i / 3.0; @call(r, v, i); sprintf(str.str, "Call sent %f, got %d
n", v, i); @write(s, str); }

eMain() { @share @reply r; @share @bag print; @init(r); @init(print);

@subordinate (i @for 3) server(r, print); @cooperate (j @for 10) client(j, r, print); while (1) { String *str; /* Remove everything from the print context */ @select { @get!(print, str) { printf("%s", str->str); free(str); } @else { /* Only when the context is empty */ break; } } } }

Portability Issues

xxx Discuss what's required to make a program portable over multiple architectures.

%C



Tim MacKenzie <tym@cs.monash.edu.au>
Mon Apr 1 00:27:29 EST 1996