model: only backtrack fences when acquire is before release
[model-checker.git] / threads.cc
index 6adc053ae2dbfc58a00bbbb2f0e6a7c2e79a7b4c..1de548ccdb93ccd41a2a0248a49be2937dd87f01 100644 (file)
@@ -7,6 +7,7 @@
 #include <threads.h>
 #include "common.h"
 #include "threads-model.h"
+#include "action.h"
 
 /* global "model" object */
 #include "model.h"
@@ -23,7 +24,13 @@ static void stack_free(void *stack)
        snapshot_free(stack);
 }
 
-/** Return the currently executing thread. */
+/**
+ * @brief Get the current Thread
+ *
+ * Must be called from a user context
+ *
+ * @return The currently executing thread
+ */
 Thread * thread_current(void)
 {
        ASSERT(model);
@@ -84,6 +91,7 @@ int Thread::create_context()
  */
 int Thread::swap(Thread *t, ucontext_t *ctxt)
 {
+       t->set_state(THREAD_READY);
        return swapcontext(&t->context, ctxt);
 }
 
@@ -97,6 +105,7 @@ int Thread::swap(Thread *t, ucontext_t *ctxt)
  */
 int Thread::swap(ucontext_t *ctxt, Thread *t)
 {
+       t->set_state(THREAD_RUNNING);
        return swapcontext(ctxt, &t->context);
 }