remove old cooperative thread demo
This commit is contained in:
@ -1,47 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* C O O P E R A T I V E T H R E A D D E M O *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Beispiel für kooperative Threads. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, HHU, 21.8.2016 *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "user/CoopThreadDemo.h"
|
||||
#include "kernel/Globals.h"
|
||||
#include "user/LoopThread.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CoopThreadDemo::run *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Der Anwendungsthread erzeugt drei Threads die Zaehler *
|
||||
* ausgeben und terminiert sich selbst. *
|
||||
*****************************************************************************/
|
||||
void CoopThreadDemo::run() {
|
||||
|
||||
/* Hier muss Code eingefuegt werden */
|
||||
|
||||
kout << "Allocating LoopThread A" << endl;
|
||||
Thread* cntA = new LoopThread(0);
|
||||
kout << "Allocating LoopThread B" << endl;
|
||||
Thread* cntB = new LoopThread(1);
|
||||
kout << "Allocating LoopThread C" << endl;
|
||||
Thread* cntC = new LoopThread(2);
|
||||
|
||||
kout << "Adding threads to ready queue" << endl;
|
||||
scheduler.ready(cntA);
|
||||
scheduler.ready(cntB);
|
||||
scheduler.ready(cntC);
|
||||
|
||||
int cnt = 0;
|
||||
while (cnt++ < 1000) {
|
||||
scheduler.yield();
|
||||
}
|
||||
|
||||
kout << "Killing LoopThread A" << endl;
|
||||
scheduler.kill(cntA);
|
||||
|
||||
kout << "Exiting main thread" << endl;
|
||||
scheduler.exit();
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* C O O P E R A T I V E T H R E A D D E M O *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Beispiel für kooperative Threads. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, HHU, 21.8.2016 *
|
||||
*****************************************************************************/
|
||||
#ifndef __coopthreaddemo_include__
|
||||
#define __coopthreaddemo_include__
|
||||
|
||||
#include "kernel/Globals.h"
|
||||
#include "kernel/threads/Thread.h"
|
||||
|
||||
class CoopThreadDemo : public Thread {
|
||||
|
||||
private:
|
||||
CoopThreadDemo(const CoopThreadDemo& copy) = delete; // Verhindere Kopieren
|
||||
|
||||
public:
|
||||
// Gib dem Anwendungsthread einen Stack.
|
||||
CoopThreadDemo() {
|
||||
kout << "Initialized CoopThreadDemo" << endl;
|
||||
}
|
||||
|
||||
// Thread-Startmethode
|
||||
void run() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,27 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* L O O P T H R E A D *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Demo eines Threads. Schleife die Zahlen ausgibt. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "user/LoopThread.h"
|
||||
#include "kernel/Globals.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: LoopThread::run *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Code des Threads. *
|
||||
*****************************************************************************/
|
||||
void LoopThread::run() {
|
||||
|
||||
/* Hier muss Code eingefuegt werden */
|
||||
|
||||
int cnt = 0;
|
||||
while (true) {
|
||||
kout.setpos(55, this->id);
|
||||
kout << this->id << ": " << dec << cnt++ << endl;
|
||||
scheduler.yield();
|
||||
}
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* L O O P T H R E A D *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Demo eines Threads. Schleife die Zahlen ausgibt. *
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __loopthread_include__
|
||||
#define __loopthread_include__
|
||||
|
||||
#include "kernel/threads/Thread.h"
|
||||
|
||||
class LoopThread : public Thread {
|
||||
|
||||
private:
|
||||
int id;
|
||||
|
||||
LoopThread(const LoopThread& copy) = delete; // Verhindere Kopieren
|
||||
|
||||
public:
|
||||
// Gibt der Loop einen Stack und eine Id.
|
||||
LoopThread(int i) : id(i) {}
|
||||
|
||||
// Zaehlt einen Zaehler hoch und gibt ihn auf dem Bildschirm aus.
|
||||
void run() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user