OOStuBS - Technische Informatik II (TI-II)  2.4
scheduler.h
gehe zur Dokumentation dieser Datei
1 /*---------------------------------------------------------------------------*
2  * Operating Systems I *
3  *---------------------------------------------------------------------------*
4  * *
5  * S C H E D U L E R *
6  * *
7  *---------------------------------------------------------------------------*/
8 
9 #ifndef __schedule_include__
10 #define __schedule_include__
11 
12 #include "thread/dispatch.h"
13 #include "common/queue.h"
14 #include "device/watch.h"
15 
16 class Thread;
17 
28 class Scheduler : protected Dispatcher {
29 private:
32 
34  bool started;
35 
37  class Idle : public Thread{
39  virtual void action();
40  } idle;
41 
42 
43 public:
45  Scheduler();
46 
48  ~Scheduler();
49 
52  void start();
53 
60  void insert(Thread& that);
61 
67  void exit();
68 
70  void yield();
71 
73  Thread* active() const;
74 
75 protected:
80  void next();
81 
83  void reactivate(Thread& unblocked);
84 
89  bool kill(Thread& that);
90 
91 private:
96  void preempt();
97 
98  friend void Watch::trigger();
99 };
100 
101 #endif