Use nanosleep() for pg_usleep() on Unix/Linux? - Mailing list pgsql-hackers

From Paul Guo
Subject Use nanosleep() for pg_usleep() on Unix/Linux?
Date
Msg-id CABQrizfxpBLZT5mZeE0js5oCh1tqEWvcGF3vMRCv5P-RwUY5dQ@mail.gmail.com
Whole thread Raw
Responses Re: Use nanosleep() for pg_usleep() on Unix/Linux?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I happened to read the pg_usleep() code recently. I'm wondering
if we could implement it using the posix function nanosleep(),
instead of by select().

nanosleep() is designed with higher time resolution, besides it provide
remaining time if is interrupted by signal so that pg_usleep() could
be implemented more accurately.

The code for pg_usleep() could be similar like this:

while(nanosleep(&req,&req)==-1 && errno == EINTR)

  continue;


or combine with clock_gettime() to control the sleep time more accurately.


Regards,

Paul

pgsql-hackers by date:

Previous
From: Mark Kirkwood
Date:
Subject: Re: Write Ahead Logging for Hash Indexes
Next
From: Craig Ringer
Date:
Subject: Re: Override compile time log levels of specific messages/modules