diff options
author | neal <neal> | 2008-08-16 09:37:22 +0000 |
---|---|---|
committer | neal <neal> | 2008-08-16 09:37:22 +0000 |
commit | 54e51f1330ed2f31fd5b7a7260478880c54d33b7 (patch) | |
tree | 02c39cbc99be44bb7da8e44513c143801ebed729 /libpthread/pthread/pt-internal.h | |
parent | a64c5f68c2e5915ac63e3e70216a970bda327c41 (diff) |
2008-08-16 Neal H. Walfield <neal@gnu.org>
* pthread/pt-alloc.c: Don't include <atomic.h>.
(__pthread_free_threads): Change to a struct __pthread *.
(__pthread_free_threads_lock): New variable.
(__pthread_alloc): When looking for a TCB to reuse, iterate over
__pthread_free_threads taking the first for which the STATE field
is PTHREAD_TERMINATED. When reusing a TCB, first call
__pthread_thread_halt on it.
* pthread/pt-dealloc.c: Don't include <atomic.h>.
(__pthread_free_threads): Change to a struct __pthread *.
(__pthread_free_threads_lock): New declaration.
(__pthread_dealloc): Enqueue PTHREAD on __PTHREAD_FREE_THREADS.
Set PTHREAD->STATE to PTHREAD_TERMINATED after everything else.
* pthread/pt-join.c (pthread_join): Call __pthread_thread_halt
before destroying the thread. When destroying the thread, call
__pthread_thread_dealloc on it.
* pthread/pt-exit.c (pthread_exit): Call __pthread_dealloc only if
the thread is detached and then as the last thing we do before
calling __pthread_thread_halt.
* pthread/pt-internal.h (__pthread_thread_halt): Remove argument
NEED_DEALLOC. Update users.
* sysdeps/l4/hurd/pt-thread-halt.c (__pthread_thread_halt): Remove
argument need_dealloc. Move the deallocation code from this
file...
* sysdeps/l4/hurd/pt-thread-dealloc.c: ... to this new file.
* sysdeps/l4/hurd/pt-sysdep.h (PTHREAD_SYSDEP_MEMBERS): Add field
have_kernel_resources.
* sysdeps/l4/hurd/pt-thread-alloc.c (__pthread_thread_alloc): If
THREAD->HAVE_KERNEL_RESOURCES is true, just return. After
allocating the resources, set THREAD->HAVE_KERNEL_RESOURCES to
true.
Diffstat (limited to 'libpthread/pthread/pt-internal.h')
-rw-r--r-- | libpthread/pthread/pt-internal.h | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/libpthread/pthread/pt-internal.h b/libpthread/pthread/pt-internal.h index 9eb84ed..986ec6b 100644 --- a/libpthread/pthread/pt-internal.h +++ b/libpthread/pthread/pt-internal.h @@ -38,9 +38,13 @@ /* Thread state. */ enum pthread_state { + /* The thread is running and joinable. */ PTHREAD_JOINABLE = 0, + /* The thread is running and detached. */ PTHREAD_DETACHED, + /* A joinable thread exited and its return code is available. */ PTHREAD_EXITED, + /* The thread structure is unallocated and available for reuse. */ PTHREAD_TERMINATED }; @@ -215,22 +219,22 @@ extern int __pthread_setup (struct __pthread *__restrict thread, resources) for THREAD; it must not be placed on the run queue. */ extern int __pthread_thread_alloc (struct __pthread *thread); -/* Deallocate any kernel resources associated with THREAD except don't - halt the thread itself. On return, the thread will be marked as - dead and __pthread_halt will be called. */ +/* Deallocate any kernel resources associated with THREAD. The thread + must not be running (that is, if __pthread_thread_start was called, + __pthread_thread_halt must first be called). This function will + never be called by a thread on itself. In the case that a thread + exits, its thread structure will be cached and cleaned up + later. */ extern void __pthread_thread_dealloc (struct __pthread *thread); /* Start THREAD making it eligible to run. */ extern int __pthread_thread_start (struct __pthread *thread); -/* Stop the kernel thread associated with THREAD. If NEED_DEALLOC is - true, the function must call __pthread_dealloc on THREAD. - - NB: The thread executing this function may be the thread which is - being halted, thus the last action should be halting the thread - itself. */ -extern void __pthread_thread_halt (struct __pthread *thread, - int need_dealloc); +/* Stop the kernel thread associated with THREAD. This function may + be called by two threads in parallel. In particular, by the thread + itself and another thread trying to join it. This function must be + implemented such that this is safe. */ +extern void __pthread_thread_halt (struct __pthread *thread); /* Called by a thread just before it calls the provided start |