/**
* @brief Check if a Thread is currently in the sleep set
* @param t The Thread to check
- * @return True if the Thread is currently enabled
*/
bool Scheduler::is_sleep_set(const Thread *t) const
{
- return get_enabled(t) == THREAD_SLEEP_SET;
+ 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;
}
/**
/**
* Add a Thread to the sleep set.
* @param t The Thread to add
+ * A Thread is in THREAD_SLEEP_SET if it is sleeping or blocked by a wait
+ * operation that should fail spuriously (decide by fuzzer).
*/
void Scheduler::add_sleep(Thread *t)
{
int thread_list[enabled_len], sleep_list[enabled_len];
Thread * thread;
- for (int i = 0; i < enabled_len; i++) {
+ for (int i = 0;i < enabled_len;i++) {
if (enabled[i] == THREAD_ENABLED)
thread_list[avail_threads++] = i;
else if (enabled[i] == THREAD_SLEEP_SET)
thread = execution->getFuzzer()->selectThread(thread_list, avail_threads);
}
- curr_thread_index = id_to_int(thread->get_id());
+ //curr_thread_index = id_to_int(thread->get_id());
return thread;
}