mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
Rendezvous tester.
This commit is contained in:
parent
e767dd4930
commit
8af7f5d093
1 changed files with 31 additions and 0 deletions
31
src/libthread/trend.c
Normal file
31
src/libthread/trend.c
Normal file
|
@ -0,0 +1,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];
|
||||
|
||||
threadcreate(pingpong, c, 16384);
|
||||
threadcreate(pingpong, c+1, 16384);
|
||||
sendul(c[0], atoi(argv[1]));
|
||||
}
|
Loading…
Reference in a new issue