2 #include "threadimpl.h"
4 typedef struct Mainarg Mainarg;
14 static void mainlauncher(void*);
15 extern void (*_sysfatal)(char*, va_list);
20 extern char *_threadexitsallstatus;
23 if(_threadexitsallstatus)
24 exit(_threadexitsallstatus[0] ? 1 : 0);
28 main(int argc, char **argv)
33 signal(SIGTERM, _threaddie);
36 //_threaddebuglevel = (DBGSCHED|DBGCHAN|DBGREND)^~0;
38 _qlockinit(_threadrendezvous);
39 _sysfatal = _threadsysfatal;
40 // notify(_threadnote);
41 if(mainstacksize == 0)
42 mainstacksize = 32*1024;
44 a = _threadmalloc(sizeof *a, 1);
48 p = _newproc(mainlauncher, a, mainstacksize, "threadmain", 0, 0);
50 abort(); /* not reached */
55 mainlauncher(void *arg)
60 threadmain(a->argc, a->argv);
61 threadexits("threadmain");
70 _threadsignalpasser(void)
79 pid = ffork(RFMEM|RFNOWAIT, _schedinit, p);
92 lock(&_threadpq.lock);
93 for(l=&_threadpq.head; *l; l=&(*l)->next){
101 unlock(&_threadpq.lock);
103 strncpy(ex, p->exitstr, sizeof ex);
104 ex[sizeof ex-1] = '\0';
123 extern int _threadnrendez, _threadhighnrendez,
124 _threadnalt, _threadhighnentry;
125 fprint(2, "*** THREAD LIBRARY STATS ***\n");
126 fprint(2, "nrendez %d high simultaneous %d\n",
127 _threadnrendez, _threadhighnrendez);
128 fprint(2, "nalt %d high simultaneous entry %d\n",
129 _threadnalt, _threadhighnentry);