This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v2 0/6] My attempts[1] to add a variant of pthread_cond_timedwait that would accept


a clockid_t parameter led me to propose[2] to The Austin Group the addition
of an entire family of functions that accept a clockid_t parameter to
indicate the clock that the timespec absolute timeout parameter should be
measured against. They responded positively to the request but an
implementation is required before the proposal can proceed.

This patch series is the second version of the first part of that
implementation in glibc, it contains implementations and tests for
four new functions:

int pthread_cond_clockwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
                           clockid_t clock, const struct timespec *abstime)

int pthread_rwlock_clockrdlock(pthread_rwlock_t *rwlock, clockid_t clock,
                               const struct timespec *abstime)

int pthread_rwlock_clockwrlock(pthread_rwlock_t *rwlock, clockid_t clock,
                               const struct timespec *abstime)

int sem_clockwait(sem_t *restrict, clockid_t clock_id, const struct
                  timespec *restrict)

These are implemented by replacing the underlying equivalent _timed
functions with ones that accept a clockid_t parameter, and then
implementing the existing _timed functions by passing CLOCK_REALTIME to the
new implementation. This requires clockid_t parameters to be added to the
underlying futex-internal and lowlevellock-futex functions.

pthread_mutex_clocklock is next on the list to be implemented, but it
will require Adhemerval Zanella's changes in
https://sourceware.org/ml/libc-alpha/2019-02/msg00569.html to land
first.

glibc-specific functions, such as pthread_timedjoin_np are next on the
list.

The mq_clockreceive and mq_clocksend functions corresponding to
mq_timedreceive and mq_timedsend require kernel changes before they can be
implemented in glibc.

As implemented, passing an unsupported or invalid clock to these functions
yields EINVAL. I considered returning ENOTSUP for valid-but-unsupported
clocks, but I was worried that there was a risk that the list of valid
clocks would not be updated when a new clock was added to glibc.

Rather than duplicating tests, I've parameterised them so that the same
tests can be run on the existing timedwait functions and the new clockwait
functions.

The changes have been tested with "make check" and "make check-abi" on
x86, x86_64, arm and arm64. I've attempted to update the abilists for
all architectures, but cannot test all of them.

This series builds upon my previous series to migrate varios nptl
tests to use libsupport[3]. This series has not yet landed.

Thanks to everyone that commented on previous versions of this patch
series. They have been a great help, and I hope that I have
incorporated their feedback correctly.

Adhemerval Zanella suggested that timespec validity checks could be
consolidated. I think that's a good idea, but it would need to be a
different change. This series doesn't really make that change any
harder to do, and I can try to tackle that separately.

Adhemerval Zanella also suggested that
futex_supports_exact_relative_timeouts could be removed. I agree, but
that would also need to be a separate change.

Changes since v1[4]:
* Many whitespace/formatting cleanups
* Rebase on top of tests that use libsupport
* Use futex_abstimed_supported_clockid in __pthread_cond_clockwait.
* Update all abilists.
* Add to NEWS.

[1] https://sourceware.org/ml/libc-alpha/2015-07/msg00193.html
[2] http://austingroupbugs.net/view.php?id=1216
[3] https://sourceware.org/ml/libc-alpha/2019-05/msg00031.html
[4] https://sourceware.org/ml/libc-alpha/2019-02/msg00637.html

