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.

33 lines
598 B
C++

// vim: set noet ts=4 sw=4:
#include "dispatcher.h"
#include "../arch/core.h"
Dispatcher::Dispatcher() {
}
Thread *Dispatcher::active() {
return lifePointer[Core::getID()];
}
bool Dispatcher::isActive(const Thread *thread, unsigned *cpu) {
for(uint8_t i=0; i<Core::MAX; i++){
if(thread == lifePointer[i]){
*cpu = i;
return true;
}
}
cpu = nullptr;
return false;
}
void Dispatcher::go(Thread *first) {
lifePointer[Core::getID()] = first;
first->go();
}
void Dispatcher::dispatch(Thread *next) {
lifePointer[Core::getID()] = next;
lifePointer[Core::getID()]->resume(next);
}