From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 2955 invoked from network); 20 Jun 2023 14:19:21 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 20 Jun 2023 14:19:21 -0000 Received: (qmail 1892 invoked by uid 550); 20 Jun 2023 14:19:18 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 1852 invoked from network); 20 Jun 2023 14:19:17 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687270745; x=1689862745; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=zZqaOvepJXM0gwf+V47N39kWa8JIBTHybFYGj2bSe6E=; b=EZ/Q85e1KFeToXWekcRsoNNXm9XHjL2cEpqtbzCnZ76SzrClRhpqMPANMZOxSZXugb 6C7boZJ45kra9wB2wVUuz67gajhpExHXvgCujevRjHG0Up0sPFfZMOwakOkB2Pi7LWwM gVGm83LtHMllsKCbKa7awu/FKwv06JbnfNqGWund1WMw8fn6TuG30JTzHql2zhhwSX20 bC65nCNZf3ewChOfrEm87J1D1f0nN6DOohLOmaDDxLaf8TNVdyLs2kGKJs49oCq0AnHO bF4nwSKc2/TK9bRsmSYqRu8yzwM3IccnANE2y61+pDMXybSLrBu4USOiy6L5zjAXSiJZ p+hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687270745; x=1689862745; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zZqaOvepJXM0gwf+V47N39kWa8JIBTHybFYGj2bSe6E=; b=ZH+EGlpTlolaU7KUUH+fm3IyXm21QdKtOHqrpaevQpuTG/ubKYuw4ipRa7zPynYUXn D8tohuq9/bWn666A/xg2j6QKjVqfNtYUZBCEs3zzPGaTcUmPF+0JNWQtfsNzuzWUMAed vf2LE1at1RlTkCa/+30s9ibIrZCX4CENEy9EIhyJBoggiRBe0yAeEWFM3ZJpGTsvU6fW LiYnfzdZ7ix6aRdKT4U/7vI0Cy1e+uC5XSUSHK12vmB5BSy9iINWcPWNIHraFoRq1mlA 5uuTcL17kDWQ2SCvSU1Qgjlk58jPWZ1ndTEzj7J8I8GWPdhxmztDjHn1Hm8rWxqV4iH6 5QZQ== X-Gm-Message-State: AC+VfDz9LlK5UYiNEkFk5dTiZA37ivIwEPaGYmyU7y3F2kEXSPXYC8da s23V5wzaNOTTqMivXLXLnEgXlNFMRRDlZrSJ3D1nBAOEN+nhnURJ8vA= X-Google-Smtp-Source: ACHHUZ6v1IPj5GkDn7FXQHckyCoa/YmXT9VOYIo4LY71/B8wSIpN71oCBl0TLd8xRNIBcayCcEMYObpSSUGV/VJznNY= X-Received: by 2002:a1f:4150:0:b0:471:af22:9a3a with SMTP id o77-20020a1f4150000000b00471af229a3amr3136342vka.5.1687270744592; Tue, 20 Jun 2023 07:19:04 -0700 (PDT) MIME-Version: 1.0 References: <20230620002507.796-1-luoyonggang@gmail.com> In-Reply-To: <20230620002507.796-1-luoyonggang@gmail.com> From: enh Date: Tue, 20 Jun 2023 07:18:53 -0700 Message-ID: To: musl@lists.openwall.com Cc: Jens Gustedt , Yonggang Luo Content-Type: multipart/alternative; boundary="0000000000005fa1aa05fe9055e4" Subject: Re: [musl] [PATCH 0/4] Add posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait c2y/mtx_timedlock_monotonic c2y/cnd_timedwait_monotonic --0000000000005fa1aa05fe9055e4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jun 19, 2023 at 5:25=E2=80=AFPM Yonggang Luo 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 =3D> cnd_timedwait_monotonic.c} | 28 ++++++------ > src/thread/mtx_timedlock.c | 2 +- > ..._timedlock.c =3D> 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 =3D> cnd_timedwait_monotonic.c} (52%) > copy src/thread/{mtx_timedlock.c =3D> 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 > > --0000000000005fa1aa05fe9055e4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Mon, Jun 19, 2023 at 5:25=E2=80=AF= PM Yonggang Luo <luoyonggang@gm= ail.com> wrote:
Currently, musl doesn't have pthread_mutex_clocklock pthread_con= d_clockdwait, but
glibc, android bionic, qnx libc already have these two functions, so implem= ent them in
musl.

And for c11 threads, the mtx and cnd doesn't support for monotonic time= dlock and timedwait,
so add a proposaled function mtx_timedlock_monotonic cnd_timedwait_monotoni= c to do that.

And indeed mtx_timedlock_monotonic and cnd_timedwait_monotonic can be imple= mented ontop of
posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait, so I implement= ed posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait
first in musl.

I think mtx_timedlock_monotonic cnd_timedwait_monotonic is reasonable becau= se 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 b= urden.

they _could_ be implemented, sur= e, but speaking as bionic's maintainer,=C2=A0i'd definitely object = to adding something so specific ... the whole reason with worked with the g= libc folks to get the new pthread functions with a clock parameter standard= ized was because we were sick of the random subset of functions working on= =C2=A0specific clocks, and wanted to just have the clock be a parameter.

if C wants to add equivalents to the pthread functio= ns, those functions should also take arguments that can be any of their TIM= E_* values rather than hard-coding clocks into function names.
= =C2=A0
For OS X it's can be implemented with pthread_cond_timedwait_relative_n= p
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):
=C2=A0 trim spaces of pthread_cond_timedwait.c and pthread_mutex_timedlock.= c
=C2=A0 add pthread_mutex_clocklock and pthread_cond_clockdwait
=C2=A0 c23: Implement newly base for timespec_get
=C2=A0 c2y: Add monotonic timed wait support for threads mtx cnd

