X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=schedule.cc;h=a2eb4cf7254834fecac49905838d53b647b95de5;hb=e0f80c403452e544452f64687b3c489a869e4f77;hp=44def6d67583e1282605de06fbb72dfe4fc3ab6b;hpb=2e5131c376bfa003e1254a92a298dae2d2abc027;p=c11tester.git diff --git a/schedule.cc b/schedule.cc index 44def6d6..a2eb4cf7 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());