void main(int argc, char **argv) { Mainarg *a; Proc *p; rfork(RFREND); mainp = &p; if(setjmp(_mainjmp)) _schedinit(p); //_threaddebuglevel = (DBGSCHED|DBGCHAN|DBGREND)^~0; _systhreadinit(); _qlockinit(_threadrendezvous); _sysfatal = _threadsysfatal; _dial = _threaddial; __assert = _threadassert; notify(_threadnote); if(mainstacksize == 0) mainstacksize = 8*1024; a = _threadmalloc(sizeof *a, 1); a->argc = argc; a->argv = argv; p = _newproc(mainlauncher, a, mainstacksize, "threadmain", 0, 0); _schedinit(p); abort(); /* not reached */ }
int procrfork(void (*f)(void *), void *arg, uint stacksize, int rforkflag) { Proc *p; int id; p = _threadgetproc(); assert(p->newproc == nil); p->newproc = _newproc(f, arg, stacksize, nil, p->thread->grp, rforkflag); id = p->newproc->threads.head->id; _sched(); return id; }