summaryrefslogtreecommitdiffstats
path: root/src/libthread/sched.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-10-22 18:45:08 +0000
committerrsc <devnull@localhost>2004-10-22 18:45:08 +0000
commit5093c3fa40717e78b0a63955640a8ac9071b5c07 (patch)
tree10141d54500447e4e4fee9aa0b6f9c8d0bcc7352 /src/libthread/sched.c
parent048610b7ea50507c6987d5b0cc0c4810cda87d53 (diff)
downloadplan9port-5093c3fa40717e78b0a63955640a8ac9071b5c07.tar.gz
plan9port-5093c3fa40717e78b0a63955640a8ac9071b5c07.zip
try to implement the daemonize hack.
Diffstat (limited to 'src/libthread/sched.c')
-rw-r--r--src/libthread/sched.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/libthread/sched.c b/src/libthread/sched.c
index 55898f08..7e430193 100644
--- a/src/libthread/sched.c
+++ b/src/libthread/sched.c
@@ -51,28 +51,43 @@ _threadscheduler(void *arg)
/*
* If thread needs to die, kill it.
+ * t->proc == p may not be true if we're
+ * trying to jump into the exec proc (see exec-unix.c).
*/
if(t->moribund){
_threaddebug(DBGSCHED, "moribund %d.%d", p->id, t->id);
+ if(t->moribund != 1)
+ print("moribund broke %p %d\n", &t->moribund, t->moribund);
assert(t->moribund == 1);
t->state = Dead;
- if(t->prevt)
- t->prevt->nextt = t->nextt;
- else
- p->threads.head = t->nextt;
- if(t->nextt)
- t->nextt->prevt = t->prevt;
- else
- p->threads.tail = t->prevt;
+ _procdelthread(p, t);
unlock(&p->lock);
_threadfree(t);
- p->nthreads--;
t = nil;
continue;
}
+
+ /*
+ * If the thread has asked to move to another proc,
+ * let it go (only to be used in *very* special situations).
+ if(t->nextproc != p)
+ _procdelthread(p, t);
+ */
+
unlock(&p->lock);
/*
+ * If the thread has asked to move to another proc,
+ * add it to the new proc.
+ */
+ if(t->nextproc != p){
+ // lock(&t->nextproc->lock);
+ // _procaddthread(t->nextproc, t);
+ // unlock(&t->nextproc->lock);
+ t->proc = t->nextproc;
+ }
+
+ /*
* If there is a request to run a function on the
* scheduling stack, do so.
*/
@@ -87,7 +102,7 @@ _threadscheduler(void *arg)
* Move the thread along.
*/
t->state = t->nextstate;
- _threaddebug(DBGSCHED, "moveon %d.%d", p->id, t->id);
+ _threaddebug(DBGSCHED, "moveon %d.%d", t->proc->id, t->id);
if(t->state == Ready)
_threadready(t);
}