X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=schedule.h;h=3feddd9025915e9275efc1bf4aca389a1a17844f;hb=27a6b2d336785fa3d30d937a397242c0a6823cfc;hp=c633b28987d7ef97da5d1130060021260e65b0f6;hpb=d48c1867f8e5b2a3f9695a6bc8f1b5394dcda8e7;p=model-checker.git diff --git a/schedule.h b/schedule.h index c633b28..3feddd9 100644 --- a/schedule.h +++ b/schedule.h @@ -1,20 +1,46 @@ +/** @file schedule.h + * @brief Thread scheduler. + */ + #ifndef __SCHEDULE_H__ #define __SCHEDULE_H__ #include +#include "mymemory.h" + +/* Forward declaration */ +class Thread; -#include "threads.h" -#include "model.h" +typedef enum enabled_type { + THREAD_DISABLED, + THREAD_ENABLED, + THREAD_SLEEP_SET +} enabled_type_t; +/** @brief The Scheduler class performs the mechanics of Thread execution + * scheduling. */ class Scheduler { public: + Scheduler(); void add_thread(Thread *t); void remove_thread(Thread *t); - Thread * next_thread(void); - Thread * get_current_thread(void); - void print(); + void sleep(Thread *t); + void wake(Thread *t); + Thread * next_thread(Thread *t); + Thread * get_current_thread() const; + void print() const; + enabled_type_t * get_enabled() { return enabled; }; + bool is_enabled(Thread *t) const; + + SNAPSHOTALLOC private: - std::list readyList; + /** The list of available Threads that are not currently running */ + enabled_type_t *enabled; + int enabled_len; + int curr_thread_index; + void set_enabled(Thread *t, enabled_type_t enabled_status); + + /** The currently-running Thread */ Thread *current; };