X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=schedule.h;h=3feddd9025915e9275efc1bf4aca389a1a17844f;hb=2de6c82d6d7e6af2267636ec55f7e81d2a799a78;hp=cba4b11a6d597011910ceec3a55324d5edf136f4;hpb=f3ef22bef8d339c7d45b7d7232cdcf183a0b7776;p=model-checker.git diff --git a/schedule.h b/schedule.h index cba4b11..3feddd9 100644 --- a/schedule.h +++ b/schedule.h @@ -11,6 +11,12 @@ /* Forward declaration */ class Thread; +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 { @@ -18,13 +24,23 @@ 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; };