You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.5 KiB
C++

// vim: set noet ts=4 sw=4:
#include "scheduler.h"
#include "../arch/lapic.h"
#include "dispatcher.h"
#include "../interrupt/guard.h"
#include "../debug/output.h"
Queue<Thread> readyList = Queue<Thread>();
Scheduler::Scheduler() {
}
Thread* Scheduler::getNext() { return nullptr; }
void Scheduler::schedule() {
// TODO maybe guard?
Thread* next = readyList.dequeue();
assert(next != nullptr);
dispatcher.go(next);
}
void Scheduler::ready(Thread* that) {
assert(that != nullptr);
readyList.enqueue(*that);
}
void Scheduler::resume(bool ready) {
//if (!active()->kill_flag)
if (ready)
readyList.enqueue(*active());
Thread* thread = readyList.dequeue();
assert(thread != nullptr);
dispatcher.dispatch(thread);
}
void Scheduler::exit() {
Thread* thread = readyList.dequeue();
assert(thread != nullptr);
dispatcher.dispatch(thread);
}
void Scheduler::kill(Thread* that) {
readyList.remove(that);
that->kill_flag = true;
DBG << "kill..." << flush;
for(uint8_t i=0;i<Core::MAX; i++)
if(dispatcher.lifePointer[i] == that){
LAPIC::IPI::send(i, Core::Interrupt::Vector::ASSASSIN);
DBG << "found thread on Core" << dec << static_cast<int>(i) << "! killing...\n" << flush;
return;
}
DBG << "not found\n" << flush;
}
bool Scheduler::isActive(const Thread* thread, unsigned int* cpu) {
(void)thread;
(void)cpu;
return false;
}
bool Scheduler::isEmpty() const { return false; }
void Scheduler::setIdle(IdleThread* that) { (void)that; }