Files
bsb2/kernel/thread/dispatcher.cc
2026-02-17 11:36:26 +01:00

31 lines
665 B
C++

// 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;
first->go();
}
void Dispatcher::dispatch(Thread *next) {
Thread *current = active();
assert(current != nullptr);
if (current != next) {
setActive(next);
mytss.sp0 = next->StackPointer.isr;
current->resume(next);
}
}