From 1544f90960275dc9211bde30329c3258e0e1bf38 Mon Sep 17 00:00:00 2001 From: rsc Date: Sat, 25 Dec 2004 21:56:33 +0000 Subject: New thread library --- src/libthread/test/tspawnloop.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/libthread/test/tspawnloop.c (limited to 'src/libthread/test/tspawnloop.c') diff --git a/src/libthread/test/tspawnloop.c b/src/libthread/test/tspawnloop.c new file mode 100644 index 00000000..8835267f --- /dev/null +++ b/src/libthread/test/tspawnloop.c @@ -0,0 +1,41 @@ +#include "u.h" +#include "libc.h" +#include "thread.h" + +void +execproc(void *v) +{ + int i, fd[3]; + char buf[100], *args[3]; + + i = (int)v; + sprint(buf, "%d", i); + fd[0] = dup(0, -1); + fd[1] = dup(1, -1); + fd[2] = dup(2, -1); + args[0] = "echo"; + args[1] = buf; + args[2] = nil; + threadexec(nil, fd, args[0], args); +} + +void +threadmain(int argc, char **argv) +{ + int i; + Channel *c; + Waitmsg *w; + + ARGBEGIN{ + case 'D': + break; + }ARGEND + + c = threadwaitchan(); + for(i=0;; i++){ + proccreate(execproc, (void*)i, 16384); + w = recvp(c); + if(w == nil) + sysfatal("exec/recvp failed: %r"); + } +} -- cgit v1.2.3