mbox series

[0/5] c2y proposal add monotonicwait support for mtx and ctx

Message ID 20230619222052.682-1-luoyonggang@gmail.com
Headers show
Series c2y proposal add monotonicwait support for mtx and ctx | expand

Message

Yonggang Luo June 19, 2023, 10:20 p.m. UTC
Currently the c11 threads mtx and cnd only support for mtx_timedlock
and cnd_timedwait that use TIME_UTC, and it's not monotonic, for application
want monotonic wait/lock, then they can not use c11 threads,
So here I proposaled functions:
int mtx_timedlock_monotonic( mtx_t *restrict mutex,
                             const struct timespec *restrict time_point );
int cnd_timedwait_monotonic( cnd_t* restrict cond, mtx_t* restrict mutex,
                             const struct timespec* restrict time_point );

to support monotonic lock/wait for mtx/cnd .

Yonggang Luo (5):
  features: Rename __GLIBC_USE_ISOC2X to __GLIBC_USE_ISOC23
  time: Implement c23 timespec_get base
  clang-format: should format with 2 space and do not usage tab
  c11: Switch to use pthread_mutex_clocklock and pthread_cond_clockwait
    to implement cnd and mtx lock and wait
  c2y: Add function cnd_timedwait_monotonic and mtx_timedlock_monotonic

 .clang-format                                 |   4 +-
 conform/data/threads.h-data                   |   2 +
 include/features.h                            |   4 +-
 nptl/Versions                                 |   5 +
 sysdeps/pthread/Makefile                      |   2 +
 sysdeps/pthread/cnd_timedwait.c               |   8 +-
 ..._timedwait.c => cnd_timedwait_monotonic.c} |  58 +++++-----
 sysdeps/pthread/mtx_timedlock.c               |   6 +-
 ..._timedlock.c => mtx_timedlock_monotonic.c} |  56 +++++-----
 sysdeps/pthread/threads.h                     |  16 +++
 sysdeps/unix/sysv/linux/Versions              |   6 ++
 sysdeps/unix/sysv/linux/cnd_timedwait.c       |   4 +-
 ..._timedwait.c => cnd_timedwait_monotonic.c} |  18 ++--
 sysdeps/unix/sysv/linux/mtx_timedlock.c       |   4 +-
 ..._timedlock.c => mtx_timedlock_monotonic.c} | 100 +++++++++---------
 sysdeps/unix/sysv/linux/thrd_priv.h           |   8 ++
 time/time.h                                   |  13 +++
 time/timespec_get.c                           |  48 ++++++++-
 18 files changed, 228 insertions(+), 134 deletions(-)
 copy sysdeps/pthread/{cnd_timedwait.c => cnd_timedwait_monotonic.c} (70%)
 copy sysdeps/pthread/{mtx_timedlock.c => mtx_timedlock_monotonic.c} (75%)
 copy sysdeps/unix/sysv/linux/{cnd_timedwait.c => cnd_timedwait_monotonic.c} (68%)
 copy sysdeps/unix/sysv/linux/{mtx_timedlock.c => mtx_timedlock_monotonic.c} (59%)