1

add vorgabe06

This commit is contained in:
2022-06-02 13:01:43 +02:00
parent 7b7b375c8c
commit 32b1f2391f
15 changed files with 525 additions and 0 deletions

26
c_os/user/CoopThreadDemo.cc Executable file
View File

@ -0,0 +1,26 @@
/*****************************************************************************
* *
* 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 "kernel/Globals.h"
#include "user/CoopThreadDemo.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 */
}

31
c_os/user/CoopThreadDemo.h Executable file
View File

@ -0,0 +1,31 @@
/*****************************************************************************
* *
* 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/threads/Thread.h"
class CoopThreadDemo : public Thread {
private:
CoopThreadDemo (const CoopThreadDemo &copy); // Verhindere Kopieren
public:
// Gib dem Anwendungsthread einen Stack.
CoopThreadDemo () : Thread () { }
// Thread-Startmethode
void run ();
};
#endif

27
c_os/user/HelloWorldThread.cc Executable file
View File

@ -0,0 +1,27 @@
/*****************************************************************************
* *
* H E L L O W O R L D T H R E A D *
* *
*---------------------------------------------------------------------------*
* Beschreibung: Ein einfacher Thread. *
* *
* Autor: Michael Schoettner, HHU, 21.8.2016 *
*****************************************************************************/
#include "kernel/Globals.h"
#include "user/HelloWorldThread.h"
/*****************************************************************************
* Methode: HelloWorldThread::run *
*---------------------------------------------------------------------------*
* Beschreibung: Einstiegsfunktion in unseren Thread. *
*****************************************************************************/
void HelloWorldThread::run () {
kout << "Hallo Welt von einem Thread!" << endl;
// selbst terminieren
scheduler.exit ();
}

30
c_os/user/HelloWorldThread.h Executable file
View File

@ -0,0 +1,30 @@
/*****************************************************************************
* *
* H E L L O W O R L D T H R E A D *
* *
*---------------------------------------------------------------------------*
* Beschreibung: Ein einfacher Thread. *
* *
* Autor: Michael Schoettner, HHU, 16.12.2016 *
*****************************************************************************/
#ifndef __hello_world_thread_include__
#define __hello_world_thread_include__
#include "kernel/threads/Thread.h"
class HelloWorldThread : public Thread {
private:
HelloWorldThread (const HelloWorldThread &copy); // Verhindere Kopieren
public:
HelloWorldThread () : Thread () { }
// Thread-Startmethode
void run ();
};
#endif

22
c_os/user/LoopThread.cc Executable file
View File

@ -0,0 +1,22 @@
/*****************************************************************************
* *
* 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 */
}

29
c_os/user/LoopThread.h Executable file
View File

@ -0,0 +1,29 @@
/*****************************************************************************
* *
* 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); // Verhindere Kopieren
public:
// Gibt der Loop einen Stack und eine Id.
LoopThread (int i) : Thread () { id = i; }
// Zaehlt einen Zaehler hoch und gibt ihn auf dem Bildschirm aus.
void run ();
};
#endif