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.
37 lines
752 B
C++
37 lines
752 B
C++
// vim: set noet ts=4 sw=4:
|
|
|
|
#include "thread.h"
|
|
#include "../debug/output.h"
|
|
#include "../arch/context.h"
|
|
|
|
// Alias to simplify stuff
|
|
typedef void (*kickoff_t)(void*);
|
|
|
|
void Thread::kickoff(Thread* object) {
|
|
object->action();
|
|
}
|
|
|
|
Thread::Thread(void* tos) {
|
|
prepareContext(tos, context, (void(*)(void*)) &(kickoff), this);
|
|
}
|
|
|
|
#include "../thread/scheduler.h"
|
|
extern Scheduler sch;
|
|
void Thread::resume(Thread* next) {
|
|
Context *from = &sch.active()->context;
|
|
Context *to = &next->context;
|
|
|
|
sch.dispatcher.lifePointer[Core::getID()] = next;
|
|
DBG << "from: " << hex << from << endl;
|
|
DBG << "to : " << hex << to << endl << flush;
|
|
context_switch(to, from);
|
|
}
|
|
|
|
void Thread::go() {
|
|
context_launch(&context);
|
|
}
|
|
|
|
void Thread::action() {
|
|
while(1);
|
|
}
|