mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Yonggang Luo <luoyonggang@gmail.com>
To: Jens Gustedt <jens.gustedt@inria.fr>, musl@lists.openwall.com
Cc: Yonggang Luo <luoyonggang@gmail.com>
Subject: [musl] [PATCH 0/4] Add posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait c2y/mtx_timedlock_monotonic c2y/cnd_timedwait_monotonic
Date: Tue, 20 Jun 2023 08:25:03 +0800	[thread overview]
Message-ID: <20230620002507.796-1-luoyonggang@gmail.com> (raw)

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.
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


             reply	other threads:[~2023-06-20  0:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-20  0:25 Yonggang Luo [this message]
2023-06-20  0:25 ` [musl] [PATCH 1/4] trim spaces of pthread_cond_timedwait.c and pthread_mutex_timedlock.c Yonggang Luo
2023-06-20  0:25 ` [musl] [PATCH 2/4] add pthread_mutex_clocklock and pthread_cond_clockdwait Yonggang Luo
2023-06-20  0:25 ` [musl] [PATCH 3/4] c23: Implement newly base for timespec_get Yonggang Luo
2023-06-20  7:06   ` [musl] " Jₑₙₛ Gustedt
2023-06-20  0:25 ` [musl] [PATCH 4/4] c2y: Add monotonic timed wait support for threads mtx cnd Yonggang Luo
2023-06-20  7:53   ` [musl] " 罗勇刚(Yonggang Luo)
2023-06-20  8:51     ` Jₑₙₛ Gustedt
2023-06-20 14:18 ` [musl] [PATCH 0/4] Add posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait c2y/mtx_timedlock_monotonic c2y/cnd_timedwait_monotonic enh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230620002507.796-1-luoyonggang@gmail.com \
    --to=luoyonggang@gmail.com \
    --cc=jens.gustedt@inria.fr \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).