diff options
author | rpj <rpj> | 1998-07-26 03:32:18 +0000 |
---|---|---|
committer | rpj <rpj> | 1998-07-26 03:32:18 +0000 |
commit | c9d01733e79f70581d2e6616332ac47677a6a2bd (patch) | |
tree | 9e295213b1c84188ae8cc33aa45644d6bb7afc3d | |
parent | 318cf7a90bc90a333061e721cf199ab341babe12 (diff) |
Sun Jul 26 13:06:12 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* exit.c (_pthread_vacuum): Add thread entry deletion code
moved from _pthread_start_call(). See next item.
(pthread_exit): Remove longjmp(). Add mutex lock around thread table
manipulation code. This routine now calls _enthreadex().
* create.c (_pthread_start_call): Remove setjmp() call and move
cleanup code out. Call pthread_exit(NULL) to terminate the thread.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | create.c | 54 | ||||
-rw-r--r-- | exit.c | 31 |
3 files changed, 38 insertions, 57 deletions
@@ -1,3 +1,13 @@ +Sun Jul 26 13:06:12 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au> + + * exit.c (_pthread_vacuum): Add thread entry deletion code + moved from _pthread_start_call(). See next item. + (pthread_exit): Remove longjmp(). Add mutex lock around thread table + manipulation code. This routine now calls _enthreadex(). + + * create.c (_pthread_start_call): Remove setjmp() call and move + cleanup code out. Call pthread_exit(NULL) to terminate the thread. + 1998-07-26 Ben Elliston <bje@cygnus.com> * tsd.c (pthread_getspecific): Update comments. @@ -38,58 +38,10 @@ _pthread_start_call(void * us_arg) func = us->call.routine; arg = us->call.arg; - /* FIXME: Should we be using sigsetjmp() here instead. */ - from = setjmp(us->call.env); + ret = (*func)(arg); - if (from == 0) - { - /* Normal return from setjmp(). */ - ret = (*func)(arg); - - _pthread_vacuum(); - - /* Remove the thread entry on exit only if pthread_detach() - was called and there are no waiting joins. */ - - /* CRITICAL SECTION */ - pthread_mutex_lock(&_pthread_table_mutex); - - if (us->detach == TRUE - && us->join_count == 0) - { - _pthread_delete_thread_entry(us); - } - - pthread_mutex_lock(&_pthread_table_mutex); - /* END CRITICAL SECTION */ - } - else - { - /* longjmp() teleported us here. - func() called pthread_exit() which called longjmp(). */ - _pthread_vacuum(); - - /* Remove the thread entry on exit only if pthread_detach() - was called and there are no waiting joins. */ - - /* CRITICAL SECTION */ - pthread_mutex_lock(&_pthread_table_mutex); - - if (us->detach == TRUE - && us->join_count == 0) - { - _pthread_delete_thread_entry(us); - } - - pthread_mutex_lock(&_pthread_table_mutex); - /* END CRITICAL SECTION */ - - ret = 0; - } - - /* From Win32's point of view we always return naturally from our - start routine and so it should clean up it's own thread residue. */ - return ret; + pthread_exit(NULL); + /* Never Reached */ } int @@ -28,6 +28,21 @@ _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 @@ -35,13 +50,17 @@ pthread_exit(void * value) { _pthread_threads_thread_t * us = _PTHREAD_THIS; + /* CRITICAL SECTION */ + pthread_mutex_lock(&_pthread_table_mutex); + /* Copy value into the thread entry so it can be given to any joining threads. */ - if (us->joinvalueptr != NULL) - { - us->joinvalueptr = value; - } + us->joinvalueptr = value; + + pthread_mutex_lock(&_pthread_table_mutex); + /* END CRITICAL SECTION */ + + _pthread_vacuum(); - /* Teleport back to _pthread_start_call() to cleanup and exit. */ - longjmp(us->call.env, 1); + _endthreadex(0); } |