Fix semaphore destruction (bug 12674).

System Internals / glibc - Carlos O'Donell [systemhalted.org] - 20 January 2015 23:46 UTC

This commit fixes semaphore destruction by either using 64b atomic operations (where available), or by using two separate fields when only 32b atomic operations are available. In the latter case, we keep a conservative estimate of whether there are any waiting threads in one bit of the field that counts the number of available tokens, thus allowing sem_post to atomically both add a token and determine whether it needs to call futex_wake.

See: https://sourceware.org/ml/libc-alpha/2014-12/msg00155.html

042e152 Fix semaphore destruction (bug 12674).
ChangeLog | 52 +++
NEWS | 25 +-
nptl/DESIGN-sem.txt | 46 --
nptl/Makefile | 5 +-
nptl/sem_getvalue.c | 26 +-
nptl/sem_init.c | 35 +-
nptl/sem_open.c | 9 +-
nptl/sem_post.c | 67 ++-
nptl/sem_timedwait.c | 96 +----
nptl/sem_trywait.c | 50 ---
nptl/sem_wait.c | 101 ++---
nptl/sem_waitcommon.c | 467 +++++++++++++++++++++
nptl/structsem.sym | 12 -
nptl/tst-sem11.c | 9 +-
nptl/tst-sem13.c | 18 +-
sysdeps/nptl/internaltypes.h | 24 +-
sysdeps/unix/sysv/linux/alpha/sem_post.c | 5 -
sysdeps/unix/sysv/linux/i386/i486/sem_post.S | 150 -------
sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S | 327 ---------------
sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S | 67 ---
sysdeps/unix/sysv/linux/i386/i486/sem_wait.S | 343 ---------------
sysdeps/unix/sysv/linux/i386/i586/sem_post.S | 19 -
sysdeps/unix/sysv/linux/i386/i586/sem_timedwait.S | 19 -
sysdeps/unix/sysv/linux/i386/i586/sem_trywait.S | 19 -
sysdeps/unix/sysv/linux/i386/i586/sem_wait.S | 19 -
sysdeps/unix/sysv/linux/i386/i686/sem_post.S | 19 -
sysdeps/unix/sysv/linux/i386/i686/sem_timedwait.S | 19 -
sysdeps/unix/sysv/linux/i386/i686/sem_trywait.S | 19 -
sysdeps/unix/sysv/linux/i386/i686/sem_wait.S | 19 -
sysdeps/unix/sysv/linux/powerpc/sem_post.c | 71 ----
sysdeps/unix/sysv/linux/x86_64/sem_post.S | 75 ----
sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S | 380 -----------------
sysdeps/unix/sysv/linux/x86_64/sem_trywait.S | 47 ---
sysdeps/unix/sysv/linux/x86_64/sem_wait.S | 176 --------
34 files changed, 732 insertions(+), 2103 deletions(-)

Upstream: sourceware.org


  • Share