various tweaks.
This commit is contained in:
parent
c715a6127a
commit
e97ceade5e
10 changed files with 74 additions and 8 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue