From e564950fd61e9ada9a0c6a599457508b8429c81b Mon Sep 17 00:00:00 2001 From: rpj Date: Sun, 26 Jul 1998 11:33:21 +0000 Subject: Sun Jul 26 13:06:12 1998 Ross Johnson * exit.c (_pthread_exit): Move thread entry delete call from _pthread_vacuum() into here. Add more explanation of thread entry deletion. --- exit.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'exit.c') diff --git a/exit.c b/exit.c index 37b5595..3714aa2 100644 --- a/exit.c +++ b/exit.c @@ -28,21 +28,6 @@ _pthread_vacuum(void) _pthread_handler_pop_all(_PTHREAD_FORKCHILD_STACK, _PTHREAD_HANDLER_NOEXECUTE); - - /* CRITICAL SECTION */ - pthread_mutex_lock(&_pthread_table_mutex); - - /* Remove the thread entry on exit only if pthread_detach() - was called and there are no waiting joins. */ - - if (us->detach == TRUE - && us->join_count == 0) - { - _pthread_delete_thread_entry(us); - } - - pthread_mutex_lock(&_pthread_table_mutex); - /* END CRITICAL SECTION */ } void @@ -62,6 +47,23 @@ _pthread_exit(void * value, int return_code) _pthread_vacuum(); + /* CRITICAL SECTION */ + pthread_mutex_lock(&_pthread_table_mutex); + + /* Remove the thread entry on exit only if pthread_detach() was + called AND there are no waiting joins. Otherwise the thread entry + will be deleted by the last waiting pthread_join() after this + thread has terminated. */ + + if (us->detach == TRUE + && us->join_count == 0) + { + _pthread_delete_thread_entry(us); + } + + pthread_mutex_lock(&_pthread_table_mutex); + /* END CRITICAL SECTION */ + _endthreadex(return_code); } -- cgit v1.2.3