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. --- private.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'private.c') diff --git a/private.c b/private.c index dc7e111..d77f0b2 100644 --- a/private.c +++ b/private.c @@ -98,35 +98,27 @@ _pthread_find_thread_entry(pthread_t thread) if (this->thread == NULL || this == start) { /* Failed to find the thread. */ - return -1; + return NULL; } return this; } void -_pthread_delete_thread_entry(_pthread_threads_thread_t * this) +_pthread_delete_thread_entry(_pthread_threads_thread_t * thread_entry) { /* We don't check that the thread has been properly cleaned up, so it had better be done already. */ - _pthread_threads_thread_t * this; - _pthread_threads_thread_t * entry; /* CRITICAL SECTION */ pthread_mutex_lock(&_pthread_count_mutex); - /* If this is not NULL then we are removing an entry for a - failed thread start. If this is NULL we need to get this - here within the critical section. */ - if (this == NULL) - { - this = _PTHREAD_THIS; - } + /* Remove the thread entry if necessary. */ - if (this->thread != NULL) + if (thread_entry->thread != NULL) { - this->thread = NULL; - + thread_entry->thread = NULL; + if (_pthread_threads_count > 0) { _pthread_threads_count--; -- cgit v1.2.3