diff options
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. |
