Re: Microsecond sleeps with select()

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Microsecond sleeps with select()
Date: 2001-02-17 18:08:53
Message-ID: 200102171808.NAA24405@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > A comment on microsecond delays using select(). Most Unix kernels run
> > at 100hz, meaning that they have a programmable timer that interrupts
> > the CPU every 10 milliseconds.
>
> Right --- this probably also explains my observation that some kernels
> seem to add an extra 10msec to the requested sleep time. Actually
> they're interpreting a one-clock-tick select() delay as "wait till
> the next clock tick, plus one tick". The actual delay will be between
> one and two ticks depending on just when you went to sleep.
>

The BSDI code would be pselect():

/*
* If poll wait was tiny, this could be zero; we will
* have to round it up to avoid sleeping forever. If
* we retry below, the timercmp above will get us out.
* Note that if wait was 0, the timercmp will prevent
* us from getting here the first time.
*/
timo = hzto(&atv);
if (timo == 0)
timo = 1;

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2001-02-17 18:12:34 Re: Microsecond sleeps with select()
Previous Message Bruce Momjian 2001-02-17 18:05:53 WAL and commit_delay