Merge branch 'master' of /home/git/random-fuzzer into thread-switch
[c11tester.git] / threads.cc
index a576697f561087fe2c09c607e44ef02bb0c6fa8c..23041b28b55db34d617b86b25e8f3c527810b918 100644 (file)
@@ -243,7 +243,7 @@ void setup_context() {
        Thread * curr_thread = thread_current();
 
        /* Add dummy "start" action, just to create a first clock vector */
-       model->switch_to_master(new ModelAction(THREAD_START, std::memory_order_seq_cst, curr_thread));
+       model->switch_thread(new ModelAction(THREAD_START, std::memory_order_seq_cst, curr_thread));
 
        real_init_all();
 
@@ -331,6 +331,16 @@ int Thread::swap(ucontext_t *ctxt, Thread *t)
        return model_swapcontext(ctxt, &t->context);
 }
 
+int Thread::swap(Thread *t, Thread *t2)
+{
+       t->set_state(THREAD_READY);
+       t2->set_state(THREAD_RUNNING);
+#ifdef TLS
+       if (t2->tls != NULL)
+               set_tls_addr((uintptr_t)t2->tls);
+#endif
+       return model_swapcontext(&t->context, &t2->context);
+}
 
 /** Terminate a thread and free its stack. */
 void Thread::complete()