This is the mail archive of the mailing list for the GCC 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 00/11] timed_mutex, shared_timed_mutex: Add full steady clock support

glibc v2.30 added the pthread_mutex_clocklock,
pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock
functions. These accept CLOCK_MONOTONIC, so they can be used to
implement proper steady_clock support in timed_mutex,
recursive_timed_mutex and shared_timed_mutex that is immune to the
system clock being warped.

Unfortunately we can't warp the system clock in the testsuite, so it's
not possible to automatically ensure that the system_clock test cases
result in a wait on CLOCK_REALTIME and steady_clock test cases result
in a wait on CLOCK_MONOTONIC. It's recommended to run the test under
strace(1) and check whether the expected futex calls are made by glibc
or ltrace(1) and check whether the expected pthread calls are
made. The easiest way to do this is to copy and paste the line used to
build the test from the output of running the tests (for example):

 make check-target-libstdc++-v3 RUNTESTFLAGS="conformance.exp=30_threads/shared_mutex/* -v -v"

to compile the test with only the tests for one clock enabled and then
run it as:

 strace -f ./1.exe

You should see calls to:


with large values of tv_sec when using system_clock and calls to:


Alternatively, you can use:

 ltrace -f ./1.exe

and look for calls to pthread_mutex_clocklock,
pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock with a
parameter of 1 for CLOCK_MONOTONIC and with values of tv_sec based on
the system uptime when using steady_clock.

This series also adds some extra tests and fixes some other minor
problems with the existing implementation and tests.

Mike Crowe (11):
  libstdc++ testsuite: Check return value from timed_mutex::try_lock_until
  libstdc++ testsuite: Add timed_mutex::try_lock_until test
  libstdc++ testsuite: Also test timed_mutex with steady_clock
  libstdc++ testsuite: Also test unique_lock::try_lock_until with steady_clock
  PR libstdc++/78237 Add full steady_clock support to timed_mutex
  libstdc++ testsuite: Move slow_clock to its own header
  PR libstdc++/91906 Fix timed_mutex::try_lock_until on arbitrary clock
  libstdc++ testsuite: Also test shared_timed_mutex with steady_clock
  libstdc++ shared_mutex: Add full steady_clock support to shared_timed_mutex
  libstdc++ timed_mutex: Ensure that try_lock_for waits for long enough
  shared_mutex: Fix try_lock_until and try_lock_shared_until on arbitrary clock

 libstdc++-v3/acinclude.m4                                                   |  64 +++++++++++++++++++++++++++-
 libstdc++-v3/                                                    |   7 +++-
 libstdc++-v3/configure                                                      | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 libstdc++-v3/                                                   |   6 +++-
 libstdc++-v3/include/std/mutex                                              |  60 +++++++++++++++++++++----
 libstdc++-v3/include/std/shared_mutex                                       | 117 +++++++++++++++++++++++++++++++++++++++++---------
 libstdc++-v3/testsuite/30_threads/condition_variable/members/           |  17 +-------
 libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/ |  76 ++++++++++++++++++++++++++++++++-
 libstdc++-v3/testsuite/30_threads/shared_mutex/try_lock_until/          |  87 +++++++++++++++++++++++++++++++++++++-
 libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock/          |  17 ++++---
 libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/           |  76 ++++++++++++++++++++++++++++++++-
 libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/       |  18 +++++---
 libstdc++-v3/testsuite/30_threads/unique_lock/locking/                  |  14 ++++--
 libstdc++-v3/testsuite/util/slow_clock.h                                    |  38 ++++++++++++++++-
 14 files changed, 707 insertions(+), 60 deletions(-)
 create mode 100644 libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/
 create mode 100644 libstdc++-v3/testsuite/30_threads/shared_mutex/try_lock_until/
 create mode 100644 libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/
 create mode 100644 libstdc++-v3/testsuite/util/slow_clock.h

base-commit: dcfd68ec29a6823f75a52c934fe408ce4b4b6919
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]