main
| Line | |
|---|
| 1 | #include <comm.cvh>
|
|---|
| 2 |
|
|---|
| 3 | $gcomm g = $gcomm_create($here, 2);
|
|---|
| 4 |
|
|---|
| 5 | void p0_f() {
|
|---|
| 6 | $comm c = $comm_create($here, g, 0);
|
|---|
| 7 | int* m = (int*) $malloc($here, sizeof(int));
|
|---|
| 8 |
|
|---|
| 9 | *m = 0;
|
|---|
| 10 | $comm_enqueue(c, $message_pack(0, 1, 0, &m, sizeof(int*)));
|
|---|
| 11 | *m = 1;
|
|---|
| 12 |
|
|---|
| 13 | $comm_dequeue(c, 1, 0);
|
|---|
| 14 | $free(m);
|
|---|
| 15 | $comm_destroy(c);
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | void p1_f() {
|
|---|
| 19 | $comm c = $comm_create($here, g, 1);
|
|---|
| 20 | $message result = $comm_dequeue(c, 0, 0);
|
|---|
| 21 |
|
|---|
| 22 | int* m;
|
|---|
| 23 | $message_unpack(result, &m, sizeof(int*));
|
|---|
| 24 | $assert(*m == 1);
|
|---|
| 25 |
|
|---|
| 26 | $comm_enqueue(c, $message_pack(1, 0, 0, NULL, 0));
|
|---|
| 27 | $comm_destroy(c);
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | int main() {
|
|---|
| 31 | $proc p0 = $spawn p0_f();
|
|---|
| 32 | $proc p1 = $spawn p1_f();
|
|---|
| 33 | $wait(p0);
|
|---|
| 34 | $wait(p1);
|
|---|
| 35 | $gcomm_destroy(g, NULL);
|
|---|
| 36 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.