reformat
This commit is contained in:
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#include "kernel/threads/Dispatch.h"
|
#include "kernel/threads/Dispatch.h"
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Methode: Dispatcher::start *
|
* Methode: Dispatcher::start *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
@ -25,14 +24,13 @@
|
|||||||
* Parameter: *
|
* Parameter: *
|
||||||
* first Zu startender Thread. *
|
* first Zu startender Thread. *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
void Dispatcher::start (Thread& first) {
|
void Dispatcher::start(Thread& first) {
|
||||||
if (!active) {
|
if (!active) {
|
||||||
active = &first;
|
active = &first;
|
||||||
active->start ();
|
active->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Methode: Dispatcher::dispatch *
|
* Methode: Dispatcher::dispatch *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
@ -41,8 +39,8 @@ void Dispatcher::start (Thread& first) {
|
|||||||
* Parameter: *
|
* Parameter: *
|
||||||
* next Thread der die CPU erhalten soll. *
|
* next Thread der die CPU erhalten soll. *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
void Dispatcher::dispatch (Thread& next) {
|
void Dispatcher::dispatch(Thread& next) {
|
||||||
Thread* current = active;
|
Thread* current = active;
|
||||||
active = &next;
|
active = &next;
|
||||||
current->switchTo (next);
|
current->switchTo(next);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,17 +19,16 @@
|
|||||||
#include "kernel/threads/Thread.h"
|
#include "kernel/threads/Thread.h"
|
||||||
|
|
||||||
class Dispatcher {
|
class Dispatcher {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Thread* active; // aktiver Thread
|
Thread* active; // aktiver Thread
|
||||||
|
|
||||||
Dispatcher(const Dispatcher ©); // Verhindere Kopieren
|
Dispatcher(const Dispatcher& copy) = delete; // Verhindere Kopieren
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Dispatcher () : active (0) {}
|
Dispatcher() : active(0) {}
|
||||||
void start (Thread& first);
|
void start(Thread& first);
|
||||||
void dispatch (Thread& next);
|
void dispatch(Thread& next);
|
||||||
Thread* get_active () { return active; }
|
Thread* get_active() { return active; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -17,30 +17,28 @@
|
|||||||
#include "lib/Queue.h"
|
#include "lib/Queue.h"
|
||||||
|
|
||||||
class Scheduler : public Dispatcher {
|
class Scheduler : public Dispatcher {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Scheduler (const Scheduler ©); // Verhindere Kopieren
|
Scheduler(const Scheduler& copy) = delete; // Verhindere Kopieren
|
||||||
|
|
||||||
private:
|
Queue readyQueue; // auf die CPU wartende Threads
|
||||||
Queue readyQueue; // auf die CPU wartende Threads
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Scheduler () {}
|
Scheduler() {}
|
||||||
|
|
||||||
// Scheduler starten
|
// Scheduler starten
|
||||||
void schedule ();
|
void schedule();
|
||||||
|
|
||||||
// Thread in readyQueue eintragen
|
// Thread in readyQueue eintragen
|
||||||
void ready (Thread * that);
|
void ready(Thread* that);
|
||||||
|
|
||||||
// Thread terminiert sich selbst
|
// Thread terminiert sich selbst
|
||||||
void exit ();
|
void exit();
|
||||||
|
|
||||||
// Thread mit 'Gewalt' terminieren
|
// Thread mit 'Gewalt' terminieren
|
||||||
void kill (Thread * that);
|
void kill(Thread* that);
|
||||||
|
|
||||||
// CPU freiwillig abgeben und Auswahl des naechsten Threads
|
// CPU freiwillig abgeben und Auswahl des naechsten Threads
|
||||||
void yield ();
|
void yield();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user