mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "zhaohang (F)" <zhaohang14@huawei.com>
To: "musl@lists.openwall.com" <musl@lists.openwall.com>
Subject: 答复: [musl] src/thread/__timedwait.c: Clock type
Date: Wed, 15 May 2019 12:27:22 +0000	[thread overview]
Message-ID: <59FB1E003EF3A943BD6BAD197ABD4D6A272F65@dggemi524-mbx.china.huawei.com> (raw)
In-Reply-To: <20190513124124.GQ23599@brightrain.aerifal.cx>

Thank you Rich for the analysis.

Bests,
Zhao Hang

-----邮件原件-----
发件人: Rich Felker [mailto:dalias@aerifal.cx] 代表 Rich Felker
发送时间: 2019年5月13日 20:41
收件人: musl@lists.openwall.com
主题: Re: [musl] src/thread/__timedwait.c: Clock type

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-15 12:27 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
2019-05-15 12:27   ` zhaohang (F) [this message]

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=59FB1E003EF3A943BD6BAD197ABD4D6A272F65@dggemi524-mbx.china.huawei.com \
    --to=zhaohang14@huawei.com \
    --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).