thread implementation
This commit is contained in:
5
main.cc
5
main.cc
@@ -127,10 +127,9 @@ extern "C" int main() {
|
|||||||
|
|
||||||
DBG << "Main CPU " << static_cast<int>(LAPIC::getID()) << endl << flush;
|
DBG << "Main CPU " << static_cast<int>(LAPIC::getID()) << endl << flush;
|
||||||
|
|
||||||
prepareContext(&test1_stack[sizeof(test1_stack)-1], test1, (void(*)(void*)) &(test_func1));
|
test1_thread.go();
|
||||||
prepareContext(&test2_stack[sizeof(test2_stack)-1], test2, (void(*)(void*)) &(test_func2));
|
|
||||||
|
|
||||||
context_launch(&test1);
|
|
||||||
|
|
||||||
//Application{}.action();
|
//Application{}.action();
|
||||||
while (true){
|
while (true){
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// vim: set noet ts=4 sw=4:
|
// vim: set noet ts=4 sw=4:
|
||||||
|
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
#include "../arch/context.h"
|
||||||
|
|
||||||
// Alias to simplify stuff
|
// Alias to simplify stuff
|
||||||
typedef void (*kickoff_t)(void*);
|
typedef void (*kickoff_t)(void*);
|
||||||
@@ -10,14 +11,17 @@ void Thread::kickoff(Thread* object) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Thread::Thread(void* tos) {
|
Thread::Thread(void* tos) {
|
||||||
|
prepareContext(tos, context, (void(*)(void*)) &(kickoff), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::resume(Thread* next) {
|
void Thread::resume(Thread* next) {
|
||||||
|
context_switch(&next->context, &context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::go() {
|
void Thread::go() {
|
||||||
|
context_launch(&context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::action() {}
|
void Thread::action() {
|
||||||
|
while(1);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user