1

remove semaphore from cga_stream

This commit is contained in:
2022-07-22 02:56:14 +02:00
parent 3540604ec7
commit 8612587e65
9 changed files with 13 additions and 39 deletions

View File

@ -1,21 +1,19 @@
#include "user/demo/PreemptiveThreadDemo.h"
Semaphore PreemptiveLoopThread::sem(1);
void PreemptiveLoopThread::run() {
int cnt = 0;
while (true) {
// Basic synchronization by semaphore
// NOTE: I placed the semaphore inside the CGA_Stream so multiple demos can synchronize, not
// only this one. This is optional so disruptions can still occur because of preemption
// (I only use this for the user output (demos), anywhere else could become problematic
// quickly...)
kout.lock();
sem.p();
// Saving + restoring kout position doesn't help much as preemption still occurs
kout.setpos(55, this->id);
kout << fillw(3) << this->id << fillw(0) << ": " << dec << cnt++ << endl;
kout.unlock();
sem.v();
}
}