diff options
author | rsc <devnull@localhost> | 2004-12-27 03:49:03 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2004-12-27 03:49:03 +0000 |
commit | 73722a8bbf80f47ea2df2a212516d1b857ffe29a (patch) | |
tree | c018c777df2eec8811c71cf9e41d073021c67b13 /src/libthread/pthread.c | |
parent | e317e37406f8597d42c1e37ab7fcc4f7f901b342 (diff) | |
download | plan9port-73722a8bbf80f47ea2df2a212516d1b857ffe29a.tar.gz plan9port-73722a8bbf80f47ea2df2a212516d1b857ffe29a.tar.bz2 plan9port-73722a8bbf80f47ea2df2a212516d1b857ffe29a.zip |
confine pthreads to pthread.c
Diffstat (limited to 'src/libthread/pthread.c')
-rw-r--r-- | src/libthread/pthread.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/libthread/pthread.c b/src/libthread/pthread.c index 8ca8f8f1..6540605d 100644 --- a/src/libthread/pthread.c +++ b/src/libthread/pthread.c @@ -71,16 +71,40 @@ _procwakeup(_Procrendez *r) } } +static void +startprocfn(void *v) +{ + void **a; + void (*fn)(void*); + Proc *p; + + a = (void**)v; + fn = a[0]; + p = a[1]; + free(a); + p->tid = pthread_self(); + pthread_detach(p->tid); + + (*fn)(p); + + pthread_exit(0); +} + void -_procstart(Proc *p, void (*fn)(void*)) +_procstart(Proc *p, void (*fn)(Proc*)) { -//print("pc\n"); - if(pthread_create(&p->tid, nil, (void*(*)(void*))fn, p) < 0){ -//print("pc1\n"); + void **a; + + a = malloc(2*sizeof a[0]); + if(a == nil) + sysfatal("_procstart malloc: %r"); + a[0] = fn; + a[1] = p; + + if(pthread_create(&p->tid, nil, (void*(*)(void*))startprocfn, (void*)a) < 0){ fprint(2, "pthread_create: %r\n"); abort(); } -//print("pc2\n"); } static pthread_key_t prockey; |