Add memmove and bzero
[c11tester.git] / execution.cc
index 4953718d360499b85dfa8eed8bc6d8415bc1e33a..d2efaba7a95dd522c96ba712eb4c761e7e36de60 100644 (file)
@@ -18,8 +18,6 @@
 #include "fuzzer.h"
 #include "newfuzzer.h"
 
-#define INITIAL_THREAD_ID       0
-
 #ifdef COLLECT_STAT
 static unsigned int atomic_load_count = 0;
 static unsigned int atomic_store_count = 0;
@@ -101,7 +99,7 @@ ModelExecution::ModelExecution(ModelChecker *m, Scheduler *scheduler) :
 /** @brief Destructor */
 ModelExecution::~ModelExecution()
 {
-       for (unsigned int i = 0;i < get_num_threads();i++)
+       for (unsigned int i = INITIAL_THREAD_ID;i < get_num_threads();i++)
                delete get_thread(int_to_id(i));
 
        delete mo_graph;
@@ -270,7 +268,7 @@ bool ModelExecution::should_wake_up(const ModelAction * asleep) const
 
 void ModelExecution::wake_up_sleeping_actions()
 {
-       for (unsigned int i = 0;i < get_num_threads();i++) {
+       for (unsigned int i = MAIN_THREAD_ID;i < get_num_threads();i++) {
                thread_id_t tid = int_to_id(i);
                if (scheduler->is_sleep_set(tid)) {
                        Thread *thr = get_thread(tid);
@@ -349,7 +347,7 @@ void ModelExecution::set_assert()
 bool ModelExecution::is_deadlocked() const
 {
        bool blocking_threads = false;
-       for (unsigned int i = 0;i < get_num_threads();i++) {
+       for (unsigned int i = MAIN_THREAD_ID;i < get_num_threads();i++) {
                thread_id_t tid = int_to_id(i);
                if (is_enabled(tid))
                        return false;
@@ -369,7 +367,7 @@ bool ModelExecution::is_deadlocked() const
  */
 bool ModelExecution::is_complete_execution() const
 {
-       for (unsigned int i = 0;i < get_num_threads();i++)
+       for (unsigned int i = MAIN_THREAD_ID;i < get_num_threads();i++)
                if (is_enabled(int_to_id(i)))
                        return false;
        return true;
@@ -498,7 +496,7 @@ bool ModelExecution::process_mutex(ModelAction *curr)
        case ATOMIC_WAIT: {
                Thread *curr_thrd = get_thread(curr);
                /* wake up the other threads */
-               for (unsigned int i = 0;i < get_num_threads();i++) {
+               for (unsigned int i = MAIN_THREAD_ID;i < get_num_threads();i++) {
                        Thread *t = get_thread(int_to_id(i));
                        if (t->waiting_on() == curr_thrd && t->get_pending()->is_lock())
                                scheduler->wake(t);
@@ -527,7 +525,7 @@ bool ModelExecution::process_mutex(ModelAction *curr)
                }
 
                /* wake up the other threads */
-               for (unsigned int i = 0;i < get_num_threads();i++) {
+               for (unsigned int i = MAIN_THREAD_ID;i < get_num_threads();i++) {
                        Thread *t = get_thread(int_to_id(i));
                        if (t->waiting_on() == curr_thrd && t->get_pending()->is_lock())
                                scheduler->wake(t);
@@ -547,7 +545,7 @@ bool ModelExecution::process_mutex(ModelAction *curr)
                // TODO: lock count for recursive mutexes
                /* wake up the other threads */
                Thread *curr_thrd = get_thread(curr);
-               for (unsigned int i = 0;i < get_num_threads();i++) {
+               for (unsigned int i = MAIN_THREAD_ID;i < get_num_threads();i++) {
                        Thread *t = get_thread(int_to_id(i));
                        if (t->waiting_on() == curr_thrd && t->get_pending()->is_lock())
                                scheduler->wake(t);
@@ -679,7 +677,7 @@ void ModelExecution::process_thread_action(ModelAction *curr)
                }
 
                /* Wake up any joining threads */
-               for (unsigned int i = 0;i < get_num_threads();i++) {
+               for (unsigned int i = MAIN_THREAD_ID;i < get_num_threads();i++) {
                        Thread *waiting = get_thread(int_to_id(i));
                        if (waiting->waiting_on() == th &&
                                        waiting->get_pending()->is_thread_join())