more or less works (with kill)
This commit is contained in:
@@ -69,7 +69,8 @@ enum Vector {
|
||||
// Interrupts
|
||||
KEYBOARD=32,
|
||||
PANIC=33,
|
||||
TIMER=34
|
||||
TIMER=34,
|
||||
ASSASSIN=35
|
||||
};
|
||||
constexpr size_t VECTORS = 256;
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
3
main.cc
3
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<int>(Core::getID()) << " / LAPIC "
|
||||
DBG << "CPU core " << static_cast<int>(Core::getID()) << " / LAPIC "
|
||||
<< static_cast<int>(LAPIC::getID()) << " in main_ap()" << endl;
|
||||
|
||||
DBG << "App CPU " << static_cast<int>(Core::getID()) << endl << flush;
|
||||
|
||||
LAPIC::Timer::setup(1000000);
|
||||
Core::Interrupt::enable();
|
||||
|
||||
@@ -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<Thread> readyList = Queue<Thread>();
|
||||
|
||||
@@ -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<Core::MAX; i++)
|
||||
if(dispatcher.lifePointer[i] == that){
|
||||
LAPIC::IPI::send(i, Core::Interrupt::Vector::ASSASSIN);
|
||||
DBG << "found thread on Core << dec << static_cast<int>(i) << "! killing...\n" << flush;
|
||||
return;
|
||||
}
|
||||
|
||||
DBG << "not found\n" << flush;
|
||||
}
|
||||
|
||||
bool Scheduler::isActive(const Thread* thread, unsigned int* cpu) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user