X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=threads.cc;h=6adc053ae2dbfc58a00bbbb2f0e6a7c2e79a7b4c;hb=5236e7a4403ccc6d28b3fdc746c5710d6190310a;hp=87de32fb2452f0384016353306b0b0b43c3d4cea;hpb=a330eb33b1b62dfa71f3f0cb055367a30090c180;p=model-checker.git diff --git a/threads.cc b/threads.cc index 87de32f..6adc053 100644 --- a/threads.cc +++ b/threads.cc @@ -104,12 +104,11 @@ int Thread::swap(ucontext_t *ctxt, Thread *t) /** Terminate a thread and free its stack. */ void Thread::complete() { - if (!is_complete()) { - DEBUG("completed thread %d\n", id_to_int(get_id())); - state = THREAD_COMPLETED; - if (stack) - stack_free(stack); - } + ASSERT(!is_complete()); + DEBUG("completed thread %d\n", id_to_int(get_id())); + state = THREAD_COMPLETED; + if (stack) + stack_free(stack); } /** @@ -162,14 +161,15 @@ Thread::Thread(thrd_t *t, void (*func)(void *), void *a) : model_print("Error in create_context\n"); id = model->get_next_id(); - *user_thread = id; + user_thread->priv = this; parent = thread_current(); } /** Destructor */ Thread::~Thread() { - complete(); + if (!is_complete()) + complete(); model->remove_thread(this); }