// vim: set noet ts=4 sw=4: #include "dispatcher.h" #include "../arch/tss.h" #include "thread.h" #include "../arch/core.h" #include "../debug/output.h" // IWYU pragma: keep Dispatcher::Dispatcher() : life(nullptr) {} Thread *Dispatcher::active() const { return life; } extern four_lvl_paging_t paging_tree; void Dispatcher::go(Thread *first) { assert(active() == nullptr); setActive(first); mytss.sp0 = first->StackPointer.isr; load_cr3((void*)&paging_tree.l4); first->go(); } void Dispatcher::dispatch(Thread *next) { Thread *current = active(); assert(current != nullptr); if (current != next) { setActive(next); mytss.sp0 = next->StackPointer.isr; load_cr3((void*)&paging_tree.l4); current->resume(next); } }