1

implement loop demo

This commit is contained in:
churl
2022-06-15 21:31:29 +02:00
parent a3aa13d946
commit 1a5c701546
4 changed files with 49 additions and 23 deletions

View File

@ -8,19 +8,40 @@
* Autor: Michael Schoettner, HHU, 21.8.2016 *
*****************************************************************************/
#include "kernel/Globals.h"
#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 () {
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();
}