Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 13 May 2019 08:41:24 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: 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

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.