Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJgzZopBKRZAtMZndbcAK5VF7NV+NgrW8Hds_bzzhnc-WQsaEw@mail.gmail.com>
Date: Tue, 20 Jun 2023 07:18:53 -0700
From: enh <enh@...gle.com>
To: musl@...ts.openwall.com
Cc: Jens Gustedt <jens.gustedt@...ia.fr>, Yonggang Luo <luoyonggang@...il.com>
Subject: Re: [PATCH 0/4] Add posix/pthread_mutex_clocklock
 posix/pthread_cond_clockdwait c2y/mtx_timedlock_monotonic c2y/cnd_timedwait_monotonic

On Mon, Jun 19, 2023 at 5:25 PM Yonggang Luo <luoyonggang@...il.com> wrote:

> Currently, musl doesn't have pthread_mutex_clocklock
> pthread_cond_clockdwait, but
> glibc, android bionic, qnx libc already have these two functions, so
> implement them in
> musl.
>
> And for c11 threads, the mtx and cnd doesn't support for monotonic
> timedlock and timedwait,
> so add a proposaled function mtx_timedlock_monotonic
> cnd_timedwait_monotonic to do that.
>
> And indeed mtx_timedlock_monotonic and cnd_timedwait_monotonic can be
> implemented ontop of
> posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait, so I
> implemented posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait
> first in musl.
>
> I think mtx_timedlock_monotonic cnd_timedwait_monotonic is reasonable
> because it's newly added
> function and won't affect existing c11 threads functions.
> And it's can be implementd with glibc/qnx libc/android bionic without
> burden.
>

they _could_ be implemented, sure, but speaking as bionic's maintainer, i'd
definitely object to adding something so specific ... the whole reason with
worked with the glibc folks to get the new pthread functions with a clock
parameter standardized was because we were sick of the random subset of
functions working on specific clocks, and wanted to just have the clock be
a parameter.

if C wants to add equivalents to the pthread functions, those functions
should also take arguments that can be any of their TIME_* values rather
than hard-coding clocks into function names.


> For OS X it's can be implemented with pthread_cond_timedwait_relative_np
> For Windows it's can be implemented with SleepConditionVariableCS
> For platform have none of these, it's still can fallback to TIME_UTC
>
> When these
>
> Yonggang Luo (4):
>   trim spaces of pthread_cond_timedwait.c and pthread_mutex_timedlock.c
>   add pthread_mutex_clocklock and pthread_cond_clockdwait
>   c23: Implement newly base for timespec_get
>   c2y: Add monotonic timed wait support for threads mtx cnd
>
>  .../time32/cnd_timedwait_monotonic_time32.c   |  9 ++++
>  .../time32/mtx_timedlock_monotonic_time32.c   |  9 ++++
>  compat/time32/pthread_cond_clockwait_time32.c |  9 ++++
>  .../time32/pthread_mutex_clocklock_time32.c   |  9 ++++
>  compat/time32/time32.h                        |  4 ++
>  include/pthread.h                             |  4 ++
>  include/threads.h                             |  4 ++
>  include/time.h                                | 13 +++++-
>  src/include/pthread.h                         |  2 +
>  src/thread/cnd_timedwait.c                    |  2 +-
>  ..._timedwait.c => cnd_timedwait_monotonic.c} | 28 ++++++------
>  src/thread/mtx_timedlock.c                    |  2 +-
>  ..._timedlock.c => mtx_timedlock_monotonic.c} | 26 +++++------
>  src/thread/pthread_cond_clockwait.c           |  3 ++
>  src/thread/pthread_cond_timedwait.c           | 18 +++++---
>  src/thread/pthread_mutex_clocklock.c          |  3 ++
>  src/thread/pthread_mutex_timedlock.c          | 15 ++++---
>  src/time/timespec_get.c                       | 44 ++++++++++++++++++-
>  18 files changed, 161 insertions(+), 43 deletions(-)
>  create mode 100644 compat/time32/cnd_timedwait_monotonic_time32.c
>  create mode 100644 compat/time32/mtx_timedlock_monotonic_time32.c
>  create mode 100644 compat/time32/pthread_cond_clockwait_time32.c
>  create mode 100644 compat/time32/pthread_mutex_clocklock_time32.c
>  copy src/thread/{cnd_timedwait.c => cnd_timedwait_monotonic.c} (52%)
>  copy src/thread/{mtx_timedlock.c => mtx_timedlock_monotonic.c} (74%)
>  create mode 100644 src/thread/pthread_cond_clockwait.c
>  create mode 100644 src/thread/pthread_mutex_clocklock.c
>
> --
> 2.39.0.windows.1
>
>

Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.