summaryrefslogtreecommitdiff
path: root/sysdeps/mach
AgeCommit message (Collapse)Author
2018-04-02Remove 'contributed' lines, the names will show up in ChangeLogHEADmasterSamuel Thibault
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-28Fix coding styleSamuel Thibault
2018-03-28Fix coding styleSamuel Thibault
2018-03-28Fix coding styleSamuel Thibault
2018-03-19Move bits/mutex-attr.h to bits/types/struct___pthread_mutexattr.hSamuel Thibault
* sysdeps/pthread/bits/mutex-attr.h: Move file to... * sysdeps/pthread/bits/types/struct___pthread_mutexattr.h: ... here. * Makefile (headers): Update accordingly. * sysdeps/generic/pthread.h: Likewise. * sysdeps/mach/hurd/bits/types/struct___pthread_mutex.h: Likewise. * sysdeps/pthread/bits/pthreadtypes.h: Likewise. * sysdeps/pthread/bits/types/struct___pthread_mutex.h: Likewise.
2018-03-19Move bits/mutex.h to bits/types/struct___pthread_mutex.hSamuel Thibault
* sysdeps/mach/hurd/bits/mutex.h: Move file to... * sysdeps/mach/hurd/bits/types/struct___pthread_mutex.h: ... here. * sysdeps/pthread/bits/mutex.h: Move file to... * sysdeps/pthread/bits/types/struct___pthread_mutex.h: ... here. * Makefile (headers): Update accordingly. * sysdeps/generic/pthread.h: Likewise. * sysdeps/pthread/bits/pthreadtypes.h: Likewise.
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-18Remove __need_pthread_mutex / __pthread_mutex_definedSamuel Thibault
We do not actually use them. * sysdeps/mach/hurd/bits/mutex.h: Always include content. * sysdeps/pthread/bits/mutex.h: Always include content.
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-03-03Increase default thread stack to 8MiBSamuel Thibault
Linux' default is 8MiB and applications sometimes assume as much. * sysdeps/mach/hurd/pt-sysdep.h (PTHREAD_STACK_DEFAULT): Set macro to 8MiB.
2018-02-24Fix pthread_mutex_trylock return valueSamuel Thibault
* sysdeps/mach/hurd/pt-mutex-trylock.c (__pthread_mutex_trylock): Return EBUSY on failure instead of -1.
2018-01-27Fix warningSamuel Thibault
* sysdeps/mach/hurd/pt-sigstate-init.c: Include <hurd/signal.h>
2018-01-25Fix spurious whitespacesSamuel Thibault
2017-12-27Make pthread_mutex use gsyncAgustina Arzille
* Makefile (libpthread-routines): Add pt-mutexattr-getrobust pt-mutexattr-setrobust pt-mutex-consistent. * include/pthread/pthreadtypes.h (__pthread_mutex_robustness): New enum, containing __PTHREAD_MUTEX_STALLED, __PTHREAD_MUTEX_ROBUST. * include/pthread/pthread.h [__USE_XOPEN2K] (PTHREAD_MUTEX_STALLED, PTHREAD_MUTEX_ROBUST): New macros. [__USE_XOPEN2K8] (pthread_mutex_consistent, pthread_mutex_consistent_np): New declarations. * sysdeps/mach/hurd/bits/mutex.h sysdeps/mach/hurd/pt-mutex-consistent.c sysdeps/mach/hurd/pt-mutex-destroy.c sysdeps/mach/hurd/pt-mutex-getprioceiling.c sysdeps/mach/hurd/pt-mutex-init.c sysdeps/mach/hurd/pt-mutex-lock.c sysdeps/mach/hurd/pt-mutex-setprioceiling.c sysdeps/mach/hurd/pt-mutex-timedlock.c sysdeps/mach/hurd/pt-mutex-transfer-np.c sysdeps/mach/hurd/pt-mutex-trylock.c sysdeps/mach/hurd/pt-mutex-unlock.c sysdeps/mach/hurd/pt-mutex.h sysdeps/mach/hurd/pt-mutexattr-destroy.c sysdeps/mach/hurd/pt-mutexattr-getprioceiling.c sysdeps/mach/hurd/pt-mutexattr-getprotocol.c sysdeps/mach/hurd/pt-mutexattr-getpshared.c sysdeps/mach/hurd/pt-mutexattr-getrobust.c sysdeps/mach/hurd/pt-mutexattr-gettype.c sysdeps/mach/hurd/pt-mutexattr-init.c sysdeps/mach/hurd/pt-mutexattr-setprioceiling.c sysdeps/mach/hurd/pt-mutexattr-setprotocol.c sysdeps/mach/hurd/pt-mutexattr-setpshared.c sysdeps/mach/hurd/pt-mutexattr-setrobust.c sysdeps/mach/hurd/pt-mutexattr-settype.c sysdeps/mach/hurd/pt-mutexattr.c: New files
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-26Avoid exposing mach_port_set_qlimitSamuel Thibault
* sysdeps/mach/pt-thread-alloc.c (create_wakeupmsg): Call __mach_port_set_qlimit instead of mach_port_set_qlimit.
2016-09-20Fix warningSamuel Thibault
* sysdeps/mach/pt-thread-terminate.c (__pthread_thread_terminate): Cast stack address to vm_address_t before calling __thread_terminate_release.
2016-01-03Do not block unmaskable signalsglibc-2.19-hurd+libpthread-20160518Samuel Thibault
* sysdeps/mach/hurd/pt-sigstate.c (__pthread_sigstate): Always remove _SIG_CANT_MASK from blocked signals, like sigprocmask does.
2015-10-31Merge branch 'master' into master-glibcSamuel Thibault
2015-09-21Avoid exposing function prototype parameter namesSamuel Thibault
* include/pthread/pthread.h: Prepend '__' to parameter names. * sysdeps/mach/hurd/bits/pthread-np.h: Likewise.
2015-05-06Shuffle files for building with glibcSamuel Thibault
* configure: New file * include/libc-symbols.h: Remove file * include/set-hooks: Remove file * sysdeps/i386/bits/spin-lock-inline.h: Move to... * b/sysdeps/mach/i386/bits/spin-lock-inline.h: ... here. * sysdeps/i386/bits/spin-lock.h: Move to... * b/sysdeps/mach/i386/bits/spin-lock.h: ... here.
2015-05-06Wake up the message thread when pending signals have been unblockedSamuel Thibault
(code grabbed from glibc) * libpthread/sysdeps/mach/hurd/pt-sigstate.c: Include <hurd/msg.h> (__pthread_sigstate): Use _hurd_sigstate_lock/unlock instead of __pthread_spin_lock on `ss->lock'. Check _hurd_sigstate_pending and send a message to the signal thread if needed.
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-21Silence warningSamuel Thibault
* sysdeps/mach/hurd/pt-hurd-cond-timedwait.c (err): Initialize to 0.
2015-03-20Fix reference to ___pthread_initSamuel Thibault
* sysdeps/mach/hurd/pt-sysdep.c (_init_routine): Call ___pthread_init instead of __pthread_init.
2015-03-20Don't hardcode using __libc_stack_endSamuel Thibault
* sysdeps/mach/hurd/pt-sysdep.c (_init_routine): Use `stack' parameter instead of hardcoding __libc_stack_end.
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.
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-01-22Fix up the main thread TCBRichard Braun
Unlike other threads, the TCB of the main thread is created by the C library before libpthread is initialized and needs special care. * sysdeps/mach/hurd/i386/pt-setup.c (__pthread_setup): Set the `self' member of the main thread TCB.
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.
2014-01-02Revert "Fix glibc spinlock inclusion"Samuel Thibault
This reverts commit 414e0bbabb6ac7a5cff148b927ec874dff922be1. It's these versions which would end up being installed. Some other way needs to be found, or else we'll have to just duplicate or move the content.
2014-01-02Fix glibc spinlock inclusionSamuel Thibault
Using an i386 Implies would change inclusion order in the rest of libc too, entailing a lot of issues. We can simply make mach/i386 include i386 instead. * sysdeps/mach/i386/bits/spin-lock-inline.h: Include ../../../sysdeps/i386/bits/spin-lock-inline.h. * sysdeps/mach/i386/bits/spin-lock.h: Include ../../../sysdeps/i386/bits/spin-lock.h.
2014-01-01Revert "Add missing dependency to get i386 spinlocks"Samuel Thibault
This reverts commit 40376cfa5d8bd4814b29b777a7d0a6b2b6ed2a7c.
2014-01-01Add missing dependency to get i386 spinlocksSamuel Thibault
* sysdeps/mach/hurd/i386/Implies: Add i386.
2014-01-01Add compatibility with kernels without __thread_terminate_releaseSamuel Thibault
This would leak, but at least let the user reboot nicely into a newer kernel. * sysdeps/mach/pt-thread-terminate.c (__pthread_thread_terminate): If __thread_terminate_release returns, use __thread_terminate to terminate the thread anyway.
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-20Drop threadvars entirelySamuel Thibault
2013-10-20Use function parameter instead of global variableSamuel Thibault
* sysdeps/mach/pt-stack-alloc.c(__pthread_stack_alloc): Use `stacksize` parameter instead of `__pthread_stacksize` global variable.
2013-02-15Add pthread_hurd_cond_timedwait_npRichard Braun
This new Hurd-specific function is meant to allow Hurd servers to wait for events during a bounded period of time. * Makefile (libpthread-routines): Add pt-hurd-cond-timedwait. * Versions: Include pthread_hurd_cond_timedwait_np in version GLIBC_2.17 of libpthread. * sysdeps/mach/hurd/bits/pthread-np.h (pthread_hurd_cond_timedwait_np): New declaration. * sysdeps/mach/hurd/pt-hurd-cond-timedwait.c: New file that provides __pthread_hurd_cond_timedwait_internal and __pthread_hurd_cond_timedwait_np. * sysdeps/mach/hurd/pt-hurd-cond-wait.c (__pthread_hurd_cond_wait_np): Rewrite as a call to __pthread_hurd_cond_timedwait_internal with no timeout.
2013-02-04Fix pthread timeout handling and cancellation issuesRichard Braun
This patch solves two issues. The first one is cancellation handling when a cancellation request is sent before reaching a cancellation point (namely, pthread_cond_{timed,}wait). Cancellation is implemented by pushing an appropriate cleanup handler and switching to PTHREAD_CANCEL_ASYNCHRONOUS type. The main problem is that it doesn't handle pending requests, only a cancellation that occurs while blocking. Other problems occur when trying to correctly handle a timeout and a cancellation request through the cleanup routine. The other issue is correctly handling timeouts. This problem was already well known, as explained by the following comment : "FIXME: What do we do if we get a wakeup message before we disconnect ourself? It may remain until the next time we block." In addition, the prevp thread member is inconsistently used. It is sometimes accessed while protected by the appropriate queue lock to determine whether a thread is still queued, while at times, threads are unqueued without holding a lock, as in pthread_cond_broadcast : /* We can safely walk the list of waiting threads without holding the lock since it is now decoupled from the condition. */ __pthread_dequeuing_iterate (wakeup, wakeup) __pthread_wakeup (wakeup); This is the root cause that triggers some assertion failures. The solution brought by this patch is to consistently use the prevp link to determine if both a thread has been unqueued and if a wakeup message has been sent (both are needed to wake up a thread). A thread unblocked because of a timeout can now accurately determine if it needs to drain its message queue. A direct improvement is that the message queue size can be limited to one message, and wakeups are guaranteed to be non-blocking, which allows safely calling __pthread_wakeup from critical sections. As it now affects the cleanup cancellation routine of __pthread_cond_timedwait_internal, cancellation is reworked as well. Cancellation type is forced to PTHREAD_CANCEL_DEFERRED during the call, and actually checked on both entry and return. A hook is set by the blocking thread so that the waker doesn't need to know about the call implementation. Cancellation members are now protected with a mutex for truely safe access. * pthread/pt-alloc.c (initialize_pthread): Initialize the new `cancel_lock', `cancel_hook' and `cancel_hook_args' fields. * pthread/pt-cancel.c (pthread_cancel): Rework cancellation handling. * pthread/pt-internal.h (struct __pthread): Add `cancel_lock', `cancel_hook' and `cancel_hook_args' fields. (__pthread_dequeue): Assert thread->prevp isn't NULL. * pthread/pt-join.c (pthread_join): Describe how the cancellation point is implemented. * pthread/pt-setcancelstate.c (__pthread_setcancelstate): Lock the given thread cancellation lock when switching state. * pthread/pt-setcanceltype.c (__pthread_setcanceltype): Likewise for cancellation type. * pthread/pt-testcancel.c (pthread_testcancel): Likewise for pending cancellations. * sysdeps/generic/pt-cond-brdcast.c (__pthread_cond_broadcast): Dequeue and wake up threads with condition locked. * sysdeps/generic/pt-cond-signal.c (cond_signal): Remove function, move implementation to ... (__pthread_cond_signal): ... this function. Remove unused `unblocked' variable. * sysdeps/generic/pt-cond-timedwait.c (struct cancel_ctx): New structure. (cancel_hook): New static function. (__pthread_cond_timedwait_internal): Fix cancellation and timeout handling. * sysdeps/generic/pt-mutex-timedlock.c (__pthread_mutex_timedlock_internal): Fix timeout handling. * sysdeps/generic/pt-rwlock-timedrdlock.c (__pthread_rwlock_timedrdlock_internal): Likewise. * sysdeps/generic/pt-rwlock-timedwrlock.c (__pthread_rwlock_timedwrlock_internal): Likewise. * sysdeps/generic/pt-rwlock-unlock.c (pthread_rwlock_unlock): Dequeue and wake up threads with rwlock internal lock held. * sysdeps/generic/sem-timedwait.c (__sem_timedwait_internal): Fix timeout handling. * sysdeps/mach/hurd/pt-docancel.c (__pthread_do_cancel): Unlock the given thread cancellation lock. * sysdeps/mach/pt-thread-alloc.c (create_wakeupmsg): Limit the message queue size of the wakeup port to 1. * sysdeps/mach/pt-wakeup.c (__pthread_wakeup): Call __mach_msg in a non-blocking way.
2013-01-25Require the "pthread" sysdepPino Toscano
This allows the use of glibc sysdeps that use pthread-based implementations. * sysdeps/mach/hurd/Implies: Add pthread.
2012-11-25Allow applications to set the default stack sizeRichard Braun
This change is a temporary hack intended for the Hurd servers. Once Hurd threadvars are replaced with TLS, this commit should be reverted. * pthread/pt-internal.h (__pthread_default_attr): Remove const qualifier. * sysdeps/generic/pt-attr.c (__pthread_default_attr): Likewise. * sysdeps/mach/hurd/pt-sysdep.c (__pthread_stack_default_size): New variable. (init_routine): Set __pthread_default_attr.stacksize if __pthread_stack_default_size exists.
2012-11-25Add Hurd-specific condition wait functionRichard Braun
* Makefile (libpthread-routines): Add pt-hurd-cond-wait. * Versions (libc): Add pthread_hurd_cond_wait_np. (libpthread): Likewise. * sysdeps/mach/hurd/bits/pthread-np.h: New file. * sysdeps/mach/hurd/pt-hurd-cond-wait.c: Likewise.