model/schedule: comput "reduadant" measurement, print along with traces
[model-checker.git] / schedule.cc
index 44def6d67583e1282605de06fbb72dfe4fc3ab6b..a2eb4cf7254834fecac49905838d53b647b95de5 100644 (file)
@@ -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());