From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Cedric Ware <cedric.ware__bml@normalesup.org>
Cc: Bart Schaefer <schaefer@brasslantern.com>,
Daniel Shahaf <d.s@daniel.shahaf.name>,
Sebastian Gniazdowski <sgniazdowski@gmail.com>,
Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [BUG] zsystem:34: flock: invalid timeout value: '0'
Date: Sat, 27 Jun 2020 09:27:08 +0200 [thread overview]
Message-ID: <CAN=4vMpFpaQg03JbY_B3ktXAEmiUhXH4crdwyc1Ups8Cf=nf8A@mail.gmail.com> (raw)
In-Reply-To: <20200627071350.zqkdhzbk3mfej2tz@phare.normalesup.org>
On Sat, Jun 27, 2020 at 9:14 AM Cedric Ware
<cedric.ware__bml@normalesup.org> wrote:
>
> I didn't want to allow specifying a timeout below 1 microsecond,
> because that's the granularity of zsleep(). One could still allow it
> but silently treat it as 0.
Timeout strictly between 0 and 1 microsecond is not much different
from timeout between 1 and 2 microseconds. You can either round up or
down in both cases. Rounding up is the right thing to do for sleeps
and timeouts because it allows you to provide a guarantee.
For sleep (pseudo code):
time start = now();
if (sleep(duration) != INTERRUPTED)
assert(now - start() >= duration);
For anything with a timeout (pseudo code):
time start = now();
if (do_with_timeout(duration) == TIMEDOUT)
assert(now - start() >= duration);
If you round down, there is no non-trivial assertion that is
guaranteed to hold and that doesn't expose the internal granularity of
the duration.
Roman.
next prev parent reply other threads:[~2020-06-27 7:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-25 17:49 Sebastian Gniazdowski
2020-06-26 14:16 ` Daniel Shahaf
2020-06-26 19:42 ` Sebastian Gniazdowski
2020-06-27 1:47 ` Daniel Shahaf
2020-06-27 2:04 ` Bart Schaefer
2020-06-27 7:13 ` Cedric Ware
2020-06-27 7:27 ` Roman Perepelitsa [this message]
2020-06-27 17:01 ` Bart Schaefer
2020-06-27 17:12 ` Roman Perepelitsa
2020-06-27 17:58 ` Bart Schaefer
2020-06-27 18:09 ` Roman Perepelitsa
2020-06-27 20:38 ` Cedric Ware
2020-06-28 9:27 ` Roman Perepelitsa
2020-07-10 15:28 ` Sebastian Gniazdowski
2020-07-11 5:18 ` dana
2020-06-27 17:25 ` Sebastian Gniazdowski
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='CAN=4vMpFpaQg03JbY_B3ktXAEmiUhXH4crdwyc1Ups8Cf=nf8A@mail.gmail.com' \
--to=roman.perepelitsa@gmail.com \
--cc=cedric.ware__bml@normalesup.org \
--cc=d.s@daniel.shahaf.name \
--cc=schaefer@brasslantern.com \
--cc=sgniazdowski@gmail.com \
--cc=zsh-workers@zsh.org \
/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/zsh/
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).