From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Use nanosleep(2) in pg_usleep, if available?
Date: Tue, 12 Mar 2019 13:13:42 -0400
Message-ID: <9173.1552410822@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+TgmobkuSFwu9yvL5UxPrY-4OgFc5--p0os=qy8BHmfjGPWGg@mail.gmail.com>
References: <4902.1552349020@sss.pgh.pa.us>
<CA+TgmobkuSFwu9yvL5UxPrY-4OgFc5--p0os=qy8BHmfjGPWGg@mail.gmail.com>
Robert Haas <robertmhaas@gmail.com> writes:
> On Mon, Mar 11, 2019 at 8:03 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> While the WaitLatch alternative avoids the problem, I doubt
>> we're ever going to remove pg_usleep entirely, so it'd be
>> good if it had fewer sharp edges. nanosleep() has the
>> same behavior as Windows, ie, the sleep is guaranteed to be
>> terminated by a signal. So if we used nanosleep() where available
>> we'd have that behavior on just about every interesting platform.
> Is there any feasible way to go the other way, and make pg_usleep()
> actually always sleep for the requested time, rather than terminating
> early?
> (Probably not, but I'm just asking.)
Yes, nanosleep would support that; it returns the remaining time after
an interrupt, so we could just loop till done. The select-based
implementation would have a hard time supporting it, though, and
I have no idea about Windows.
Now, this proposal is predicated on the idea that we won't need
to care too much about the select case because few if any
platforms would end up using it. So really the question boils
down to whether we can provide the continue-to-wait behavior on
Windows. Anyone?
(I'm not sure what I think about which behavior is really more
desirable. We can debate that if there's actually a plausible
choice to be made, which seems to depend on Windows.)
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com
Subject: Re: Use nanosleep(2) in pg_usleep, if available?
In-Reply-To: <9173.1552410822@sss.pgh.pa.us>
References: <4902.1552349020@sss.pgh.pa.us> <CA+TgmobkuSFwu9yvL5UxPrY-4OgFc5--p0os=qy8BHmfjGPWGg@mail.gmail.com> <9173.1552410822@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox