summaryrefslogtreecommitdiff
path: root/pthread
AgeCommit message (Collapse)Author
2018-04-02Add first-line comment to files lacking itSamuel Thibault
2018-03-28Fix coding styleSamuel Thibault
2018-03-28Fix coding styleSamuel Thibault
2018-03-28Fix coding styleSamuel Thibault
2018-03-19Move bits/spin-lock.h to bits/types/__pthread_spinlock_t.hSamuel Thibault
* sysdeps/mach/bits/spin-lock.h: Move file to... * sysdeps/mach/bits/types/__pthread_spinlock_t.h: ... here. * Makefile (headers): Move bits/spin-lock.h to bits/types/__pthread_spinlock_t.h. * pthread/pt-spin-inlines.c: Update accordingly. * sysdeps/generic/pthread.h: Likewise. * sysdeps/mach/bits/spin-lock-inline.h: Likewise. * sysdeps/pthread/bits/barrier.h: Likewise. * sysdeps/pthread/bits/condition.h: Likewise. * sysdeps/pthread/bits/mutex.h: Likewise. * sysdeps/pthread/bits/once.h: Likewise. * sysdeps/pthread/bits/pthreadtypes.h: Likewise. * sysdeps/pthread/bits/rwlock.h: Likewise. * sysdeps/pthread/bits/semaphore.h: Likewise.
2018-03-19Remove ENABLE_TLS defineSamuel Thibault
* Makefile (CPPFLAGS): Remove -DENABLE_TLS. * pthread/pt-alloc.c: Remove ENABLE_TLS condition. * pthread/pt-create.c: Likewise. * pthread/pt-internal.h: Likewise.
2018-03-19Avoid installing private pthread.hSamuel Thibault
It was actually by mistake that sysdeps/pthread/pthread.h was getting installed and that we'd have an include/pthread/pthread.h. Let's simplify this. * sysdeps/pthread/pthread.h: Move file content to... * ./sysdeps/pthread/pthreadP.h: ... here. * sysdeps/generic/pthread/pthread.h: Move file to... * sysdeps/generic/pthread.h: ... here. * Makefile (headers): Remove pthread/pthread.h. * Makeconfig (includes): Remove -I$(..)htl/include. * pthread/cthreads-compat.c: Include <pthreadP.h> instead of <pthread.h>
2018-03-19Remove bits/pt-atomic.hSamuel Thibault
* pthread/pt-create.c: Include <atomic.h> instead of <bits/pt-atomic.h>. (__pthread_total): Change type from __atomic_t to unsigned int. (__pthread_create_internal): Use atomic_increment and atomic_decrement instead of __atomic_inc and __atomic_dec. * pthread/pt-dealloc.c: Include <atomic.h> instead of <bits/pt-atomic.h>. (__pthread_dealloc): Use atomic_decrement_and_test instead of __atomic_dec_and_test. * pthread/pt-exit.c: Include <atomic.h> instead of <bits/pt-atomic.h>. (__pthread_exit): Use atomic_decrement_and_test instead of __atomic_dec_and_test. * pthread/pt-internal.h: Include <atomic.h> instead of <bits/pt-atomic.h>. (struct __pthread): Use unsigned int type for nr_refs field instead of __atomic_t. (__pthread_total): Use unsigned int type instead of nr_refs.
2018-03-18Fix getting typesSamuel Thibault
* pthread/pt-internal.h: Include <bits/types/res_state.h> instead of defining __need_res_state and including <resolv.h>. * sysdeps/pthread/semaphore.h [__USE_XOPEN2K]: Include <bits/types/struct_timespec.h> instead of defining __need_timespec and including <time.h>.
2018-03-18Remove unused __pthread_init hookSamuel Thibault
Since nothing uses it we get link failures. * pthread/pt-initialize.c (__pthread_init): Remove hook. (___pthread_init): Do not call __pthread_init hook.
2018-03-03Fix copyright years and addressesAmos Jeffries
* sysdeps/mach/hurd/bits/mutex.h: reformat copyright blurb intro to match other files * replace Free Software Foundation address using gnu.org URL from upstream glibc copyright blurbs. * apply upstream glibc scripts/update-copyrights * update copyright date syntax per upstream glibc request
2018-01-27Use pthread_key for libc_keySamuel Thibault
* sysdeps/pthread/pthread-functions.h (struct pthread_functions): Rename ptr_pthread_key_create, ptr_pthread_getspecific, ptr_pthread_setspecific fields into ptr___pthread_key_create, ptr___pthread_getspecific, ptr___pthread_setspecific * pthread/pt-initialize.c (struct pthread_functions): Likewise. * sysdeps/pthread/libc-lockP.h (__libc_key_t): Define type. [IS_IN (libpthread)] (PTFAVAIL, __libc_ptf_call, __libc_ptf_call_always): Directly call pthread functions. (__libc_key_create): Define macro to calling __pthread_key_create. (__libc_getspecific): Define macro to calling __pthread_getspecific. (__libc_setspecific): Define macro to calling __pthread_setspecific.
2018-01-25Fix spurious whitespacesSamuel Thibault
2018-01-21Move Version to sysdeps so the normal sysdeps mechanism worksSamuel Thibault
to cope with the removal of add-ons mechanism. * pthread/Versions: Move to sysdeps/pthread/.
2017-11-05Make pthread_spinlock use gsyncAgustina Arzille
* pthread/pt-spin-inlines.c (pthread_spin_lock): Define weak alias for __pthread_spin_lock. * sysdeps/mach/bits/spin-lock-inline.h: Include <lock-intern.h> instead of <machine-lock.h>. (__pthread_spin_trylock, __pthread_spin_unlock): Use __spin_lock_t type instead of __lock. (__pthread_spin_lock): Define as inline only, use __spin_lock and __spin_lock_t type. * sysdeps/mach/bits/spin-lock.h: Do not include <machine-lock.h> (__pthread_spinlock_t): Use volatile int instead of __spin_lock_t. (__PTHREAD_SPIN_LOCK_INITIALIZER): Define to 0. * sysdeps/mach/i386/bits/spin-lock-inline.h: Remove file. * sysdeps/mach/i386/bits/spin-lock.h: Remove file. * sysdeps/posix/pt-spin.c (pthread_spin_lock, __pthread_spin_lock): Remove weak aliases, provided by pt-spin-inlines.c
2017-09-24Fix symbols exposed in linkspaceSamuel Thibault
Libc uses some thread functions, but should not expose the corresponding symbols, so use aliases. * Versions (__cthread_detach, __cthread_fork, __cthread_keycreate, __cthread_getspecific, __cthread_setspecific, __pthread_getattr_np, __pthread_attr_getstack): Add symbols * pthread/cthreads-compat.c (cthread_t, cthread_fn_t, cthread_key_t): Do not define. (cthread_detach): Rename to __cthread_detach. (cthread_detach): Define as weak alias to __cthread_detach. (cthread_fork, cthread_keycreate, cthread_getspecific, cthread_setspecific): Likewise. * pthread/pt-getattr.c (pthread_getattr_np): Likewise. * sysdeps/generic/pt-attr-getstack.c (pthread_attr_getstack): Likewise. * sysdeps/pthread/pthread.h (__cthread_t, __cthread_key_t, __cthread_fn_t, __cthread_fork, __cthread_detach, __cthread_keycreate, __cthread_getspecific, __cthread_setspecific, __pthread_getattr_np, __pthread_attr_getstack): Declare.
2016-10-18Fix spurious common variable definitionsSamuel Thibault
* pthread/pt-internal.h (__pthread_default_rwlockattr, __pthread_default_condattr): Add missing extern qualifier to variable declaration.
2016-10-14Fix exec crash due to ext2fsSamuel Thibault
This reverts part of a87bf9a8 for now. This fixes a crash in exec due to ext2fs, still to be investigated. * pthread/pt-exit.c (__pthread_exit): Use pthread_setcancelstate instead of __pthread_setcancelstate.
2016-09-21Merge branch 'master' into master-glibc-2.23Samuel Thibault
2016-09-19Fix exposition of pthread functionsSamuel Thibault
* pthread/pt-alloc.c (__pthread_alloc): Use __pthread_rwlock_wrlock and __pthread_rwlock_unlock instead of pthread_rwlock_wrlock and pthread_rwlock_unlock. * pthread/pt-create.c (__pthread_create_internal): Use__pthread_rwlock_rdlock and __pthread_rwlock_unlock instead of pthread_rwlock_rdlock and pthread_rwlock_unlock. * pthread/pt-dealloc.c (__pthread_dealloc): Use __pthread_cond_broadcast, __pthread_mutex_lock, and __pthread_mutex_unlock instead of pthread_cond_broadcast, pthread_mutex_lock, and pthread_mutex_unlock * pthread/pt-exit.c (__pthread_exit): Use __pthread_setcancelstate and __pthread_cond_broadcast instead of pthread_setcancelstate and pthread_cond_broadcast. * pthread/pt-internal.h (__pthread_getid, __pthread_setid): Use __pthread_rwlock_rdlock, __pthread_rwlock_wrlock, and __pthread_rwlock_unlock instead of pthread_rwlock_rdlock, pthread_rwlock_wrlock, and pthread_rwlock_unlock * pthread/pt-join.c (pthread_join): Use __pthread_cond_wait instead of pthread_cond_wait. * sysdeps/hurd/pt-key-delete.c (pthread_key_delete): Use __pthread_rwlock_rdlock and __pthread_rwlock_unlock instead of pthread_rwlock_rdlock and pthread_rwlock_unlock.
2016-09-19Fix getrlimit visibilitySamuel Thibault
* pthread/pt-create.c (__pthread_create_internal): Call __getrlimit instead of getrlimit.
2016-08-21Revert "Fix build with 2.22"Samuel Thibault
This reverts commit edb5bb83ec918dc6b77b3da5b246c056932d78d7.
2016-08-21fix glibc 2.22 buildSamuel Thibault
* pthread/alloca_cutoff.c: New file. * Makefile (routines): Add alloca_cutoff. * Versions (GLIBC_PRIVATE): Add __libc_alloca_cutoff.
2016-08-20Fix build with 2.22Samuel Thibault
2015-11-01Merge branch 'master-glibc' into master-glibc-2.21Samuel Thibault
2015-10-11Remove __libc_getspecificSamuel Thibault
The version from libc was not made to be replaced, and doesn't need to indeed. * Version: Remove __libc_getspecific symbol. * libpthread.a: Likewise. * libpthread_pic.a: Likewise. * pthread/cthreads-compat: Remove __libc_getspecific function.
2015-05-07Revert "Fix build with glibc < 2.21"glibc-2.21-hurd3Samuel Thibault
This reverts commit 9aa597d0457d265b9bbdc213de67a8ce9e30f60a.
2015-05-07Merge branch 'master' into master-glibc-2.21Samuel Thibault
2015-05-07Fix build with glibc < 2.21Samuel Thibault
* pthread/pt-internal.h: Use IS_IN_libpthread instead of IS_IN (libpthread).
2015-05-06Revert "Revert "Stop using IS_IN""glibc-2.21-hurd1Samuel Thibault
This reverts commit c6fc9fbb8e0d2e0a8147197c31589cdc96497e07.
2015-05-06Revert "Stop using IS_IN"Samuel Thibault
This reverts commit 44ae774bed1a75ea926590f1bc7c9f3328219832.
2015-03-22Avoid exposing internals of structuresSamuel Thibault
* sysdeps/generic/bits/barrier-attr.h (__pthread_barrierattr): Rename `pshared' field to `__pshared'. * sysdeps/generic/bits/barrier.h (__pthread_barrier): Rename `lock', `'queue', `pending', `count', `attr', and `data' fields to `__lock', `__queue', `__pending', `__count', `__attr', and `__data'. * sysdeps/generic/bits/cancelation.h (__pthread_cancelation_handler): Rename `handler', `arg', and `next' fields to `__handler', `__arg', and `__next'. * sysdeps/generic/bits/condition-attr.h (__pthread_condattr): Rename `pshared' and `clock' fields to `__pshared', and `__clock'. * sysdeps/generic/bits/mutex-attr.h (__pthread_mutexattr): Rename `prioceiling', `protocol', `pshared', and `mutex_type' fields to `__prioceiling', `__protocol', `__pshared', and `__mutex_type'. * sysdeps/generic/bits/mutex.h (__pthread_mutex): Rename `cthreadscompat1', `attr', `data', `owner', and `locks' fields to `__cthreadscompat1', `__attr', `__data', `__owner', and `__locks'. * sysdeps/generic/bits/once.h (__pthread_once): Rename `run' and `lock' fields to `__run' and `__lock'. * sysdeps/generic/bits/rwlock-attr.h (__pthread_rwlockattr): Rename `psharead' field to `__pshared'. * sysdeps/generic/bits/rwlock.h (__pthread_rwlock): Rename `readers', `readerqueue', and `writerqueue' fields to `__readers', `__readerqueue', and `__writerqueue'. * sysdeps/generic/bits/thread-attr.h (__pthread_contentionscope): Rename `schedparam', `stackaddr', `stacksize', `guardsize', `detachstate', `inheritsched', `contentionscope', and `schedpolicy' fields to `__schedparam', `__stackaddr', `__stacksize', `__guardsize', `__detachstate', `__inheritsched', `__contentionscope', and `__schedpolicy''. * sysdeps/generic/bits/cancelation.h: Update code accordingly. * pthread/pt-create.c: Likewise. * pthread/pt-exit.c: Likewise. * pthread/pt-getattr.c: Likewise. * sysdeps/generic/pt-attr-getdetachstate.c: Likewise. * sysdeps/generic/pt-attr-getguardsize.c: Likewise. * sysdeps/generic/pt-attr-getinheritsched.c: Likewise. * sysdeps/generic/pt-attr-getschedparam.c: Likewise. * sysdeps/generic/pt-attr-getschedpolicy.c: Likewise. * sysdeps/generic/pt-attr-getscope.c: Likewise. * sysdeps/generic/pt-attr-getstackaddr.c: Likewise. * sysdeps/generic/pt-attr-getstacksize.c: Likewise. * sysdeps/generic/pt-attr-setdetachstate.c: Likewise. * sysdeps/generic/pt-attr-setguardsize.c: Likewise. * sysdeps/generic/pt-attr-setinheritsched.c: Likewise. * sysdeps/generic/pt-attr-setschedparam.c: Likewise. * sysdeps/generic/pt-attr-setschedpolicy.c: Likewise. * sysdeps/generic/pt-attr-setscope.c: Likewise. * sysdeps/generic/pt-attr-setstackaddr.c: Likewise. * sysdeps/generic/pt-attr-setstacksize.c: Likewise. * sysdeps/generic/pt-attr.c: Likewise. * sysdeps/generic/pt-barrier-init.c: Likewise. * sysdeps/generic/pt-barrier-wait.c: Likewise. * sysdeps/generic/pt-barrier.c: Likewise. * sysdeps/generic/pt-barrierattr-getpshared.c: Likewise. * sysdeps/generic/pt-barrierattr-setpshared.c: Likewise. * sysdeps/generic/pt-cond-timedwait.c: Likewise. * sysdeps/generic/pt-cond.c: Likewise. * sysdeps/generic/pt-condattr-getclock.c: Likewise. * sysdeps/generic/pt-condattr-getpshared.c: Likewise. * sysdeps/generic/pt-condattr-setclock.c: Likewise. * sysdeps/generic/pt-condattr-setpshared.c: Likewise. * sysdeps/generic/pt-mutex-destroy.c: Likewise. * sysdeps/generic/pt-mutex-init.c: Likewise. * sysdeps/generic/pt-mutex-timedlock.c: Likewise. * sysdeps/generic/pt-mutex-transfer-np.c: Likewise. * sysdeps/generic/pt-mutex-trylock.c: Likewise. * sysdeps/generic/pt-mutex-unlock.c: Likewise. * sysdeps/generic/pt-mutexattr-getprotocol.c: Likewise. * sysdeps/generic/pt-mutexattr-getpshared.c: Likewise. * sysdeps/generic/pt-mutexattr-gettype.c: Likewise. * sysdeps/generic/pt-mutexattr-setprotocol.c: Likewise. * sysdeps/generic/pt-mutexattr-setpshared.c: Likewise. * sysdeps/generic/pt-mutexattr-settype.c: Likewise. * sysdeps/generic/pt-mutexattr.c: Likewise. * sysdeps/generic/pt-once.c: Likewise. * sysdeps/generic/pt-rwlock-attr.c: Likewise. * sysdeps/generic/pt-rwlock-timedrdlock.c: Likewise. * sysdeps/generic/pt-rwlock-timedwrlock.c: Likewise. * sysdeps/generic/pt-rwlock-tryrdlock.c: Likewise. * sysdeps/generic/pt-rwlock-trywrlock.c: Likewise. * sysdeps/generic/pt-rwlock-unlock.c: Likewise. * sysdeps/generic/pt-rwlockattr-getpshared.c: Likewise. * sysdeps/generic/pt-rwlockattr-setpshared.c: Likewise. * sysdeps/mach/hurd/pt-attr-setstackaddr.c: Likewise. * sysdeps/mach/hurd/pt-attr-setstacksize.c: Likewise. * sysdeps/mach/hurd/pt-hurd-cond-timedwait.c: Likewise.
2015-03-22Fix build after 32b1b38Samuel Thibault
* sysdeps/pthread/pthread-functions.h (pthread_functions): Rename ptr_pthread_exit field to ptr___pthread_exit. * pthread/pt-initialize.c (pthread_functions): Likewise.
2015-03-08Move pthread-specific lock definitions and declarations to libpthreadSamuel Thibault
* sysdeps/pthread/bits/libc-lockP.h: New file * pthread/pthread-functions.h: Move to... * sysdeps/pthread/pthread-functions.h: ... here.
2015-03-01Forward lockfile calls from libc to dynamically loaded libpthreadSamuel Thibault
* forward.c: (__libc_pthread_functions_init): Add variable (FORWARD2): Use __libc_pthread_functions_init instead of testing __libc_pthread_functions.ptr_##name value. (FORWARD_NORETURN): Add macro. (pthread_exit): Use FORWARD_NORETURN instead of FORWARD2. * libc_pthread_init.c (__libc_pthread_init): Set __libc_pthread_functions_init to 1. * pthread/pthread-functions.h (__pthread_once, __pthread_rwlock_rdlock, __pthread_rwlock_wrlock, __pthread_rwlock_unlock, __pthread_key_create, __pthread_getspecific, __pthread_setspecific, _cthreads_flockfile, _cthreads_funlockfile, _cthreads_ftrylockfile): Add prototypes. (pthread_functions): Add ptr_pthread_once, ptr_pthread_rwlock_rdlock, ptr_pthread_rwlock_wrlock, ptr_pthread_rwlock_unlock, ptr_pthread_key_create, ptr_pthread_getspecific, ptr_pthread_setspecific, ptr__IO_flockfile, ptr__IO_funlockfile, ptr__IO_ftrylockfile. (__libc_pthread_functions_init): Add variable declaration. (PTHFCT_CALL): Add macro. * pthread/pt-initialize.c (pthread_functions): Initialize ptr_pthread_once, ptr_pthread_rwlock_rdlock, ptr_pthread_rwlock_wrlock, pthread_rwlock_unlock, ptr_ptr_pthread_key_create, pthread_getspecific, ptr_pthread_setspecific, ptr_ptr__IO_flockfile, _IO_funlockfile, ptr__IO_ftrylockfile. * sysdeps/generic/pt-once.c (pthread_once): Rename to __pthread_once (pthread_once): Add strong alias. * sysdeps/generic/pt-rwlock-rdlock.c (pthread_rwlock_rdlock): Rename to __pthread_rwlock_rdlock (pthread_rwlock_rdlock): Add strong alias. * sysdeps/generic/pt-rwlock-wrlock.c (pthread_rwlock_wrlock): Rename to __pthread_rwlock_wrlock (pthread_rwlock_wrlock): Add strong alias. * sysdeps/generic/pt-rwlock-unlock.c (pthread_rwlock_unlock): Rename to __pthread_rwlock_unlock (pthread_rwlock_unlock): Add strong alias. * sysdeps/generic/pt-getspecific.c (pthread_getspecific): Rename to __pthread_getspecific (pthread_getspecific): Add strong alias. * sysdeps/generic/pt-setspecific.c (pthread_setspecific): Rename to __pthread_setspecific (pthread_setspecific): Add strong alias. * sysdeps/pthread/flockfile.c: Add file. * sysdeps/pthread/ftrylockfile.c: Add file. * sysdeps/pthread/funlockfile.c: Add file.
2015-02-28Allow libpthread.so to dynamically loaded from a dlopened librarySamuel Thibault
* pthread/pt-internal.h: Include <ldsodefs.h> (_dl_allocate_tls, _dl_deallocate_tls): Remove declarations. * sysdeps/mach/hurd/pt-sysdep.c (init_routine): Rename into _init_routine, add `stack' parameter, return if __pthread_threads is already initialized, pass stack address to __pthread_create_internal if any. (init_routine): New function, calls init_routine with 0 (dynamic_init_routine): New constructor function, calls init_routine with __libc_stack_end.
2015-02-12Rename __pthread_init into ___pthread_initSamuel Thibault
To avoid clashing with the __pthread_init hook. * pthread/pt-initialize.c (__pthread_init): Rename into ___pthread_init. * pthread/pt-internal.h: Likewise. * sysdeps/mach/hurd/pt-sysdep.c: Likewise.
2015-02-12Stop using IS_INSamuel Thibault
* pthread/pt-create.c: Use IS_IN (libpthread) instead of IS_IN_libpthread * pthread/pt-initialize.c: Likewise. * pthread/pt-internal.h: Likewise.
2014-12-04Fix pthread_create return value on TLS allocation failureSamuel Thibault
* pthread/pt-create.c (__pthread_create_internal): When _dl_allocate_tls returns NULL, set `err' to ENOMEM.
2014-09-28Fetch stack size from rlimitSamuel Thibault
* pthread/pt-create.c: Include <hurd/resource.h> (__pthread_create_internal): When `attr''s stacksize is 0, try to get the desired size from the RLIMIT_STACK rlimit before defaulting to PTHREAD_STACK_DEFAULT. * sysdeps/generic/pt-attr.c (__pthread_default_attr): Set stacksize to 0 instead of PTHREAD_STACK_DEFAULT.
2014-08-31Fix stack address computationSamuel Thibault
stackaddr is supposed to be an adressable byte, i.e. not inside the guard size. * pthread/pt-getattr.c (pthread_getattr_np): Take guard size into account when returning the stack bottom address.
2014-08-20Fix guard size computationSamuel Thibault
* pthread/pt-create.c (__pthread_create_internal): On thread creation failure, take guard size into account when deallocating the stack. * sysdeps/mach/pt-thread-terminate.c (__pthread_thread_terminate): Take guard size into account when deallocating the stack.
2014-05-23Fix guardsize computationSamuel Thibault
* pthread/pt-create.c (__pthread_create_internal): Round guardsize up to page size. Fill `guardsize' field of thread structure. * sysdeps/mach/hurd/i386/pt-setup.c (stack_setup): Add guardsize to computation of the top of the stack.
2014-05-02Fix guardsize semanticSamuel Thibault
POSIX says guardsize is in addition to stacksize, not included. * pthread/pt-create.c (__pthread_create_internal): Use setup->guardsize + setup->stacksize as stack allocation size. Do not truncate guardsize to stacksize. * pthread/pt-internal.h (guardsize): Remove comment. * sysdeps/generic/pt-attr-setstacksize.c (pthread_attr_setstacksize): Do not truncate guardsize to stacksize.
2014-02-19Make name resolution thread-safeRichard Braun
* pthread/pt-alloc.c (initialize_pthread): Reset resolver state. * pthread/pt-create.c: Include <resolv.h>. (entry_point): Update the __resp TLS variable to point to the resolver state of the current thread. * pthread/pt-internal.h: Define __need_res_state and include <resolv.h>. (struct __pthread): New `res_state' member.
2014-01-22Fix thread destructionRichard Braun
Releasing a thread reference uses a mutex, which means the kernel resources used for synchronization must be available until late during the destruction process. For simplicity, merge __pthread_thread_dealloc into __pthread_thread_terminate. * Makefile (libpthread-routines): Remove pt-thread-dealloc. * pthread/pt-create.c (__pthread_create_internal): Remove call to __pthread_thread_dealloc. * pthread/pt-exit.c (__pthread_exit): Likewise. * pthread/pt-internal.h (__pthread_thread_dealloc): Remove declaration. (__pthread_thread_terminate): Update description. * sysdeps/mach/pt-thread-dealloc.c: Remove file. * sysdeps/mach/pt-thread-terminate.c (__pthread_thread_terminate): Destroy the wake up port.
2013-12-29Revert "Allow applications to set the default stack size"Richard Braun
This reverts commit 536420a581f9f822cdef0fc460b5176a840f49e5. Now that threadvars have been replaced with TLS, this hack is no longer needed.
2013-12-26Implement thread destructionRichard Braun
This change makes libpthread release almost every resource allocated for a thread, including the kernel thread, its send right, its reply port and its stack. This improves resource usage after peaks of activity during which servers can create hundreds or even thousands of threads. To achieve this, the library relies on the recently added thread_terminate_release one-way GNU Mach RPC, which allows threads to release their last resources along with terminating in a single operation. The pthread_exit function unconditionally releases all the resources it can, including other kernel objects (namely the port used for blocking and waking up) and signal states. When releasing the pthread structure, a reference counter is used so that joinable threads remain available. Once the reference counter drops to 0, the pthread structure can be recycled. Thread local storage (TLS) is also recycled since it needs to remain allocated while terminating the thread, as it is there that the reply port is stored. TLS could be released too, after grabbing the reply port name, but it is difficult to make sure no RPC involving a reply port is used afterwards, so the simpler solution of recycling TLS was chosen. * Makefile (libpthread-routines): Replace pt-thread-halt with pt-thread-terminate. * pthread/pt-alloc.c (initialize_pthread): Set reference counter and unconditionally initialize new threads completely. (__pthread_alloc): Remove call to __pthread_thread_halt, update calls to initialize_pthread. * pthread/pt-create.c (__pthread_create_internal): Don't attempt to reuse stacks, handle reference counter, update failure handling. * pthread/pt-dealloc.c: Include bits/pt-atomic.h. (__pthread_dealloc): Make pthread structure available for reuse when reference counter reaches 0. * pthread/pt-detach.c (pthread_detach): Assume the target thread takes care of its own resources and, as a result, simply unreference its pthread struct. * pthread/pt-exit.c (__pthread_exit): Release resources and terminate. * pthread/pt-internal.h (struct __pthread): New `nr_refs' member. (__pthread_alloc): Update description. (__pthread_dealloc): Likewise. (__pthread_thread_dealloc): Likewise. (__pthread_thread_terminate): New declaration. * pthread/pt-join.c (pthread_join): Assume the target thread takes care of its own resources and, as a result, simply unreference its pthread struct. * sysdeps/mach/hurd/pt-sigstate-destroy.c (__pthread_sigstate_destroy): Call _hurd_sigstate_delete. * sysdeps/mach/hurd/pt-sigstate-init.c (__pthread_sigstate_init): Call _hurd_thread_sigstate and _hurd_sigstate_set_global_rcv when appropriate. * sysdeps/mach/hurd/pt-sysdep.c (__pthread_create_internal): Prevent the library from releasing the stack of the main thread. * sysdeps/mach/hurd/pt-sysdep.h (PTHREAD_SYSDEP_MEMBERS): Remove `have_kernel_resources' from the list of sysdep members. * sysdeps/mach/pt-thread-alloc.c (__pthread_thread_alloc): Update thread allocation. * sysdeps/mach/pt-thread-dealloc.c (__pthread_thread_dealloc): Update description. * sysdeps/mach/pt-thread-halt.c: Remove file. * sysdeps/mach/pt-thread-start.c (__pthread_thread_start): Fix the conditions under which a thread should actually be started. * sysdeps/mach/pt-thread-terminate.c: New file.
2013-10-24Really use user-provided stackSamuel Thibault
* pthread/pt-create.c (__pthread_create_internal): When the user provides a `stackaddr`, use it instead of allocating a stack. * pthread/pt-detach.c (pthread_detach): Only deallocate the stack when it was allocated by libpthread. * pthread/pt-join.c (pthread_join): Likewise.
2013-10-20Drop threadvars entirelySamuel Thibault