Blob


1 #include <u.h>
2 #include <signal.h>
3 #include "threadimpl.h"
5 char *_threadexitsallstatus;
6 Channel *_threadwaitchan;
8 void
9 threadexits(char *exitstr)
10 {
11 Proc *p;
12 Thread *t;
14 p = _threadgetproc();
15 t = p->thread;
16 if(t == p->idle)
17 p->idle = nil;
18 t->moribund = 1;
19 _threaddebug(DBGSCHED, "threadexits %s", exitstr);
20 if(exitstr==nil)
21 exitstr="";
22 utfecpy(p->exitstr, p->exitstr+ERRMAX, exitstr);
23 _sched();
24 }
26 void
27 threadexitsall(char *exitstr)
28 {
29 _threaddebug(DBGSCHED, "threadexitsall %s", exitstr);
30 if(exitstr == nil)
31 exitstr = "";
32 _threadexitsallstatus = exitstr;
33 _threaddebug(DBGSCHED, "_threadexitsallstatus set to %p", _threadexitsallstatus);
34 /* leave */
35 _threadexitallproc(exitstr);
36 }
38 Channel*
39 threadwaitchan(void)
40 {
41 if(_threadwaitchan==nil)
42 _threadwaitchan = chancreate(sizeof(Waitmsg*), 16);
43 return _threadwaitchan;
44 }