1

add a shnitton of loggers

This commit is contained in:
2022-07-16 03:30:20 +02:00
parent 60d746af11
commit 2f7a2a219b
25 changed files with 177 additions and 173 deletions

View File

@ -55,8 +55,8 @@ void Scheduler::ready(Thread* that) {
// Thread-Wechsel durch PIT verhindern
cpu.disable_int();
this->ready_queue.insert(that);
kout << "Scheduler :: Adding to ready_queue" << endl;
this->ready_queue.print();
log << TRACE << "Scheduler :: Adding to ready_queue" << endl;
this->ready_queue.print(log << TRACE);
cpu.enable_int();
}
@ -75,8 +75,8 @@ void Scheduler::exit() {
// Thread-Wechsel durch PIT verhindern
cpu.disable_int();
Thread& next = *(Thread*)this->ready_queue.remove_first();
kout << "Scheduler :: Exiting thread" << endl;
this->ready_queue.print();
log << TRACE << "Scheduler :: Exiting thread" << endl;
this->ready_queue.print(log << TRACE);
this->dispatch(next);
// Interrupts werden in Thread_switch in Thread.asm wieder zugelassen
@ -101,8 +101,8 @@ void Scheduler::kill(Thread* that) {
// Thread-Wechsel durch PIT verhindern
cpu.disable_int();
this->ready_queue.remove(that);
kout << "Scheduler :: Killing thread" << endl;
this->ready_queue.print();
log << TRACE << "Scheduler :: Killing thread" << endl;
this->ready_queue.print(log << TRACE);
cpu.enable_int();
}
@ -125,8 +125,8 @@ void Scheduler::yield() {
cpu.disable_int();
this->ready_queue.insert(this->get_active());
Thread& next = *(Thread*)this->ready_queue.remove_first();
kout << "Scheduler :: Yield" << endl;
this->ready_queue.print();
log << TRACE << "Scheduler :: Yield" << endl;
this->ready_queue.print(log << TRACE);
this->dispatch(next);
}

View File

@ -18,6 +18,7 @@
#include "lib/Queue.h"
#include "lib/SpinLock.h"
#include "user/lib/ArrayList.h"
#include "user/lib/Logger.h"
class Scheduler : public Dispatcher {
private:
@ -29,6 +30,8 @@ private:
// bevor er initialisiert wurde
bool has_idle_thread;
Logger log;
// NOTE: I would have to release the lock when switching threads but I don't know exactly how to do this
// in the assembly function
// SpinLock lock; // Use spinlock instead of cpu.disable_int() because it still allows preemption
@ -39,7 +42,7 @@ private:
ArrayList<Thread*> ready_queue;
public:
Scheduler() : has_idle_thread(false) {}
Scheduler() : has_idle_thread(false), log("SCHED") {}
void init() {
this->ready_queue.init();