diff options
| author | rsc <devnull@localhost> | 2003-12-06 18:05:27 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2003-12-06 18:05:27 +0000 |
| commit | e97ceade5e1bba5787e39429384336fa37797906 (patch) | |
| tree | 1353f5aa99b04e9c030ecc89cd7b526cb814090d /src/libthread/create.c | |
| parent | c715a6127a46b8090591972b5c4bb04dfabbca8b (diff) | |
| download | plan9port-e97ceade5e1bba5787e39429384336fa37797906.tar.gz plan9port-e97ceade5e1bba5787e39429384336fa37797906.zip | |
various tweaks.
Diffstat (limited to 'src/libthread/create.c')
| -rw-r--r-- | src/libthread/create.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libthread/create.c b/src/libthread/create.c index 6a44c243..55f6c60c 100644 --- a/src/libthread/create.c +++ b/src/libthread/create.c @@ -2,6 +2,8 @@ Pqueue _threadpq; +int _threadmultiproc; + static int nextID(void); /* @@ -81,6 +83,14 @@ procrfork(void (*f)(void *), void *arg, uint stacksize, int rforkflag) int proccreate(void (*f)(void*), void *arg, uint stacksize) { + Proc *p; + + p = _threadgetproc(); + if(p->idle){ + werrstr("cannot create procs once there is an idle thread"); + return -1; + } + _threadmultiproc = 1; return procrfork(f, arg, stacksize, 0); } @@ -110,6 +120,20 @@ threadcreate(void (*f)(void *arg), void *arg, uint stacksize) return newthread(_threadgetproc(), f, arg, stacksize, nil, threadgetgrp()); } +int +threadcreateidle(void (*f)(void *arg), void *arg, uint stacksize) +{ + int id; + + if(_threadmultiproc){ + werrstr("cannot have idle thread in multi-proc program"); + return -1; + } + id = newthread(_threadgetproc(), f, arg, stacksize, nil, threadgetgrp()); + _threadidle(); + return id; +} + /* * Create and initialize a new Proc structure with a single Thread * running inside it. Add the Proc to the global process list. |
