diff --git a/arch/core_interrupt.h b/arch/core_interrupt.h index 190b69e..cd3d53f 100644 --- a/arch/core_interrupt.h +++ b/arch/core_interrupt.h @@ -69,7 +69,8 @@ enum Vector { // Interrupts KEYBOARD=32, PANIC=33, - TIMER=34 + TIMER=34, + ASSASSIN=35 }; constexpr size_t VECTORS = 256; diff --git a/interrupt/epilogues.cc b/interrupt/epilogues.cc index c18918c..d67cb10 100644 --- a/interrupt/epilogues.cc +++ b/interrupt/epilogues.cc @@ -1,17 +1,23 @@ #include "epilogues.h" #include "../debug/output.h" +#include "../arch/core.h" +#include "../arch/lapic.h" #include "guard.h" #include "../thread/scheduler.h" extern Key kout_key; +#include "../user/app1/appl.h" +extern Application application1; namespace Epilogues { void keyboard(Vault& v) { v.kout.setPos(0,0); v.kout << kout_key.ascii() << flush ; + if(kout_key.scancode == Key::KEY_K) + v.sch.kill(v.sch.dispatcher.lifePointer[3]); } void timer(Vault& v) { @@ -23,11 +29,13 @@ void timer(Vault& v) { v.kout << counter++ << flush; v.kout.setPos(x, y); } + DBG << "timer C:" << dec << Core::getID() << " L:" << LAPIC::getID() << "\n" << flush; v.sch.resume(true); } void assassin(Vault& v) { + DBG << "assassin epilog\n"<< endl; if (v.sch.active()->kill_flag) { v.sch.exit(); } diff --git a/interrupt/guard.cc b/interrupt/guard.cc index 13b1d3b..20c47ed 100644 --- a/interrupt/guard.cc +++ b/interrupt/guard.cc @@ -57,7 +57,7 @@ void Guard::relay(Epilogue handler) { Core::Interrupt::enable(); // goto level 0.5 if(epi_flag FOR_CURRENT_CORE){ - epilogue_queue->produce(handler); + epilogue_queue FOR_CURRENT_CORE.produce(handler); } else{ epi_flag FOR_CURRENT_CORE = true; diff --git a/interrupt/handlers.cc b/interrupt/handlers.cc index 7c6b34c..52c334d 100644 --- a/interrupt/handlers.cc +++ b/interrupt/handlers.cc @@ -10,9 +10,11 @@ #include "../device/ps2controller.h" #include "../sync/ticketlock.h" +#include "../arch/core_interrupt.h" #include "epilogues.h" #include "guard.h" + Key kout_key = Key(); void printContext(const InterruptContext *context) { @@ -77,6 +79,7 @@ void handle_keyboard() { LAPIC::endOfInterrupt(); if (kout_key.ctrl() && kout_key.alt() && kout_key.scancode == Key::KEY_DEL) System::reboot(); + Guard::relay(Epilogues::keyboard); } else @@ -98,6 +101,7 @@ void handle_keyboard() { [[gnu::interrupt]] void handle_assassin(InterruptContext *context) { (void)context; LAPIC::endOfInterrupt(); + DBG << "assassin handler\n"<< endl; Guard::relay(Epilogues::assassin); } [[gnu::interrupt]] void handle_wakeup(InterruptContext *context) { @@ -126,6 +130,8 @@ void initInterruptHandlers() { IDT::InterruptDescriptor::Returning(handle_keyboard_asm)); IDT::set(Core::Interrupt::Vector::TIMER, IDT::InterruptDescriptor::Returning(handle_timer)); + IDT::set(Core::Interrupt::Vector::ASSASSIN, + IDT::InterruptDescriptor::Returning(handle_assassin)); // Load the idt pointer IDT::load(); } diff --git a/main.cc b/main.cc index ae4f153..a85c271 100644 --- a/main.cc +++ b/main.cc @@ -146,10 +146,9 @@ extern "C" int main() { // Main function for application processors extern "C" int main_ap() { - DBG_VERBOSE << "CPU core " << static_cast(Core::getID()) << " / LAPIC " + DBG << "CPU core " << static_cast(Core::getID()) << " / LAPIC " << static_cast(LAPIC::getID()) << " in main_ap()" << endl; - DBG << "App CPU " << static_cast(Core::getID()) << endl << flush; LAPIC::Timer::setup(1000000); Core::Interrupt::enable(); diff --git a/thread/scheduler.cc b/thread/scheduler.cc index 186ebdd..536b6a2 100644 --- a/thread/scheduler.cc +++ b/thread/scheduler.cc @@ -1,6 +1,10 @@ // vim: set noet ts=4 sw=4: #include "scheduler.h" +#include "../arch/lapic.h" +#include "dispatcher.h" +#include "../interrupt/guard.h" +#include "../debug/output.h" Queue readyList = Queue(); @@ -39,6 +43,17 @@ void Scheduler::exit() { void Scheduler::kill(Thread* that) { readyList.remove(that); that->kill_flag = true; + + DBG << "kill..." << flush; + + for(uint8_t i=0;i(i) << "! killing...\n" << flush; + return; + } + + DBG << "not found\n" << flush; } bool Scheduler::isActive(const Thread* thread, unsigned int* cpu) { diff --git a/user/app1/appl.cc b/user/app1/appl.cc index 6e5e3c0..690bdb7 100644 --- a/user/app1/appl.cc +++ b/user/app1/appl.cc @@ -25,9 +25,6 @@ Ich bin Großmuttersniffer\n\ Und wacht sie aus'm Koma auf, kriegt sie von mir 'n Sticker\n\ \n"; -extern Ticketlock koutlock; -extern Context* test2; extern Context* test1; -extern uint8_t test1_stack[], test2_stack[]; void activeWaitDelay(uint64_t cycles) { uint64_t counter = 0; // Use volatile to prevent optimization for (uint64_t i = 0; i < cycles; ++i) {