The thread library maintains a global pointer to the currently executing thread in the process.
uthread_t *ut_curthr;
The uthread_init() function must be called (once) by a program that uses the uthread library to initialize the uthread global data structures and to convert the initial thread of the process to a uthread.
This function should initialize the global uthreads array. Each entry should be initialized to indicate not yet in use:
- ut_state should be set to UT_NO_STATE
- ut_id should be initialized; e.g, uthreads[k].ut_id can be set to k.
- ut_stack set to NULL
- ut_prio is used as the index into an array of queues. To initialize this as unused, it could be set to -1.
- ut_errno can be set to 0 (no error)
- ut_waiter pointer to thread that has called uthread_join for this thread. Set to NULL.