blob: 1ccf1a7968f29bc5c94e3923546c9b30036d7767 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include <lib9.h>
#include <thread.h>
Channel *c[3];
void
pingpong(void *v)
{
int n;
Channel **c;
c = v;
do{
n = recvul(c[0]);
sendul(c[1], n-1);
}while(n > 0);
exit(0);
}
void
threadmain(int argc, char **argv)
{
c[0] = chancreate(sizeof(ulong), 1);
c[1] = chancreate(sizeof(ulong), 1);
c[2] = c[0];
proccreate(pingpong, c, 16384);
threadcreate(pingpong, c+1, 16384);
sendul(c[0], atoi(argv[1]));
}
|