1

implement demo

This commit is contained in:
2022-05-23 09:12:08 +02:00
parent 4f94ccdc99
commit 0537f6dd45
2 changed files with 23 additions and 12 deletions

View File

@ -8,15 +8,10 @@
* Autor: Michael Schoettner, HHU, 15.8.2016 * * Autor: Michael Schoettner, HHU, 15.8.2016 *
*****************************************************************************/ *****************************************************************************/
#include "kernel/Globals.h"
#include "user/CoroutineDemo.h" #include "user/CoroutineDemo.h"
#include "kernel/Globals.h"
#include "user/CoroutineLoop.h" #include "user/CoroutineLoop.h"
// Stacks (koennen alternative auch per 'new' alloziert werden)
static unsigned int stack[3][1024];
/***************************************************************************** /*****************************************************************************
* Methode: CoroutineDemo::main * * Methode: CoroutineDemo::main *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
@ -30,5 +25,15 @@ void CoroutineDemo::main () {
* Die 3 Koroutinen einrichten, verketten und die 1. starten * 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();
} }

View File

@ -14,7 +14,6 @@
#include "user/CoroutineLoop.h" #include "user/CoroutineLoop.h"
#include "kernel/Globals.h" #include "kernel/Globals.h"
/***************************************************************************** /*****************************************************************************
* Methode: CoroutineLoop::run * * Methode: CoroutineLoop::run *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
@ -24,4 +23,11 @@ void CoroutineLoop::run () {
/* Hier muss Code eingefuegt werden */ /* Hier muss Code eingefuegt werden */
int i = 0;
while (true) {
kout.setpos(0, 20 + this->id);
kout << "Corout[" << this->id << "]: " << i++ << endl;
this->switchToNext();
}
} }