X-Git-Url: http://plrg.eecs.uci.edu/git/?p=model-checker.git;a=blobdiff_plain;f=schedule.cc;h=a2eb4cf7254834fecac49905838d53b647b95de5;hp=44def6d67583e1282605de06fbb72dfe4fc3ab6b;hb=2daff868a7ef4f6235c2776b746cec9947a87b13;hpb=0330918c2798a36363a197bf500a5646b048a687;ds=sidebyside diff --git a/schedule.cc b/schedule.cc index 44def6d..a2eb4cf 100644 --- a/schedule.cc +++ b/schedule.cc @@ -96,6 +96,23 @@ bool Scheduler::is_sleep_set(const Thread *t) const return get_enabled(t) == THREAD_SLEEP_SET; } +/** + * @brief Check if execution is stuck with no enabled threads and some sleeping + * thread + * @return True if no threads are enabled an some thread is in the sleep set; + * false otherwise + */ +bool Scheduler::all_threads_sleeping() const +{ + bool sleeping = false; + for (int i = 0; i < enabled_len; i++) + if (enabled[i] == THREAD_ENABLED) + return false; + else if (enabled[i] == THREAD_SLEEP_SET) + sleeping = true; + return sleeping; +} + enabled_type_t Scheduler::get_enabled(const Thread *t) const { int id = id_to_int(t->get_id());