void __lwp_sysinit() { __lwp_objmgr_initinfo(&_lwp_thr_objects,LWP_MAX_THREADS,sizeof(lwp_cntrl)); __lwp_objmgr_initinfo(&_lwp_tqueue_objects,LWP_MAX_TQUEUES,sizeof(tqueue_st)); // create idle thread, is needed iff all threads are locked on a queue _thr_idle = (lwp_cntrl*)__lwp_objmgr_allocate(&_lwp_thr_objects); __lwp_thread_init(_thr_idle,NULL,0,255,0,TRUE); _thr_executing = _thr_heir = _thr_idle; __lwp_thread_start(_thr_idle,idle_func,NULL); __lwp_objmgr_open(&_lwp_thr_objects,&_thr_idle->object); // create main thread, as this is our entry point // for every GC application. _thr_main = (lwp_cntrl*)__lwp_objmgr_allocate(&_lwp_thr_objects); __lwp_thread_init(_thr_main,__stack_end,((u32)__stack_addr-(u32)__stack_end),191,0,TRUE); __lwp_thread_start(_thr_main,(void*)__crtmain,NULL); __lwp_objmgr_open(&_lwp_thr_objects,&_thr_main->object); }
static tqueue_st* __lwp_tqueue_allocate() { tqueue_st *tqueue; __lwp_thread_dispatchdisable(); tqueue = (tqueue_st*)__lwp_objmgr_allocate(&_lwp_tqueue_objects); if(tqueue) { __lwp_objmgr_open(&_lwp_tqueue_objects,&tqueue->object); return tqueue; } __lwp_thread_dispatchenable(); return NULL; }
static lwp_cntrl* __lwp_cntrl_allocate() { lwp_cntrl *thethread; __lwp_thread_dispatchdisable(); thethread = (lwp_cntrl*)__lwp_objmgr_allocate(&_lwp_thr_objects); if(thethread) { __lwp_objmgr_open(&_lwp_thr_objects,&thethread->object); return thethread; } __lwp_thread_dispatchenable(); return NULL; }
static cond_st* __lwp_cond_allocate() { cond_st *cond; __lwp_thread_dispatchdisable(); cond = (cond_st*)__lwp_objmgr_allocate(&_lwp_cond_objects); if(cond) { __lwp_objmgr_open(&_lwp_cond_objects,&cond->object); return cond; } __lwp_thread_dispatchenable(); return NULL; }
static mqbox_st* __lwp_mqbox_allocate() { mqbox_st *mqbox; __lwp_thread_dispatchdisable(); mqbox = (mqbox_st*)__lwp_objmgr_allocate(&_lwp_mqbox_objects); if(mqbox) { __lwp_objmgr_open(&_lwp_mqbox_objects,&mqbox->object); return mqbox; } __lwp_thread_dispatchenable(); return NULL; }