delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:date:from:to:subject:message-id:reply-to | |
:references:mime-version:content-type:in-reply-to; q=dns; s= | |
default; b=LyYN8UwjVNTv1fhDlv529Q93P/1V1zqmIyDYWIrew5P1k5NB9xjg2 | |
LuZ3W0GTH4HKolMfHcu881Hi2CB7CsdzbrAgPIA9NWJ2vkLocQOzlsC0gGKJTDxB | |
/7JNuV3IsLVyt5NO2XAouTkPb39RtXD4lAjWN+k3d8C/s68OFrwujM= | |
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:date:from:to:subject:message-id:reply-to | |
:references:mime-version:content-type:in-reply-to; s=default; | |
bh=WXD15BBxIbicdxWENRNaGbXzGbo=; b=JCComd17qv1hb+enyNE3QwN87dI8 | |
EUOi2qjyDZmv3b8KFZ1tIk5HEx6clvEMkUuc6YTXDzJWSWm6sJRsyFdIDMCHMWBa | |
26uh7jcMOWF7TUMDIPKKgIOsBOai800w86AUq5xgRlKLUqDlkwjRuBHHAKYaIQEE | |
RaAmeOtbOggwt7M= | |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Authentication-Results: | sourceware.org; auth=none |
X-Spam-SWARE-Status: | No, score=-100.9 required=5.0 tests=BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= |
X-HELO: | mout.kundenserver.de |
Date: | Mon, 26 Nov 2018 17:46:57 +0100 |
From: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
To: | cygwin AT cygwin DOT com |
Subject: | Re: pthread_cond_timedwait with setclock(CLOCK_MONOTONIC) times out early |
Message-ID: | <20181126164657.GN30649@calimero.vinschen.de> |
Reply-To: | cygwin AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
References: | <CAOWZHxdTpDD6LLVctvjFQWqQMd9cex7pp-s1YYaMAdtGECy3Yw AT mail DOT gmail DOT com> <20181126153545 DOT GM30649 AT calimero DOT vinschen DOT de> <CAOWZHxdmOeQ7o6099PERwq-FbFbdYLLm43JfR5iQm-HtfP90aw AT mail DOT gmail DOT com> |
MIME-Version: | 1.0 |
In-Reply-To: | <CAOWZHxdmOeQ7o6099PERwq-FbFbdYLLm43JfR5iQm-HtfP90aw@mail.gmail.com> |
User-Agent: | Mutt/1.9.2 (2017-12-15) |
--Il7n/DHsA0sMLmDu Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Nov 26 10:47, James E. King III wrote: > On Mon, Nov 26, 2018 at 10:35 AM Corinna Vinschen > <corinna-cygwin AT cygwin DOT com> wrote: > > > > On Nov 25 09:01, James E. King III wrote: > > > I have isolated a problem in pthread_cond_timedwait when the condattr > > > is used to set the clock type to CLOCK_MONOTONIC. In this case even > > > though a target time point in the future is specified, the call > > > returns ETIMEDOUT but a subsequent call to > > > clock_gettime(CLOCK_MONOTONIC) shows the desired time point was not > > > reached. > > > > > > $ gcc timed_wait_short.c -o timed_wait_short > > > $ ./timed_wait_short.exe > > > [...] > > > begin: 521056s 671907500n > > > target: 521056s 721907500n > > > end: 521056s 721578000n > > > ok: false > > > > > > I have attached the source code. > > > > Thanks for the testcase. The problem is this: > > [...] > > At the moment I only have an *ugly* idea: We can always add the > > coarsest resolution of the wait functions (typically 15.625 ms) to the > > relative timeout value computed from the absolute timeout given to > > pthread_cond_timedwait. In my testing this is sufficient since the > > difference between target and actual end time is always < 15ms, in > > thousands of runs. > > > > Thoughts? > > > > > > Thanks, > > Corinna > > > > (*) https://docs.microsoft.com/en-us/windows/desktop/Sync/wait-function= s#wait-functions-and-time-out-intervals > > > > -- > > Corinna Vinschen > > Cygwin Maintainer >=20 > Some thoughts: >=20 > https://cygwin.com/git/gitweb.cgi?p=3Dnewlib-cygwin.git;a=3Dblob;f=3Dwins= up/cygwin/thread.cc;h=3D0bddaf345d255ae39187458dc6d02b1b4c8087c1;hb=3DHEAD#= l2546 >=20 > In pthread_convert_abstime, line 2564, care is taken to adjust for > rounding errors. > At line 2574, the rounding is not accounted for when adjusting for a > relative wait because it is a monotonic clock. > Wouldn't that rounding error cause it to wait less time? Au contraire: - The end time you're waiting for is rounded *up*. - The current time is rounded *down* - So end time - current time is always bigger than required on the 100ns level. Make sense? Corinna --=20 Corinna Vinschen Cygwin Maintainer --Il7n/DHsA0sMLmDu Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlv8I4EACgkQ9TYGna5E T6ALLQ//W/Xqu2ZW1cb78ST1/An2Let4agJ62IP3WTdmAF0d8bcsFwf5HW9HhBkE zHdYii47pXwKNjtSr4sybenBTmLNe7XmhX487GuQ7fpaB5Mlo2JhOomc3bPrDaSd N0kFXWtp0kIZTDbUQs6Oa1Zec3tHToEZnwcs9gvNxhZATIfNxMB6q6qFDIJm2SVo iflTSGI5XijATSwkMda2rkE+ShCHeLq1+7ryhOkg9YjFuACLYbMJOXnb3UBVyBAW pEmJdNoCTSAx371nbFr2AnZiUUoxXosXugI8kDy2KkRpp1HEjmppGjJJGr3IzvIO of8ZuxLzlWsa1PiPeCAAeteVagFz8vE38pzndbaKNtsyPX4RF3MrM5MXDcO9wSIl mTrm4zRGWqX54smVOpv/gHndvHcwSP/ybx1vMlSef1Y1BMwKKS6ftT7OykLxFfGM SEFWVyd4yIBJWSNdk3V3UYmZzuWZvaHavxjCQpvb2EN/YR4rDbH4rt+E90McQOe4 LHEo+DMOv6Gz80/AHhIHAH4RP6Ulyw5iKq7ealWJt/64tvwqQUGdEbvO4x4Sdgs1 ZX3rKHeXHgIQLVeT4dVNPldoFoe/g8uXkU9hTR4ZHM9F+S3cJW3vT4XeevQZU/CY Sav09Ewin10wBWNgWHOgXuJPqEsjOE1bFVhrn8LwSH4TCFRTI0M= =HIe0 -----END PGP SIGNATURE----- --Il7n/DHsA0sMLmDu--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |