[][src]Static sunrise_kernel::scheduler::CURRENT_THREAD

static CURRENT_THREAD: RefCell<Option<Arc<ThreadStruct>>>

An Arc to the currently running thread.

In the early kernel initialization, this will be None. Once the first thread takes over, this variable is guaranteed to always be Some and never go back to None - if all threads are currently waiting, the global will point to whatever the last thread was running. A useful side-effect: the CURRENT_PROCESS's pmemory will always be the current CR3.

A side-effect of this guarantee is, if the last thread dies, it will still be kept alive through this global!

Safety

Setting this value should be done through set_current_thread, otherwise Bad Things:tm: will happen.