[PATCH v2 0/4] c2y proposal add monotonicwait support for mtx and ctx

Yonggang Luo luoyonggang@gmail.com
Tue Jun 20 17:17:27 GMT 2023


For c11 threads, the mtx and cnd doesn't support for monotonic timedlock and timedwait;
So add two proposal function mtx_timedlock_base cnd_timedwait_base to do that.
The protype of these two functions is:

int mtx_timedlock_base(mtx_t *restrict m, int time_base, const struct timespec *restrict ts);

int cnd_timedwait_base(cnd_t *restrict c, mtx_t *restrict m, int time_base, const struct timespec *restrict ts);

The time_base at least can be TIME_UTC/TIME_MONOTONIC, the implementer can implement it with any provided
TIME_* base parameter provided in c2y time.h, if TIME_MONOTONIC can not natively supported, fallback to TIME_UTC
should provided, for other TIME_* base parameter, it's implementer's choice.

Yonggang Luo (4):
  clang-format: should format with 2 space and do not usage tab
  time: Implement c23 timespec_get base
  c11: Switch to use pthread_mutex_clocklock and pthread_cond_clockwait
    to implement cnd and mtx lock and wait
  c2y: Add function cnd_timedwait_base and mtx_timedlock_base

 .clang-format                                 |   4 +-
 conform/data/threads.h-data                   |   2 +
 htl/Versions                                  |   5 +
 nptl/Versions                                 |   5 +
 sysdeps/pthread/Makefile                      |   2 +
 sysdeps/pthread/cnd_timedwait.c               |   8 +-
 .../{cnd_timedwait.c => cnd_timedwait_base.c} |  58 +++++-----
 sysdeps/pthread/mtx_timedlock.c               |   6 +-
 .../{mtx_timedlock.c => mtx_timedlock_base.c} |  56 +++++-----
 sysdeps/pthread/threads.h                     |  18 ++++
 sysdeps/unix/sysv/linux/Versions              |   6 ++
 sysdeps/unix/sysv/linux/cnd_timedwait.c       |   4 +-
 .../{cnd_timedwait.c => cnd_timedwait_base.c} |  24 +++--
 sysdeps/unix/sysv/linux/mtx_timedlock.c       |   4 +-
 .../{mtx_timedlock.c => mtx_timedlock_base.c} | 100 +++++++++---------
 sysdeps/unix/sysv/linux/thrd_priv.h           |  10 ++
 time/time.h                                   |  13 ++-
 time/timespec_get.c                           |  51 ++++++++-
 18 files changed, 240 insertions(+), 136 deletions(-)
 copy sysdeps/pthread/{cnd_timedwait.c => cnd_timedwait_base.c} (70%)
 copy sysdeps/pthread/{mtx_timedlock.c => mtx_timedlock_base.c} (75%)
 copy sysdeps/unix/sysv/linux/{cnd_timedwait.c => cnd_timedwait_base.c} (60%)
 copy sysdeps/unix/sysv/linux/{mtx_timedlock.c => mtx_timedlock_base.c} (60%)

-- 
2.39.0.windows.1



More information about the Libc-alpha mailing list