From 83e18391b758c554d2d7b72d9609fd1314eed665 Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Sun, 1 Jun 2025 18:43:46 +0200 Subject: [PATCH] rum --- interrupt/epilogues.cc | 2 ++ interrupt/guard.cc | 29 +++++++++++++++-------------- interrupt/handlers.cc | 1 + main.cc | 6 +++--- sync/ticketlock.cc | 5 ++++- user/app1/appl.cc | 2 +- 6 files changed, 26 insertions(+), 19 deletions(-) diff --git a/interrupt/epilogues.cc b/interrupt/epilogues.cc index f9e3b86..e0729dc 100644 --- a/interrupt/epilogues.cc +++ b/interrupt/epilogues.cc @@ -1,5 +1,6 @@ #include "epilogues.h" +#include "../debug/output.h" #include "guard.h" extern Key kout_key; @@ -8,6 +9,7 @@ extern TextStream kout; namespace Epilogues { void keyboard(Vault& g) { + DBG << "keyboard epi" << endl << flush; (void)g; kout << kout_key.ascii() << endl << flush ; } diff --git a/interrupt/guard.cc b/interrupt/guard.cc index 9c337c6..b6f7332 100644 --- a/interrupt/guard.cc +++ b/interrupt/guard.cc @@ -44,22 +44,23 @@ void Guard::leave() { } void Guard::relay(Epilogue handler) { - if(!epilogue_queue FOR_CURRENT_CORE.consume(handler)) - return; // enqueue, but dont execute - if(epi_flag FOR_CURRENT_CORE){ - enter(); - Core::Interrupt::disable(); - leave(); - } - //Core::Interrupt::enable(); // goto level 0.5 - //if(epi_flag FOR_CURRENT_CORE){ - // epilogue_queue->produce(handler); - //} - //else{ - // epi_flag FOR_CURRENT_CORE = true; + //if(!epilogue_queue FOR_CURRENT_CORE.produce(handler)) + // return; // enqueue, but dont execute + //if(!epi_flag FOR_CURRENT_CORE){ + // enter(); + // Core::Interrupt::enable(); // handler(global_vault); - // leave(); // maybe not needed since destructor also calls leave + // leave(); //} + Core::Interrupt::enable(); // goto level 0.5 + if(epi_flag FOR_CURRENT_CORE){ + epilogue_queue->produce(handler); + } + else{ + epi_flag FOR_CURRENT_CORE = true; + handler(global_vault); + leave(); // maybe not needed since destructor also calls leave + } } const Vault &Guard::unsafeConstAccess() { return global_vault; } diff --git a/interrupt/handlers.cc b/interrupt/handlers.cc index 68265e4..b135bc1 100644 --- a/interrupt/handlers.cc +++ b/interrupt/handlers.cc @@ -78,6 +78,7 @@ extern Ticketlock koutlock; extern Vault keyboard_vault; void handle_keyboard() { + DBG << "keyboard pro" << endl << flush; //Key key = Key(); if (PS2Controller::fetch(kout_key)) { Guard::relay(Epilogues::keyboard); diff --git a/main.cc b/main.cc index cf48433..14d80da 100644 --- a/main.cc +++ b/main.cc @@ -31,7 +31,7 @@ Ticketlock koutlock; //}; TextStream dout[Core::MAX] = { - {0, 40, 10, 14}, + {0, 40, 10, 20}, {40, 80, 10, 14}, {0, 40, 14, 18}, {40, 80, 14, 18}, @@ -110,8 +110,8 @@ extern "C" int main() { Application{}.action(); while (true){ - DBG << "pos: " << testx << ", " << testy << endl << flush; - Core::pause(); + //DBG << "pos: " << testx << ", " << testy << endl << flush; + //Core::pause(); } return 0; diff --git a/sync/ticketlock.cc b/sync/ticketlock.cc index 401bcb3..a9e739f 100644 --- a/sync/ticketlock.cc +++ b/sync/ticketlock.cc @@ -1,4 +1,5 @@ #include "sync/ticketlock.h" +#include "debug/output.h" void Ticketlock::lock() { uint64_t ticket = __atomic_fetch_add(&ticket_count, 1, __ATOMIC_RELAXED); @@ -8,5 +9,7 @@ void Ticketlock::lock() { } void Ticketlock::unlock() { - __atomic_fetch_add(&ticket_current, 1, __ATOMIC_RELEASE); + if(ticket_current != ticket_count){ + __atomic_fetch_add(&ticket_current, 1, __ATOMIC_RELEASE); + } } diff --git a/user/app1/appl.cc b/user/app1/appl.cc index 67c3392..2799c67 100644 --- a/user/app1/appl.cc +++ b/user/app1/appl.cc @@ -43,7 +43,7 @@ void Application::action() { // NOLINT kout << text[cnt-1]; } kout << endl << flush; - Guard::leave(); + //Guard::leave(); //koutlock.unlock(); activeWaitDelay(1000000000);