source: CIVL/examples/concurrency/porCommBug.cvl

main
Last change on this file was 0a12b559, checked in by Alex Wilton <awilton@…>, 3 years ago

Added dev test for por comm bug.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5764 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 680 bytes
Line 
1#include <comm.cvh>
2
3$gcomm g = $gcomm_create($here, 2);
4
5void 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
18void 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
30int 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.