implement + enable demos
This commit is contained in:
6
c_os/user/PCSPKdemo.cc
Normal file
6
c_os/user/PCSPKdemo.cc
Normal file
@ -0,0 +1,6 @@
|
||||
#include "user/PCSPKdemo.h"
|
||||
|
||||
void PCSPKdemo::run() {
|
||||
pcspk.tetris();
|
||||
scheduler.exit();
|
||||
}
|
||||
19
c_os/user/PCSPKdemo.h
Normal file
19
c_os/user/PCSPKdemo.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef __PCSPKdemo_INCLUDE_H_
|
||||
#define __PCSPKdemo_INCLUDE_H_
|
||||
|
||||
#include "kernel/Globals.h"
|
||||
#include "kernel/threads/Thread.h"
|
||||
|
||||
class PCSPKdemo : public Thread {
|
||||
private:
|
||||
PCSPKdemo(const PCSPKdemo& copy) = delete;
|
||||
|
||||
public:
|
||||
PCSPKdemo() {
|
||||
kout << "Initialized PCSPKdemo" << endl;
|
||||
}
|
||||
|
||||
void run() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
17
c_os/user/PreemptiveLoopThread.cc
Normal file
17
c_os/user/PreemptiveLoopThread.cc
Normal file
@ -0,0 +1,17 @@
|
||||
#include "user/PreemptiveLoopThread.h"
|
||||
|
||||
void PreemptiveLoopThread::run() {
|
||||
|
||||
/* Hier muss Code eingefuegt werden */
|
||||
|
||||
int cnt = 0;
|
||||
while (true) {
|
||||
// Basic synchronization by disabling PIT interrupts
|
||||
cpu.disable_int();
|
||||
|
||||
kout.setpos(55, this->id);
|
||||
kout << this->id << ": " << dec << cnt++ << endl;
|
||||
|
||||
cpu.enable_int();
|
||||
}
|
||||
}
|
||||
22
c_os/user/PreemptiveLoopThread.h
Normal file
22
c_os/user/PreemptiveLoopThread.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef __pre_loopthread_include__
|
||||
#define __pre_loopthread_include__
|
||||
|
||||
#include "kernel/threads/Thread.h"
|
||||
#include "kernel/Globals.h"
|
||||
|
||||
class PreemptiveLoopThread : public Thread {
|
||||
|
||||
private:
|
||||
int id;
|
||||
|
||||
PreemptiveLoopThread(const PreemptiveLoopThread& copy) = delete; // Verhindere Kopieren
|
||||
|
||||
public:
|
||||
// Gibt der Loop einen Stack und eine Id.
|
||||
PreemptiveLoopThread(int i) : id(i) {}
|
||||
|
||||
// Zaehlt einen Zaehler hoch und gibt ihn auf dem Bildschirm aus.
|
||||
void run() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
18
c_os/user/PreemptiveThreadDemo.cc
Normal file
18
c_os/user/PreemptiveThreadDemo.cc
Normal file
@ -0,0 +1,18 @@
|
||||
#include "user/PreemptiveThreadDemo.h"
|
||||
|
||||
void PreemptiveThreadDemo::run() {
|
||||
kout << "Allocating LoopThread A" << endl;
|
||||
Thread* cntA = new PreemptiveLoopThread(0);
|
||||
kout << "Allocating LoopThread B" << endl;
|
||||
Thread* cntB = new PreemptiveLoopThread(1);
|
||||
kout << "Allocating LoopThread C" << endl;
|
||||
Thread* cntC = new PreemptiveLoopThread(2);
|
||||
|
||||
kout << "Adding threads to ready queue" << endl;
|
||||
scheduler.ready(cntA);
|
||||
scheduler.ready(cntB);
|
||||
scheduler.ready(cntC);
|
||||
|
||||
kout << "Exiting main thread" << endl;
|
||||
scheduler.exit();
|
||||
}
|
||||
21
c_os/user/PreemptiveThreadDemo.h
Normal file
21
c_os/user/PreemptiveThreadDemo.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef __preemptive_thread_include__
|
||||
#define __preemptive_thread_include__
|
||||
|
||||
#include "kernel/Globals.h"
|
||||
#include "kernel/threads/Thread.h"
|
||||
#include "user/PreemptiveLoopThread.h"
|
||||
|
||||
class PreemptiveThreadDemo : public Thread {
|
||||
private:
|
||||
PreemptiveThreadDemo(const PreemptiveThreadDemo& copy) = delete; // Verhindere Kopieren
|
||||
|
||||
public:
|
||||
PreemptiveThreadDemo() {
|
||||
kout << "Initialized PreemptiveThreadDemo" << endl;
|
||||
}
|
||||
|
||||
// Thread-Startmethode
|
||||
void run() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user