aboutsummaryrefslogtreecommitdiff
path: root/src/libthread
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2003-10-01 00:44:57 +0000
committerrsc <devnull@localhost>2003-10-01 00:44:57 +0000
commit8af7f5d093773b6a780a4ccfcee04791c221d81a (patch)
treead9c362cd26061e959e88e1177dc02ee88a685df /src/libthread
parente767dd493091d95e9fed07c927d7ececd93b47ca (diff)
downloadplan9port-8af7f5d093773b6a780a4ccfcee04791c221d81a.tar.gz
plan9port-8af7f5d093773b6a780a4ccfcee04791c221d81a.tar.bz2
plan9port-8af7f5d093773b6a780a4ccfcee04791c221d81a.zip
Rendezvous tester.
Diffstat (limited to 'src/libthread')
-rw-r--r--src/libthread/trend.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/libthread/trend.c b/src/libthread/trend.c
new file mode 100644
index 00000000..6f8adcd5
--- /dev/null
+++ b/src/libthread/trend.c
@@ -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]));
+}