From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14123 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: src/thread/__timedwait.c: Clock type Date: Mon, 13 May 2019 08:41:24 -0400 Message-ID: <20190513124124.GQ23599@brightrain.aerifal.cx> References: <59FB1E003EF3A943BD6BAD197ABD4D6A272CE7@dggemi524-mbx.china.huawei.com> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="98227"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-14139-gllmg-musl=m.gmane.org@lists.openwall.com Mon May 13 14:41:40 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1hQAGy-000PPh-Bs for gllmg-musl@m.gmane.org; Mon, 13 May 2019 14:41:40 +0200 Original-Received: (qmail 15555 invoked by uid 550); 13 May 2019 12:41:37 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 15533 invoked from network); 13 May 2019 12:41:37 -0000 Content-Disposition: inline In-Reply-To: <59FB1E003EF3A943BD6BAD197ABD4D6A272CE7@dggemi524-mbx.china.huawei.com> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:14123 Archived-At: 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