1

add vorgabe05

This commit is contained in:
churl
2022-05-20 16:16:24 +02:00
parent 2b41893743
commit bdfe784340
11 changed files with 461 additions and 3 deletions

54
c_os/kernel/corouts/Coroutine.h Executable file
View File

@ -0,0 +1,54 @@
/*****************************************************************************
* *
* C O R O U T I N E *
* *
*---------------------------------------------------------------------------*
* Beschreibung: Implementierung eines Koroutinen-Konzepts. *
* Die Koroutinen sind miteinander verkettet, weswegen die *
* Klasse Coroutine ein Subtyp von 'Chain' ist. *
* *
* Im Konstruktor wird der initialie Kontext der Koroutine *
* eingerichtet. Mit 'start' wird ein Koroutine aktiviert. *
* Das Umschalten auf die naechste Koroutine erfolgt durch *
* Aufruf von 'switchToNext'. *
* *
* Um bei einem Koroutinenwechsel den Kontext sichern zu *
* koennen, enthaelt jedes Koroutinenobjekt eine Struktur *
* CoroutineState, in dem die Werte der nicht-fluechtigen *
* Register gesichert werden koennen. *
* *
* Autor: Michael, Schoettner, HHU, 13.08.2020 *
*****************************************************************************/
#ifndef __Coroutine_include__
#define __Coroutine_include__
#include "kernel/corouts/CoroutineState.h"
#include "lib/Chain.h"
class Coroutine : public Chain {
private:
Coroutine(const Coroutine &copy); // Verhindere Kopieren
private:
struct CoroutineState regs;
public:
Coroutine (unsigned int* stack);
// Coroutine aktivieren
void start ();
// Auf die naechste Coroutine umschalten
void switchToNext ();
// Methode der Coroutine, muss in Sub-Klasse implementiert werden
virtual void run () = 0;
// Verweis auf nächste Coroutine setzen
void setNext (Chain* next);
};
#endif