mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-15 11:20:03 +00:00
a995e477ff
The main change is the use of pthread to implement ffork.
31 lines
421 B
C
31 lines
421 B
C
#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]));
|
|
}
|