change keyboard demo to event listener
This commit is contained in:
@ -202,6 +202,32 @@ void Scheduler::deblock(Thread* that) {
|
||||
/* hier muss Code eingefuegt werden */
|
||||
|
||||
cpu.disable_int();
|
||||
this->readyQueue.enqueue(that);
|
||||
cpu.enable_int();
|
||||
this->readyQueue.enqueue(this->get_active());
|
||||
this->dispatch(*that); // Prefer deblocked
|
||||
}
|
||||
|
||||
// NOTE: Don't need these, input blocked threads are managed inside event manager
|
||||
// These blocking functions are mainly for KeyEvents
|
||||
// void Scheduler::block() {
|
||||
// if (this->readyQueue.isEmpty()) {
|
||||
// // Something went seriously wrong
|
||||
// return;
|
||||
// }
|
||||
|
||||
// cpu.disable_int();
|
||||
// this->blockQueue.enqueue(this->get_active());
|
||||
// Thread& next = *(Thread*)this->readyQueue.dequeue();
|
||||
// this->dispatch(next);
|
||||
// }
|
||||
|
||||
// void Scheduler::deblock(Thread* that) {
|
||||
// if (this->blockQueue.isEmpty()) {
|
||||
// // Something went seriously wrong
|
||||
// return;
|
||||
// }
|
||||
|
||||
// cpu.disable_int();
|
||||
// this->readyQueue.enqueue(this->get_active());
|
||||
// this->blockQueue.remove(that);
|
||||
// this->dispatch(*that); // Prefer deblocked
|
||||
// }
|
||||
|
||||
@ -21,6 +21,7 @@ private:
|
||||
Scheduler(const Scheduler& copy) = delete; // Verhindere Kopieren
|
||||
|
||||
Queue readyQueue; // auf die CPU wartende Threads
|
||||
Queue blockQueue;
|
||||
|
||||
// Scheduler wird evt. von einer Unterbrechung vom Zeitgeber gerufen,
|
||||
// bevor er initialisiert wurde
|
||||
@ -55,8 +56,12 @@ public:
|
||||
// Thread umschalten; wird aus der ISR des PITs gerufen
|
||||
void preempt();
|
||||
|
||||
// TODO: Merge this with usual block/deblock
|
||||
void block();
|
||||
void deblock(Thread* that);
|
||||
|
||||
// void block();
|
||||
// void deblock(Thread* that);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user