update demos for nice_kill
This commit is contained in:
@ -9,9 +9,7 @@ private:
|
||||
ArrayDemo(const ArrayDemo& copy) = delete;
|
||||
|
||||
public:
|
||||
ArrayDemo() {
|
||||
kout << "Initialized ArrayDemo" << endl;
|
||||
}
|
||||
ArrayDemo() : Thread("ArrayDemo") {}
|
||||
|
||||
void run() override;
|
||||
};
|
||||
|
||||
@ -9,12 +9,9 @@ private:
|
||||
BlueScreenDemo(const BlueScreenDemo& copy) = delete;
|
||||
|
||||
public:
|
||||
BlueScreenDemo() {
|
||||
kout << "Initialized BlueScreenDemo" << endl;
|
||||
}
|
||||
BlueScreenDemo() : Thread("BlueScreenDemo") {}
|
||||
|
||||
void run() override;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -25,9 +25,7 @@ private:
|
||||
HeapDemo(const HeapDemo& copy) = delete;
|
||||
|
||||
public:
|
||||
HeapDemo() {
|
||||
kout << "Initialized HeapDemo" << endl;
|
||||
}
|
||||
HeapDemo() : Thread("HeapDemo") {}
|
||||
|
||||
void run() override;
|
||||
};
|
||||
|
||||
@ -24,8 +24,11 @@ void KeyboardDemo::run() {
|
||||
kout << "\nInput: ";
|
||||
kout.flush();
|
||||
|
||||
while (true) {
|
||||
while (running) {
|
||||
kout << listener.waitForKeyEvent();
|
||||
kout.flush();
|
||||
}
|
||||
|
||||
kout.unlock();
|
||||
scheduler.exit();
|
||||
}
|
||||
|
||||
@ -22,16 +22,20 @@ private:
|
||||
KeyEventListener listener;
|
||||
|
||||
public:
|
||||
KeyboardDemo() : listener(this->tid) {
|
||||
log << INFO << "Initialized KeyboardDemo with ID: " << dec << this->tid << endl;
|
||||
KeyboardDemo() : Thread("KeyboardDemo"), listener(this->tid) {
|
||||
kevman.subscribe(this->listener);
|
||||
}
|
||||
|
||||
// Base class destructor will be called automatically
|
||||
~KeyboardDemo() override {
|
||||
log << INFO << "Uninitialized KeyboardDemo" << endl;
|
||||
if (running) {
|
||||
// NOTE: If the thread was exited nicely it can unlock before destructor,
|
||||
// but on forced kill kout has to be unlocked in the destructor.
|
||||
// This is bad since it could release the lock although some other
|
||||
// thread set it (so use nice_kill)
|
||||
kout.unlock();
|
||||
}
|
||||
kevman.unsubscribe(this->listener);
|
||||
kout.unlock();
|
||||
}
|
||||
|
||||
void run() override;
|
||||
|
||||
@ -11,9 +11,7 @@ private:
|
||||
void (PCSPK::*melody)(void); // Allow to pass a melody to play when initializing the demo
|
||||
|
||||
public:
|
||||
PCSPKdemo(void (PCSPK::*melody)(void)) : melody(melody) {
|
||||
kout << "Initialized PCSPKdemo" << endl;
|
||||
}
|
||||
PCSPKdemo(void (PCSPK::*melody)(void)) : Thread("PCSPKdemo"), melody(melody) {}
|
||||
|
||||
~PCSPKdemo() override {
|
||||
pcspk.off();
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
void PreemptiveLoopThread::run() {
|
||||
int cnt = 0;
|
||||
|
||||
while (true) {
|
||||
while (running) {
|
||||
// Basic synchronization by semaphore
|
||||
kout.lock();
|
||||
|
||||
@ -13,6 +13,8 @@ void PreemptiveLoopThread::run() {
|
||||
|
||||
kout.unlock();
|
||||
}
|
||||
|
||||
scheduler.exit();
|
||||
}
|
||||
|
||||
void PreemptiveThreadDemo::run() {
|
||||
|
||||
@ -12,7 +12,7 @@ private:
|
||||
|
||||
public:
|
||||
// Gibt der Loop einen Stack und eine Id.
|
||||
PreemptiveLoopThread(int i) : id(i) {}
|
||||
PreemptiveLoopThread(int i) : Thread("LoopThread"), id(i) {}
|
||||
|
||||
// Zaehlt einen Zaehler hoch und gibt ihn auf dem Bildschirm aus.
|
||||
void run() override;
|
||||
@ -25,9 +25,7 @@ private:
|
||||
unsigned int number_of_threads;
|
||||
|
||||
public:
|
||||
PreemptiveThreadDemo(unsigned int n) : number_of_threads(n) {
|
||||
kout << "Initialized PreemptiveThreadDemo" << endl;
|
||||
}
|
||||
PreemptiveThreadDemo(unsigned int n) : Thread("PreemptiveThreadDemo"), number_of_threads(n) {}
|
||||
|
||||
// Thread-Startmethode
|
||||
void run() override;
|
||||
|
||||
@ -8,9 +8,7 @@ private:
|
||||
SmartPointerDemo(const SmartPointerDemo& copy) = delete;
|
||||
|
||||
public:
|
||||
SmartPointerDemo() {
|
||||
kout << "Initialized SmartPointerDemo" << endl;
|
||||
}
|
||||
SmartPointerDemo() : Thread("SmartPointerDemo") {}
|
||||
|
||||
void run() override;
|
||||
};
|
||||
|
||||
@ -19,9 +19,7 @@ private:
|
||||
TextDemo(const TextDemo& copy) = delete;
|
||||
|
||||
public:
|
||||
TextDemo() {
|
||||
log << INFO << "Initialized TextDemo" << endl;
|
||||
}
|
||||
TextDemo() : Thread("TextDemo") {}
|
||||
|
||||
void run() override;
|
||||
};
|
||||
|
||||
@ -102,6 +102,8 @@ void VBEdemo::run() {
|
||||
drawBitmap();
|
||||
drawFonts();
|
||||
|
||||
while (running) {}
|
||||
|
||||
// selbst terminieren
|
||||
// scheduler.exit();
|
||||
scheduler.exit();
|
||||
}
|
||||
|
||||
@ -24,9 +24,7 @@ private:
|
||||
|
||||
public:
|
||||
// Gib dem Anwendungsthread einen Stack.
|
||||
VBEdemo() {
|
||||
kout << "Initialized VBEdemo" << endl;
|
||||
}
|
||||
VBEdemo() : Thread("VBEdemo") {}
|
||||
|
||||
~VBEdemo() override {
|
||||
vesa.initTextMode();
|
||||
|
||||
@ -10,9 +10,7 @@ private:
|
||||
VectorDemo(const VectorDemo& copy) = delete;
|
||||
|
||||
public:
|
||||
VectorDemo() {
|
||||
kout << "Initialized VectorDemo" << endl;
|
||||
}
|
||||
VectorDemo() : Thread("VectorDemo") {}
|
||||
|
||||
void run() override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user