comments
[c11tester.git] / schedule.h
1 /** @file schedule.h
2  *      @brief Thread scheduler.
3  */
4
5 #ifndef __SCHEDULE_H__
6 #define __SCHEDULE_H__
7
8 #include <list>
9 #include "mymemory.h"
10
11 /* Forward declaration */
12 class Thread;
13
14 /** @brief The Scheduler class performs the mechanics of Thread execution
15  * scheduling. */
16 class Scheduler {
17 public:
18         Scheduler();
19         void add_thread(Thread *t);
20         void remove_thread(Thread *t);
21         void sleep(Thread *t);
22         void wake(Thread *t);
23         Thread * next_thread(Thread *t);
24         Thread * get_current_thread() const;
25         void print() const;
26         bool * get_enabled() { return is_enabled; };
27
28         SNAPSHOTALLOC
29 private:
30         /** The list of available Threads that are not currently running */
31         bool * is_enabled;
32         int enabled_len;
33         int curr_thread_index;
34         void set_enabled(Thread *t, bool enabled_status);
35
36         /** The currently-running Thread */
37         Thread *current;
38 };
39
40 #endif /* __SCHEDULE_H__ */