X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=threads.cc;h=ca4b28b1bc850c9ea5bcab709e2d27a9e74e2581;hb=80ab61e4168b993a319788c70fd41e63a34ba627;hp=b3a1d5599fb541d340184e0e2ba0f7589c0ec5ae;hpb=f472540b6ab3b65c91221f6f0790d8327333a5c2;p=c11tester.git diff --git a/threads.cc b/threads.cc index b3a1d559..ca4b28b1 100644 --- a/threads.cc +++ b/threads.cc @@ -12,13 +12,13 @@ /** Allocate a stack for a new thread. */ static void * stack_allocate(size_t size) { - return malloc(size); + return snapshot_malloc(size); } /** Free a stack for a terminated thread. */ static void stack_free(void *stack) { - free(stack); + snapshot_free(stack); } /** Return the currently executing thread. */ @@ -104,8 +104,8 @@ int Thread::swap(ucontext_t *ctxt, Thread *t) /** Terminate a thread and free its stack. */ void Thread::complete() { - if (state != THREAD_COMPLETED) { - DEBUG("completed thread %d\n", get_id()); + if (!is_complete()) { + DEBUG("completed thread %d\n", id_to_int(get_id())); state = THREAD_COMPLETED; if (stack) stack_free(stack); @@ -119,10 +119,13 @@ void Thread::complete() * @param a The parameter to pass to this function. */ Thread::Thread(thrd_t *t, void (*func)(void *), void *a) : + creation(NULL), + pending(NULL), start_routine(func), arg(a), user_thread(t), state(THREAD_CREATED), + wait_list(), last_action_val(VALUE_NONE) { int ret;