X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=threads.cc;h=1de548ccdb93ccd41a2a0248a49be2937dd87f01;hb=30999f20b8426081e676adfc76d1c4af7b941e8e;hp=6adc053ae2dbfc58a00bbbb2f0e6a7c2e79a7b4c;hpb=96bc0872c55ea4a0c1c52f7d5145f3f953226f78;p=model-checker.git diff --git a/threads.cc b/threads.cc index 6adc053..1de548c 100644 --- a/threads.cc +++ b/threads.cc @@ -7,6 +7,7 @@ #include #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); }