diff options
author | rpj <rpj> | 1998-07-22 16:42:53 +0000 |
---|---|---|
committer | rpj <rpj> | 1998-07-22 16:42:53 +0000 |
commit | f33f4460f9de9c2d2ae6f3bf05caed391c6ad485 (patch) | |
tree | 12bb86525d369c1c4de220bb58d92d3eab2f5a7e /exit.c | |
parent | b84f1cc523f4236200689b2f78b16b26bc05f429 (diff) |
Wed Jul 22 00:16:22 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* attr.c, implement.h, pthread.h, ChangeLog: Resolve CVS merge
conflicts.
* private.c (_pthread_find_thread_entry): Changes to return type
to support leaner _pthread_threads_table[] which now only stores
_pthread_thread_thread_t *.
(_pthread_new_thread_entry): Internal changes.
(_pthread_delete_thread_entry): Internal changes to avoid contention.
Calling routines changed accordingly.
* pthread.h: Modified cleanup macros to use new generic push and pop.
Added destructor and atfork stacks to _pthread_threads_thread_t.
* cleanup.c (_pthread_handler_push, _pthread_handler_pop,
_pthread_handler_pop_all): Renamed cleanup push and pop routines
and made generic to handle destructors and atfork handlers as
well.
* create.c (_pthread_start_call): New function is a wrapper for
all new threads. It allows us to do some cleanup when the thread
returns, ie. that is otherwise only done if the thread is cancelled.
* exit.c (_pthread_vacuum): New function contains code from
pthread_exit() that we need in the new _pthread_start_call()
as well.
* implement.h: Various additions and minor changes.
* pthread.h: Various additions and minor changes.
Change cleanup handler macros to use generic handler push and pop
functions.
* attr.c: Minor mods to all functions.
(is_attr): Implemented missing function.
* create.c (pthread_create): More clean up.
* private.c (_pthread_find_thread_entry): Implement.
(_pthread_delete_thread_entry): Implement.
(_pthread_new_thread_entry): Implement.
These functions manipulate the implementations internal thread
table and are part of general code cleanup and modularisation.
They replace _pthread_getthreadindex() which was removed.
* exit.c (pthread_exit): Changed to use the new code above.
* pthread.h: Add cancelability constants. Update comments.
Diffstat (limited to 'exit.c')
-rw-r--r-- | exit.c | 33 |
1 files changed, 19 insertions, 14 deletions
@@ -12,25 +12,30 @@ #include "implement.h" void -pthread_exit(void * value) +_pthread_vacuum(void) { - int t; - - t = _pthread_getthreadindex(pthread_self()); + /* 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 cleanup handlers */ - _pthread_do_cancellation(t); + this = *_PTHREAD_THIS; - /* CRITICAL SECTION */ - pthread_mutex_lock(&_pthread_count_mutex); + /* Run all the handlers. */ + _pthread_handler_pop_all(&(this->cleanupstack), _PTHREAD_HANDLER_EXECUTE); + _pthread_handler_pop_all(&(this->destructorstack), _PTHREAD_HANDLER_EXECUTE); - /* Frees attr and cleanupstack */ - free(_pthread_threads_table[t]->attr); + /* 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_threads_table[t]->thread = NULL; - - pthread_mutex_unlock(&_pthread_count_mutex); - /* END CRITICAL SECTION */ + _pthread_delete_thread_entry(NULL); +} +void +pthread_exit(void * value) +{ + _pthread_vacuum(); _endthreadex((DWORD) value); } |