diff options
author | rpj <rpj> | 1998-07-26 11:33:21 +0000 |
---|---|---|
committer | rpj <rpj> | 1998-07-26 11:33:21 +0000 |
commit | e564950fd61e9ada9a0c6a599457508b8429c81b (patch) | |
tree | 994bf5d5a4cbe364aee88e1e0a4174ee16e3027c | |
parent | e54818fa1513ff6802c929d27f01df2257d8c153 (diff) |
Sun Jul 26 13:06:12 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* exit.c (_pthread_exit): Move thread entry delete call from _pthread_vacuum()
into here. Add more explanation of thread entry deletion.
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | exit.c | 32 |
2 files changed, 19 insertions, 15 deletions
@@ -3,6 +3,8 @@ Sun Jul 26 13:06:12 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * exit.c (_pthread_exit): New function. Called from pthread_exit() and _pthread_start_call() to exit the thread. It allows an extra argument which is the return code passed to _endthreadex(). + (_pthread_exit): Move thread entry delete call from _pthread_vacuum() + into here. Add more explanation of thread entry deletion. * create.c (_pthread_start_call): Change pthread_exit() call to _pthread_exit() call. @@ -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); } |