1

update preemption demo

This commit is contained in:
2022-07-11 19:22:23 +02:00
parent 60e36011e3
commit 25da4b8596
4 changed files with 31 additions and 45 deletions

View File

@ -0,0 +1,36 @@
#ifndef __preemptive_thread_include__
#define __preemptive_thread_include__
#include "kernel/Globals.h"
#include "kernel/threads/Thread.h"
#include "lib/Semaphore.h"
class PreemptiveLoopThread : public Thread {
private:
int id;
Semaphore* sem;
PreemptiveLoopThread(const PreemptiveLoopThread& copy) = delete; // Verhindere Kopieren
public:
// Gibt der Loop einen Stack und eine Id.
PreemptiveLoopThread(int i, Semaphore* sem) : id(i), sem(sem) {}
// Zaehlt einen Zaehler hoch und gibt ihn auf dem Bildschirm aus.
void run() override;
};
class PreemptiveThreadDemo : public Thread {
private:
PreemptiveThreadDemo(const PreemptiveThreadDemo& copy) = delete; // Verhindere Kopieren
public:
PreemptiveThreadDemo() {
kout << "Initialized PreemptiveThreadDemo" << endl;
}
// Thread-Startmethode
void run() override;
};
#endif