about summary refs log tree commit diff
path: root/htl/pt-dealloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'htl/pt-dealloc.c')
-rw-r--r--htl/pt-dealloc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/htl/pt-dealloc.c b/htl/pt-dealloc.c
index 9cca718c7f..c776e3471d 100644
--- a/htl/pt-dealloc.c
+++ b/htl/pt-dealloc.c
@@ -29,12 +29,10 @@ extern struct __pthread *__pthread_free_threads;
 extern pthread_mutex_t __pthread_free_threads_lock;
 
 
-/* Deallocate the thread structure for PTHREAD.  */
+/* Deallocate the content of the thread structure for PTHREAD.  */
 void
 __pthread_dealloc (struct __pthread *pthread)
 {
-  assert (pthread->state != PTHREAD_TERMINATED);
-
   if (!atomic_decrement_and_test (&pthread->nr_refs))
     return;
 
@@ -56,13 +54,18 @@ __pthread_dealloc (struct __pthread *pthread)
   __pthread_mutex_lock (&__pthread_free_threads_lock);
   __pthread_enqueue (&__pthread_free_threads, pthread);
   __pthread_mutex_unlock (&__pthread_free_threads_lock);
+}
 
-  /* Setting PTHREAD->STATE to PTHREAD_TERMINATED makes this TCB
+/* Confirm deallocation of the thread structure for PTHREAD.  */
+void
+__pthread_dealloc_finish (struct __pthread *pthread)
+{
+  /* Setting PTHREAD->TERMINATED makes this TCB
      available for reuse.  After that point, we can no longer assume
      that PTHREAD is valid.
 
      Note that it is safe to not lock this update to PTHREAD->STATE:
      the only way that it can now be accessed is in __pthread_alloc,
      which reads this variable.  */
-  pthread->state = PTHREAD_TERMINATED;
+  pthread->terminated = TRUE;
 }