=C2=A0.../time32/cnd_timedwait_monotonic_time32.c=C2=A0 =C2=A0|=C2=A0 9 +++= +
=C2=A0.../time32/mtx_timedlock_monotonic_time32.c=C2=A0 =C2=A0|=C2=A0 9 +++= +
=C2=A0compat/time32/pthread_cond_clockwait_time32.c |=C2=A0 9 ++++
=C2=A0.../time32/pthread_mutex_clocklock_time32.c=C2=A0 =C2=A0|=C2=A0 9 +++= +
=C2=A0compat/time32/time32.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 4 ++
=C2=A0include/pthread.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 4 ++
=C2=A0include/threads.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 4 ++
=C2=A0include/time.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 13 +++++-
=C2=A0src/include/pthread.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 2 +
=C2=A0src/thread/cnd_timedwait.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 2 +-
=C2=A0..._timedwait.c =3D> cnd_timedwait_monotonic.c} | 28 ++++++------<= br> =C2=A0src/thread/mtx_timedlock.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 2 +-
=C2=A0..._timedlock.c =3D> mtx_timedlock_monotonic.c} | 26 +++++------ =C2=A0src/thread/pthread_cond_clockwait.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0|=C2=A0 3 ++
=C2=A0src/thread/pthread_cond_timedwait.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0| 18 +++++---
=C2=A0src/thread/pthread_mutex_clocklock.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 |=C2=A0 3 ++
=C2=A0src/thread/pthread_mutex_timedlock.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 | 15 ++++---
=C2=A0src/time/timespec_get.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 44 ++++++++++++++++++-
=C2=A018 files changed, 161 insertions(+), 43 deletions(-)
=C2=A0create mode 100644 compat/time32/cnd_timedwait_monotonic_time32.c
=C2=A0create mode 100644 compat/time32/mtx_timedlock_monotonic_time32.c
=C2=A0create mode 100644 compat/time32/pthread_cond_clockwait_time32.c
=C2=A0create mode 100644 compat/time32/pthread_mutex_clocklock_time32.c
=C2=A0copy src/thread/{cnd_timedwait.c =3D> cnd_timedwait_monotonic.c} (= 52%)
=C2=A0copy src/thread/{mtx_timedlock.c =3D> mtx_timedlock_monotonic.c} (= 74%)
=C2=A0create mode 100644 src/thread/pthread_cond_clockwait.c
=C2=A0create mode 100644 src/thread/pthread_mutex_clocklock.c

--
2.39.0.windows.1

--0000000000005fa1aa05fe9055e4--