-void Scheduler::update_sleep_set(Node *n) {
- enabled_type_t *enabled_array=n->get_enabled_array();
- for(int i=0;i<enabled_len;i++) {
- if (enabled_array[i]==THREAD_SLEEP_SET) {
- enabled[i]=THREAD_SLEEP_SET;
- }
- }
+/**
+ * @brief Check if a Thread is currently in the sleep set
+ * @param t The Thread to check
+ */
+bool Scheduler::is_sleep_set(const Thread *t) const
+{
+ return is_sleep_set(t->get_id());
+}
+
+bool Scheduler::is_sleep_set(thread_id_t tid) const
+{
+ int id = id_to_int(tid);
+ ASSERT(id < enabled_len);
+ return enabled[id] == THREAD_SLEEP_SET;
+}
+
+/**
+ * @brief Check if execution is stuck with no enabled threads and some sleeping
+ * thread
+ * @return True if no threads are enabled and 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());
+ ASSERT(id < enabled_len);
+ return enabled[id];