diff --git a/main.cc b/main.cc index 190eadc..7e231f8 100644 --- a/main.cc +++ b/main.cc @@ -12,6 +12,7 @@ #include "device/textstream.h" #include "device/ps2controller.h" #include "arch/ioapic.h" +#include "thread/scheduler.h" #include "user/app1/appl.h" #include "sync/ticketlock.h" #include "interrupt/guard.h" @@ -71,32 +72,32 @@ unsigned int testx, testy; Context test1; uint8_t test1_stack[256]; -Thread test1_thread = Thread(&test1_stack[sizeof(test1_stack)-1]); -//Application application = Application(test1_stack); - -Context test2; -uint8_t test2_stack[256]; -Thread test2_thread = Thread(&test2_stack[sizeof(test2_stack)-1]); - -void test_func1(){ - while(1){ - { - Guarded g = Guard::enter(); - g.vault().kout << "test 1\n" << flush; - } - context_switch(&test2, &test1); - } -} - -void test_func2(){ - while(1){ - { - Guarded g = Guard::enter(); - g.vault().kout << "test 2\n" << flush; - } - context_switch(&test1, &test2); - } -} +//Thread test1_thread = Thread(&test1_stack[sizeof(test1_stack)-1]); +Application application = Application(test1_stack); + +//Context test2; +//uint8_t test2_stack[256]; +//Thread test2_thread = Thread(&test2_stack[sizeof(test2_stack)-1]); + +//void test_func1(){ +// while(1){ +// { +// Guarded g = Guard::enter(); +// g.vault().kout << "test 1\n" << flush; +// } +// context_switch(&test2, &test1); +// } +//} +// +//void test_func2(){ +// while(1){ +// { +// Guarded g = Guard::enter(); +// g.vault().kout << "test 2\n" << flush; +// } +// context_switch(&test1, &test2); +// } +//} @@ -126,7 +127,10 @@ extern "C" int main() { DBG << "Main CPU " << static_cast(LAPIC::getID()) << endl << flush; - test1_thread.go(); + Scheduler sch; + sch.ready(&application); + sch.schedule(); + //Application{}.action(); while (true){ diff --git a/thread/dispatcher.cc b/thread/dispatcher.cc index 6ffb6cc..1420f33 100644 --- a/thread/dispatcher.cc +++ b/thread/dispatcher.cc @@ -1,7 +1,7 @@ // vim: set noet ts=4 sw=4: #include "dispatcher.h" -#include "core.h" +#include "../arch/core.h" Dispatcher::Dispatcher() { } diff --git a/thread/dispatcher.h b/thread/dispatcher.h index d52c83b..e3acce2 100644 --- a/thread/dispatcher.h +++ b/thread/dispatcher.h @@ -6,7 +6,7 @@ #pragma once #include "../thread/thread.h" #include "../types.h" -#include "core.h" +#include "../arch/core.h" /*! \brief The dispatcher dispatches threads and puts the scheduler's * decisions into action. diff --git a/thread/scheduler.cc b/thread/scheduler.cc index 405e8e4..f6badfd 100644 --- a/thread/scheduler.cc +++ b/thread/scheduler.cc @@ -22,7 +22,8 @@ void Scheduler::ready(Thread* that) { } void Scheduler::resume(bool ready) { - if (!active()->kill_flag) + if (ready) + //if (!active()->kill_flag) readyList.enqueue(*active()); Thread* thread = readyList.dequeue(); assert(thread != nullptr);