implement demo
This commit is contained in:
@ -8,15 +8,10 @@
|
||||
* Autor: Michael Schoettner, HHU, 15.8.2016 *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "kernel/Globals.h"
|
||||
#include "user/CoroutineDemo.h"
|
||||
#include "kernel/Globals.h"
|
||||
#include "user/CoroutineLoop.h"
|
||||
|
||||
|
||||
// Stacks (koennen alternative auch per 'new' alloziert werden)
|
||||
static unsigned int stack[3][1024];
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CoroutineDemo::main *
|
||||
*---------------------------------------------------------------------------*
|
||||
@ -30,5 +25,15 @@ void CoroutineDemo::main () {
|
||||
* Die 3 Koroutinen einrichten, verketten und die 1. starten
|
||||
*
|
||||
*/
|
||||
unsigned int(*stack)[1024] = new unsigned int[3][1024];
|
||||
|
||||
CoroutineLoop corout1(stack[0] + 1024, 0);
|
||||
CoroutineLoop corout2(stack[1] + 1024, 1);
|
||||
CoroutineLoop corout3(stack[2] + 1024, 2);
|
||||
|
||||
corout1.setNext(&corout2);
|
||||
corout2.setNext(&corout3);
|
||||
corout3.setNext(&corout1);
|
||||
|
||||
corout1.start();
|
||||
}
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
#include "user/CoroutineLoop.h"
|
||||
#include "kernel/Globals.h"
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CoroutineLoop::run *
|
||||
*---------------------------------------------------------------------------*
|
||||
@ -24,4 +23,11 @@ void CoroutineLoop::run () {
|
||||
|
||||
/* Hier muss Code eingefuegt werden */
|
||||
|
||||
int i = 0;
|
||||
while (true) {
|
||||
kout.setpos(0, 20 + this->id);
|
||||
kout << "Corout[" << this->id << "]: " << i++ << endl;
|
||||
|
||||
this->switchToNext();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user