1

use pointer instead of reference for thread

This commit is contained in:
2022-07-11 14:36:41 +02:00
parent 9c41c72011
commit 7058350414
2 changed files with 16 additions and 2 deletions

View File

@ -174,6 +174,16 @@ void Scheduler::preempt() {
void Scheduler::block() { void Scheduler::block() {
/* hier muss Code eingefuegt werden */ /* hier muss Code eingefuegt werden */
if (this->readyQueue.isEmpty()) {
// Something went seriously wrong
return;
}
cpu.disable_int();
Thread& next = *(Thread*)this->readyQueue.dequeue();
this->dispatch(next);
} }
/***************************************************************************** /*****************************************************************************
@ -187,7 +197,11 @@ void Scheduler::block() {
* * * *
* Parameter: that: Thread der deblockiert werden soll. * * Parameter: that: Thread der deblockiert werden soll. *
*****************************************************************************/ *****************************************************************************/
void Scheduler::deblock(Thread& that) { void Scheduler::deblock(Thread* that) {
/* hier muss Code eingefuegt werden */ /* hier muss Code eingefuegt werden */
cpu.disable_int();
this->readyQueue.enqueue(that);
cpu.enable_int();
} }

View File

@ -56,7 +56,7 @@ public:
void preempt(); void preempt();
void block(); void block();
void deblock(Thread& that); void deblock(Thread* that);
}; };
#endif #endif