Mike Crowe (6):
  nptl: Add clockid parameter to futex timed wait calls
  nptl: Add POSIX-proposed sem_clockwait
  nptl: Add POSIX-proposed pthread_cond_clockwait
  nptl: pthread_rwlock: Move timeout validation into _full functions
  nptl: Add POSIX-proposed pthread_rwlock_clockrdlock & pthread_rwlock_clockwrlock
  Update NEWS for new _clockwait functions

 ChangeLog                                                       | 332 +++++++-
 NEWS                                                            |   6 +-
 manual/threads.texi                                             |  58 +-
 nptl/Makefile                                                   |   8 +-
 nptl/Versions                                                   |   5 +-
 nptl/forward.c                                                  |   5 +-
 nptl/nptl-init.c                                                |   1 +-
 nptl/pthreadP.h                                                 |   4 +-
 nptl/pthread_cond_wait.c                                        |  68 +-
 nptl/pthread_mutex_timedlock.c                                  |   4 +-
 nptl/pthread_rwlock_clockrdlock.c                               |  29 +-
 nptl/pthread_rwlock_clockwrlock.c                               |  29 +-
 nptl/pthread_rwlock_common.c                                    |  32 +-
 nptl/pthread_rwlock_rdlock.c                                    |   2 +-
 nptl/pthread_rwlock_timedrdlock.c                               |  12 +-
 nptl/pthread_rwlock_timedwrlock.c                               |  12 +-
 nptl/pthread_rwlock_wrlock.c                                    |   2 +-
 nptl/sem_clockwait.c                                            |  45 +-
 nptl/sem_timedwait.c                                            |   3 +-
 nptl/sem_wait.c                                                 |   3 +-
 nptl/sem_waitcommon.c                                           |  15 +-
 nptl/tst-abstime.c                                              |   8 +-
 nptl/tst-cond11.c                                               |  37 +-
 nptl/tst-cond26.c                                               |  77 ++-
 nptl/tst-cond27.c                                               |  68 +-
 nptl/tst-rwlock14.c                                             |  12 +-
 nptl/tst-rwlock6.c                                              |  94 +-
 nptl/tst-rwlock7.c                                              |  83 +-
 nptl/tst-rwlock9.c                                              | 102 +-
 nptl/tst-sem13.c                                                |  39 +-
 nptl/tst-sem17.c                                                |  76 ++-
 nptl/tst-sem5.c                                                 |  23 +-
 sysdeps/mach/hurd/i386/libpthread.abilist                       |   4 +-
 sysdeps/nptl/futex-internal.h                                   |   7 +-
 sysdeps/nptl/lowlevellock-futex.h                               |  13 +-
 sysdeps/nptl/pthread-functions.h                                |   4 +-
 sysdeps/nptl/pthread.h                                          |  29 +-
 sysdeps/pthread/semaphore.h                                     |   7 +-
 sysdeps/unix/sysv/linux/aarch64/libpthread.abilist              |   4 +-
 sysdeps/unix/sysv/linux/alpha/libpthread.abilist                |   4 +-
 sysdeps/unix/sysv/linux/arm/libpthread.abilist                  |   4 +-
 sysdeps/unix/sysv/linux/csky/libpthread.abilist                 |   4 +-
 sysdeps/unix/sysv/linux/futex-internal.h                        |  26 +-
 sysdeps/unix/sysv/linux/hppa/libpthread.abilist                 |   4 +-
 sysdeps/unix/sysv/linux/i386/libpthread.abilist                 |   4 +-
 sysdeps/unix/sysv/linux/ia64/libpthread.abilist                 |   4 +-
 sysdeps/unix/sysv/linux/lowlevellock-futex.h                    |  33 +-
 sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist        |   4 +-
 sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist          |   4 +-
 sysdeps/unix/sysv/linux/microblaze/libpthread.abilist           |   4 +-
 sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist          |   4 +-
 sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist          |   4 +-
 sysdeps/unix/sysv/linux/nios2/libpthread.abilist                |   4 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist    |   4 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist |   4 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist |   4 +-
 sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist           |   4 +-
 sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist         |   4 +-
 sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist         |   4 +-
 sysdeps/unix/sysv/linux/sh/libpthread.abilist                   |   4 +-
 sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist        |   4 +-
 sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist        |   4 +-
 sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist            |   4 +-
 sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist           |   4 +-
 64 files changed, 1330 insertions(+), 183 deletions(-)
 create mode 100644 nptl/pthread_rwlock_clockrdlock.c
 create mode 100644 nptl/pthread_rwlock_clockwrlock.c
 create mode 100644 nptl/sem_clockwait.c
 create mode 100644 nptl/tst-cond26.c
 create mode 100644 nptl/tst-cond27.c
 create mode 100644 nptl/tst-sem17.c

base-commit: 56727e885902a96b7cd883b6cceab9a7455d5b6c
-- 
git-series 0.9.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]