X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;ds=sidebyside;f=threads.cc;h=0da9282aa942bd2966bf939d6409636fa99049e5;hb=8caa7a3bd239c0141876f4f5a47d3910f1747e3c;hp=8d078b51bbfa1a8c0b4bc03b3176afa85f3a4d97;hpb=6898da1b7c46ddf3427ea0127dc68f8cc6016511;p=c11tester.git diff --git a/threads.cc b/threads.cc index 8d078b51..0da9282a 100644 --- a/threads.cc +++ b/threads.cc @@ -13,6 +13,7 @@ /* global "model" object */ #include "model.h" #include "execution.h" +#include "schedule.h" #ifdef TLS #include @@ -319,10 +320,15 @@ void Thread::complete() if (stack) stack_free(stack); #ifdef TLS - if (this != model->getInitThread()) { + if (this != model->getInitThread() && !model->getParams()->threadsnocleanup) { modellock = 1; + ASSERT(thread_current()==NULL); + Thread * curr_thread = model->getScheduler()->get_current_thread(); + //Make any current_thread calls work in code to free + model->getScheduler()->set_current_thread(this); real_pthread_mutex_unlock(&mutex2); real_pthread_join(thread, NULL); + model->getScheduler()->set_current_thread(curr_thread); modellock = 0; } #endif