cyclegraph: add back edges to CycleNode
[model-checker.git] / threads.cc
index 87de32fb2452f0384016353306b0b0b43c3d4cea..6adc053ae2dbfc58a00bbbb2f0e6a7c2e79a7b4c 100644 (file)
@@ -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);
 }