mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: src/thread/__timedwait.c: Clock type
Date: Mon, 13 May 2019 08:41:24 -0400	[thread overview]
Message-ID: <20190513124124.GQ23599@brightrain.aerifal.cx> (raw)
In-Reply-To: <59FB1E003EF3A943BD6BAD197ABD4D6A272CE7@dggemi524-mbx.china.huawei.com>

On Mon, May 13, 2019 at 01:36:15AM +0000, zhaohang (F) wrote:
> In the function _timedwait_cp, 'clk' indicates the type of clock used, CLOCK_REALTIME or CLOCK_MONOTONIC.
> 
> when we call __syscall_cp in this function, the fifth parameter 'top' is calculated based on the clock type.
> 
> However, the third parameter is not set according to the clock type. CLOCK_MONOTONIC is used by default.
> 
> Is this a bug? Or other considerations?

The timeout argument to the FUTEX_WAIT operation is always relative,
and does not support choosing a clock. To support the more exotic
clocks (e.g. cputime for a given thread) it would need explicit
support here, but for just realtime and monotonic, it suffices to
compute the relative sleep based on the argument and the current time
in the given clock.

The behavior is of course different under non-continuous changes to
the clock. This is a fundamental limitation of the FUTEX_WAIT
operation; using the FUTEX_WAIT_BITSET operation if available would
avoid this, but seems less likely to be able to support arbitrary
other clocks in the future, and the behavior distinction only appears
when you do something fundamentally broken (setting the clock wrong)
and half the time it's worse rather than better...

Rich


  reply	other threads:[~2019-05-13 12:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-13  1:36 zhaohang (F)
2019-05-13 12:41 ` Rich Felker [this message]
2019-05-15 12:27   ` 答复: [musl] " zhaohang (F)

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=20190513124124.GQ23599@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --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).