From 7322a9ed70d877c00c0c05e169e488101ce05821 Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Mon, 23 Jun 2025 21:27:57 +0200 Subject: [PATCH] schedule with 4 application --- main.cc | 26 +++++++++++++++++++++++--- thread/thread.cc | 1 + user/app1/appl.cc | 8 ++++++-- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/main.cc b/main.cc index d9dfbfa..20e4f8b 100644 --- a/main.cc +++ b/main.cc @@ -73,9 +73,13 @@ unsigned int testx, testy; uint8_t test1_stack[1024]; uint8_t test2_stack[1024]; +uint8_t test3_stack[1024]; +uint8_t test4_stack[1024]; //Thread test1_thread = Thread(&test1_stack[sizeof(test1_stack)-1]); Application application1 = Application(&test1_stack[sizeof(test1_stack)-1]); Application application2 = Application(&test2_stack[sizeof(test2_stack)-1]); +Application application3 = Application(&test3_stack[sizeof(test3_stack)-1]); +Application application4 = Application(&test4_stack[sizeof(test4_stack)-1]); //Context test2; //uint8_t test2_stack[256]; @@ -114,6 +118,14 @@ extern "C" int main() { * Startup IPIs or even block devices like keyboard because of a missing EOI */ + { + Guarded g = Guard::enter(); + sch.ready(&application1); + sch.ready(&application2); + sch.ready(&application3); + sch.ready(&application4); + } + ApplicationProcessor::boot(); PS2Controller::init(); @@ -128,9 +140,12 @@ extern "C" int main() { DBG << "Main CPU " << static_cast(LAPIC::getID()) << endl << flush; - sch.ready(&application1); - sch.ready(&application2); - sch.schedule(); + + + { + Guarded g = Guard::enter(); + sch.schedule(); + } //Application{}.action(); @@ -150,6 +165,11 @@ extern "C" int main_ap() { DBG << "App CPU " << static_cast(Core::getID()) << endl << flush; + { + Guarded g = Guard::enter(); + sch.schedule(); + } + //assert(Core::getID() != 1); //Application{}.action(); diff --git a/thread/thread.cc b/thread/thread.cc index 8abfefe..b34c556 100644 --- a/thread/thread.cc +++ b/thread/thread.cc @@ -8,6 +8,7 @@ typedef void (*kickoff_t)(void*); void Thread::kickoff(Thread* object) { + Guard::leave(); object->action(); } diff --git a/user/app1/appl.cc b/user/app1/appl.cc index 8ef0ea4..5511df2 100644 --- a/user/app1/appl.cc +++ b/user/app1/appl.cc @@ -47,7 +47,7 @@ void Application::action() { // NOLINT { Guarded g = Guard::enter(); //g.vault(); - g.vault().kout.setPos((unsigned)10*row,(unsigned)Core::getID()*2+1); + g.vault().kout.setPos((unsigned)10*row,(unsigned)/*Core::getID()*2+*/1); g.vault().kout << cnt++ << flush; //g.vault().kout << endl << flush; @@ -57,7 +57,11 @@ void Application::action() { // NOLINT //Core::pause(); //activeWaitDelay(10000000); - sch.resume(true); + + { + Guarded g = Guard::enter(); + sch.resume(true); + } if(cnt >= sizeof(text)-1) cnt=0;