From a4152607760c8cb233e29db50d80769597f34a12 Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Tue, 13 May 2025 16:49:28 +0200 Subject: [PATCH] rename lock --- interrupt/handlers.cc | 8 ++++---- main.cc | 3 +-- user/app1/appl.cc | 13 +++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/interrupt/handlers.cc b/interrupt/handlers.cc index 72bf885..128b416 100644 --- a/interrupt/handlers.cc +++ b/interrupt/handlers.cc @@ -70,16 +70,16 @@ enum PAGE_FAULT_ERROR { } extern TextStream kout; -extern Ticketlock ticketlock; +extern Ticketlock koutlock; void handle_keyboard() { - ticketlock.lock(); Key key = Key(); if (PS2Controller::fetch(key)) { - kout << key.ascii() << endl << flush ; + koutlock.lock(); + kout << key.ascii() << flush ; + koutlock.unlock(); } - ticketlock.unlock(); LAPIC::endOfInterrupt(); } diff --git a/main.cc b/main.cc index 4b3e4a3..0213dad 100644 --- a/main.cc +++ b/main.cc @@ -16,6 +16,7 @@ #include "sync/ticketlock.h" TextStream kout = TextStream(0, 80, 0, 10, true); +Ticketlock koutlock; //TextStream dout[8] = { // TextStream(0 ,20,12,25,false), @@ -50,8 +51,6 @@ CopyStream copystream[Core::MAX]{ {&dout[7], &sout}, }; -Ticketlock ticketlock; - OutputStream* copyout[Core::MAX]{ &dout[0], ©stream[1], diff --git a/user/app1/appl.cc b/user/app1/appl.cc index 5f37b32..17cb12a 100644 --- a/user/app1/appl.cc +++ b/user/app1/appl.cc @@ -20,13 +20,14 @@ Und wacht sie aus'm Koma auf, kriegt sie von mir 'n Sticker\n\ \n"; extern TextStream kout; -extern Ticketlock ticketlock; +extern Ticketlock koutlock; + void activeWaitDelay(uint64_t cycles) { uint64_t counter = 0; // Use volatile to prevent optimization for (uint64_t i = 0; i < cycles; ++i) { counter++; // Simple operation to consume cycles - //asm("nop"); - Core::pause(); + asm("nop"); + //Core::pause(); } } @@ -34,17 +35,17 @@ void Application::action() { // NOLINT uint16_t cnt = 0; while (1) { Core::Interrupt::disable(); - ticketlock.lock(); + koutlock.lock(); while(text[cnt++] != '\n'){ kout << text[cnt-1]; } kout << endl << flush; + koutlock.unlock(); - activeWaitDelay(10000000); + activeWaitDelay(1000000000); if(cnt >= sizeof(text)-1) cnt=0; - ticketlock.unlock(); Core::Interrupt::enable(); } }