3 #include "threadimpl.h"
5 typedef struct Mainarg Mainarg;
15 static void mainlauncher(void*);
16 extern void (*_sysfatal)(char*, va_list);
28 extern char *_threadexitsallstatus;
31 if(_threadexitsallstatus)
32 exit(_threadexitsallstatus[0] ? 1 : 0);
36 main(int argc, char **argv)
41 //_threaddebuglevel = (DBGSCHED|DBGCHAN|DBGREND)^~0;
43 _qlockinit(_threadrendezvous);
44 _sysfatal = _threadsysfatal;
46 if(mainstacksize == 0)
47 mainstacksize = 32*1024;
49 a = _threadmalloc(sizeof *a, 1);
53 p = _newproc(mainlauncher, a, mainstacksize, "threadmain", 0, 0);
55 abort(); /* not reached */
60 mainlauncher(void *arg)
65 threadmain(a->argc, a->argv);
66 threadexits("threadmain");
75 _threadsignalpasser(void)
84 pid = ffork(RFMEM|RFNOWAIT, _schedinit, p);
97 lock(&_threadpq.lock);
98 for(l=&_threadpq.head; *l; l=&(*l)->next){
107 unlock(&_threadpq.lock);
109 strncpy(ex, p->exitstr, sizeof ex);
110 ex[sizeof ex-1] = '\0';
129 extern int _threadnrendez, _threadhighnrendez,
130 _threadnalt, _threadhighnentry;
131 fprint(2, "*** THREAD LIBRARY STATS ***\n");
132 fprint(2, "nrendez %d high simultaneous %d\n",
133 _threadnrendez, _threadhighnrendez);
134 fprint(2, "nalt %d high simultaneous entry %d\n",
135 _threadnalt, _threadhighnentry);