From 860f5268e2d230e4fc04ab588f74ea5e05bab44a Mon Sep 17 00:00:00 2001 From: rpj Date: Sat, 25 Jul 1998 12:27:18 +0000 Subject: Sat Jul 25 00:00:13 1998 Ross Johnson * create.c (_pthread_start_call): Set thread priority. Ensure our thread entry is removed from the thread table but only if pthread_detach() was called and there are no waiting joins. (pthread_create): Set detach flag in thread entry if the thread is created PTHREAD_CREATE_DETACHED. * pthread.h (pthread_attr_t): Rename member "detachedstate". * attr.c (pthread_attr_init): Rename attr members. * exit.c (pthread_exit): Fix indirection mistake. * implement.h (_PTHREAD_THREADS_TABLE_INDEX): Add. * exit.c (_pthread_vacuum): Fix incorrect args to _pthread_handler_pop_all() calls. Make thread entry removal conditional. * sync.c (pthread_join): Add multiple join and async detach handling. * implement.h (_PTHREAD_THREADS_TABLE_INDEX): Add. * global.c (_pthread_threads_mutex_table): Add. * implement.h (_pthread_once_flag): Remove. (_pthread_once_lock): Ditto. (_pthread_threads_mutex_table): Add. * global.c (_pthread_once_flag): Remove. (_pthread_once_lock): Ditto. * sync.c (pthread_join): Fix tests involving new return value from _pthread_find_thread_entry(). (pthread_detach): Ditto. * private.c (_pthread_find_thread_entry): Failure return code changed from -1 to NULL. --- exit.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'exit.c') diff --git a/exit.c b/exit.c index a32e0ca..70fc7f2 100644 --- a/exit.c +++ b/exit.c @@ -6,31 +6,28 @@ * a thread. */ -#include -#include #include "pthread.h" #include "implement.h" void _pthread_vacuum(void) { - /* This function can be called from pthread_exit(), or from - _pthread_start_call() in which case cleanupstack should be - empty but destructorstack still needs to be run. */ - _pthread_threads_thread_t * this; + /* Run all the handlers. */ + _pthread_handler_pop_all(_PTHREAD_CLEANUP_STACK, + _PTHREAD_HANDLER_EXECUTE); - this = *_PTHREAD_THIS; + _pthread_handler_pop_all(_PTHREAD_DESTRUCTOR_STACK, + _PTHREAD_HANDLER_EXECUTE); - /* Run all the handlers. */ - _pthread_handler_pop_all(&(this->cleanupstack), _PTHREAD_HANDLER_EXECUTE); - _pthread_handler_pop_all(&(this->destructorstack), _PTHREAD_HANDLER_EXECUTE); + /* Pop any atfork handlers without executing them. */ + _pthread_handler_pop_all(_PTHREAD_FORKPREPARE_STACK, + _PTHREAD_HANDLER_NOEXECUTE); - /* Pop any atfork handlers to free storage. */ - _pthread_handler_pop_all(&(this->forkprepare), _PTHREAD_HANDLER_NOEXECUTE); - _pthread_handler_pop_all(&(this->forkparent), _PTHREAD_HANDLER_NOEXECUTE); - _pthread_handler_pop_all(&(this->forkchild), _PTHREAD_HANDLER_NOEXECUTE); + _pthread_handler_pop_all(_PTHREAD_FORKPARENT_STACK, + _PTHREAD_HANDLER_NOEXECUTE); - _pthread_delete_thread_entry(NULL); + _pthread_handler_pop_all(_PTHREAD_FORKCHILD_STACK, + _PTHREAD_HANDLER_NOEXECUTE); } void @@ -40,14 +37,13 @@ pthread_exit(void * value) this = _PTHREAD_THIS; + /* Copy value into the thread entry so it can be given + to any joining threads. */ if (this->joinvalueptr != NULL) { - *(this->joinvalueptr) = value; + this->joinvalueptr = value; } - /* FIXME: More to do here. IE, if pthread_detach() was called - and value != NULL, do we free(value)? */ - /* Teleport back to _pthread_start_call() to cleanup and exit. */ longjmp(this->call.env, 1); } -- cgit v1.2.3