musl/src/thread
Rich Felker feee98903c overhaul pthread cancellation
this patch improves the correctness, simplicity, and size of
cancellation-related code. modulo any small errors, it should now be
completely conformant, safe, and resource-leak free.

the notion of entering and exiting cancellation-point context has been
completely eliminated and replaced with alternative syscall assembly
code for cancellable syscalls. the assembly is responsible for setting
up execution context information (stack pointer and address of the
syscall instruction) which the cancellation signal handler can use to
determine whether the interrupted code was in a cancellable state.

these changes eliminate race conditions in the previous generation of
cancellation handling code (whereby a cancellation request received
just prior to the syscall would not be processed, leaving the syscall
to block, potentially indefinitely), and remedy an issue where
non-cancellable syscalls made from signal handlers became cancellable
if the signal handler interrupted a cancellation point.

x86_64 asm is untested and may need a second try to get it right.
2011-04-17 11:43:03 -04:00
..
i386 overhaul pthread cancellation 2011-04-17 11:43:03 -04:00
x86_64 overhaul pthread cancellation 2011-04-17 11:43:03 -04:00
__futex.c global cleanup to use the new syscall interface 2011-03-20 00:16:43 -04:00
__lock.c consistency: change all remaining syscalls to use SYS_ rather than __NR_ prefix 2011-04-06 20:32:53 -04:00
__rsyscall.c fixed crash in new rsyscall (failure to set sa_flags for signal handler) 2011-04-06 20:43:39 -04:00
__set_thread_area.c finish unifying thread register handling in preparation for porting 2011-02-15 03:56:52 -05:00
__timedwait.c overhaul pthread cancellation 2011-04-17 11:43:03 -04:00
__timedwait_cp.c overhaul pthread cancellation 2011-04-17 11:43:03 -04:00
__unmapself.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
__wait.c consistency: change all remaining syscalls to use SYS_ rather than __NR_ prefix 2011-04-06 20:32:53 -04:00
__wake.c consistency: change all remaining syscalls to use SYS_ rather than __NR_ prefix 2011-04-06 20:32:53 -04:00
cancel_dummy.c overhaul pthread cancellation 2011-04-17 11:43:03 -04:00
cancel_impl.c overhaul pthread cancellation 2011-04-17 11:43:03 -04:00
cancellation.c match glibc/lsb cancellation abi on i386 2011-03-25 22:13:57 -04:00
cancellation2.c match glibc/lsb cancellation abi on i386 2011-03-25 22:13:57 -04:00
cancellation3.c match glibc/lsb cancellation abi on i386 2011-03-25 22:13:57 -04:00
clone.c finish unifying thread register handling in preparation for porting 2011-02-15 03:56:52 -05:00
pthread_atfork.c add pthread_atfork interface 2011-02-18 19:52:42 -05:00
pthread_attr_destroy.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
pthread_attr_getdetachstate.c fix pthread_attr_* implementations to match corrected prototypes 2011-03-11 09:51:14 -05:00
pthread_attr_getguardsize.c fix pthread_attr_* implementations to match corrected prototypes 2011-03-11 09:51:14 -05:00
pthread_attr_getschedparam.c implement dummy pthread_attr_[gs]etschedparam functions 2011-03-11 09:51:54 -05:00
pthread_attr_getscope.c fix pthread_attr_* implementations to match corrected prototypes 2011-03-11 09:51:14 -05:00
pthread_attr_getstacksize.c fix pthread_attr_* implementations to match corrected prototypes 2011-03-11 09:51:14 -05:00
pthread_attr_init.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
pthread_attr_setdetachstate.c reject invalid attribute settings 2011-03-07 15:46:37 -05:00
pthread_attr_setguardsize.c reorganize pthread data structures and move the definitions to alltypes.h 2011-02-17 17:16:20 -05:00
pthread_attr_setschedparam.c implement dummy pthread_attr_[gs]etschedparam functions 2011-03-11 09:51:54 -05:00
pthread_attr_setscope.c reject invalid attribute settings 2011-03-07 15:46:37 -05:00
pthread_attr_setstacksize.c enforce stack size min in pthread_attr_setstacksize 2011-03-04 00:59:14 -05:00
pthread_barrier_destroy.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
pthread_barrier_init.c reorganize pthread data structures and move the definitions to alltypes.h 2011-02-17 17:16:20 -05:00
pthread_barrier_wait.c reorganize pthread data structures and move the definitions to alltypes.h 2011-02-17 17:16:20 -05:00
pthread_barrierattr_destroy.c implement barrier attribute functions (essentially no-ops) 2011-03-07 15:42:52 -05:00
pthread_barrierattr_getpshared.c implement barrier attribute functions (essentially no-ops) 2011-03-07 15:42:52 -05:00
pthread_barrierattr_init.c implement barrier attribute functions (essentially no-ops) 2011-03-07 15:42:52 -05:00
pthread_barrierattr_setpshared.c implement barrier attribute functions (essentially no-ops) 2011-03-07 15:42:52 -05:00
pthread_cond_broadcast.c reorganize pthread data structures and move the definitions to alltypes.h 2011-02-17 17:16:20 -05:00
pthread_cond_destroy.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
pthread_cond_init.c use the selected clock from the condattr for pthread_cond_timedwait 2011-03-07 17:39:13 -05:00
pthread_cond_signal.c reorganize pthread data structures and move the definitions to alltypes.h 2011-02-17 17:16:20 -05:00
pthread_cond_timedwait.c overhaul pthread cancellation 2011-04-17 11:43:03 -04:00
pthread_cond_wait.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
pthread_condattr_destroy.c implement pthread_condattr_* interfaces 2011-03-07 16:20:12 -05:00
pthread_condattr_getclock.c implement pthread_condattr_* interfaces 2011-03-07 16:20:12 -05:00
pthread_condattr_getpshared.c implement pthread_condattr_* interfaces 2011-03-07 16:20:12 -05:00
pthread_condattr_init.c implement pthread_condattr_* interfaces 2011-03-07 16:20:12 -05:00
pthread_condattr_setclock.c disallow cpu time clocks as condattr clock values 2011-03-08 02:32:42 -05:00
pthread_condattr_setpshared.c implement pthread_condattr_* interfaces 2011-03-07 16:20:12 -05:00
pthread_create.c overhaul pthread cancellation 2011-04-17 11:43:03 -04:00
pthread_detach.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
pthread_equal.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
pthread_getspecific.c optimize POSIX TSD for fast pthread_getspecific 2011-03-03 18:30:44 -05:00
pthread_join.c overhaul pthread cancellation 2011-04-17 11:43:03 -04:00
pthread_key_create.c simplify pthread tsd key handling 2011-04-03 02:40:18 -04:00
pthread_kill.c consistency: change all remaining syscalls to use SYS_ rather than __NR_ prefix 2011-04-06 20:32:53 -04:00
pthread_mutex_consistent.c implement robust mutexes 2011-03-17 20:41:37 -04:00
pthread_mutex_destroy.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
pthread_mutex_init.c implement robust mutexes 2011-03-17 20:41:37 -04:00
pthread_mutex_lock.c cheap trick to further optimize locking normal mutexes 2011-04-14 14:39:57 -04:00
pthread_mutex_timedlock.c implement robust mutexes 2011-03-17 20:41:37 -04:00
pthread_mutex_trylock.c cheap trick to further optimize locking normal mutexes 2011-04-14 14:39:57 -04:00
pthread_mutex_unlock.c avoid crash on stupid but allowable usage of pthread_mutex_unlock 2011-03-30 10:32:45 -04:00
pthread_mutexattr_destroy.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
pthread_mutexattr_getpshared.c implement pthread_mutexattr_[gs]etpshared functions 2011-03-08 02:33:37 -05:00
pthread_mutexattr_getrobust.c implement robust mutexes 2011-03-17 20:41:37 -04:00
pthread_mutexattr_gettype.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
pthread_mutexattr_init.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
pthread_mutexattr_setpshared.c implement pthread_mutexattr_[gs]etpshared functions 2011-03-08 02:33:37 -05:00
pthread_mutexattr_setrobust.c implement robust mutexes 2011-03-17 20:41:37 -04:00
pthread_mutexattr_settype.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
pthread_once.c fix major breakage in pthread_once (it was always deadlocking) 2011-03-08 12:08:40 -05:00
pthread_rwlock_destroy.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
pthread_rwlock_init.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
pthread_rwlock_rdlock.c reorganize pthread data structures and move the definitions to alltypes.h 2011-02-17 17:16:20 -05:00
pthread_rwlock_timedrdlock.c reorganize pthread data structures and move the definitions to alltypes.h 2011-02-17 17:16:20 -05:00
pthread_rwlock_timedwrlock.c reorganize pthread data structures and move the definitions to alltypes.h 2011-02-17 17:16:20 -05:00
pthread_rwlock_tryrdlock.c rwlock trylock functions were wrongly returning EAGAIN instead of EBUSY 2011-03-08 12:19:30 -05:00
pthread_rwlock_trywrlock.c rwlock trylock functions were wrongly returning EAGAIN instead of EBUSY 2011-03-08 12:19:30 -05:00
pthread_rwlock_unlock.c reorganize pthread data structures and move the definitions to alltypes.h 2011-02-17 17:16:20 -05:00
pthread_rwlock_wrlock.c reorganize pthread data structures and move the definitions to alltypes.h 2011-02-17 17:16:20 -05:00
pthread_rwlockattr_destroy.c implement pthread_rwlockattr_* (essentially no-ops) 2011-03-07 16:43:25 -05:00
pthread_rwlockattr_getpshared.c implement pthread_rwlockattr_* (essentially no-ops) 2011-03-07 16:43:25 -05:00
pthread_rwlockattr_init.c implement pthread_rwlockattr_* (essentially no-ops) 2011-03-07 16:43:25 -05:00
pthread_rwlockattr_setpshared.c implement pthread_rwlockattr_* (essentially no-ops) 2011-03-07 16:43:25 -05:00
pthread_self.c use bss instead of mmap for main thread's pthread thread-specific data 2011-04-01 22:07:59 -04:00
pthread_setcancelstate.c simplify cancellation point handling 2011-04-13 20:47:01 -04:00
pthread_setcanceltype.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
pthread_setspecific.c optimize POSIX TSD for fast pthread_getspecific 2011-03-03 18:30:44 -05:00
pthread_sigmask.c fix error handling for pthread_sigmask 2011-03-09 20:31:06 -05:00
pthread_spin_destroy.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
pthread_spin_init.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
pthread_spin_lock.c revert some more spin optimizations that turned out to be pessimizations 2011-03-28 22:36:55 -04:00
pthread_spin_trylock.c revert some more spin optimizations that turned out to be pessimizations 2011-03-28 22:36:55 -04:00
pthread_spin_unlock.c prepare pthread_spin_unlock for archs that need memory barriers 2011-03-24 23:06:48 -04:00
pthread_testcancel.c overhaul pthread cancellation 2011-04-17 11:43:03 -04:00
sem_destroy.c implement POSIX semaphores 2011-03-04 00:45:59 -05:00
sem_getvalue.c implement POSIX semaphores 2011-03-04 00:45:59 -05:00
sem_init.c implement POSIX semaphores 2011-03-04 00:45:59 -05:00
sem_open.c fix failure behavior of sem_open when sem does not exist 2011-03-10 22:05:16 -05:00
sem_post.c major semaphore improvements (performance and correctness) 2011-04-06 12:24:34 -04:00
sem_timedwait.c overhaul pthread cancellation 2011-04-17 11:43:03 -04:00
sem_trywait.c change sem_trywait algorithm so it never has to call __wake 2011-04-14 15:10:50 -04:00
sem_unlink.c implement POSIX semaphores 2011-03-04 00:45:59 -05:00
sem_wait.c implement POSIX semaphores 2011-03-04 00:45:59 -05:00
syscall_cp.c overhaul pthread cancellation 2011-04-17 11:43:03 -04:00