Re: Microsecond sleeps with select()
| От | Bruce Momjian |
|---|---|
| Тема | Re: Microsecond sleeps with select() |
| Дата | |
| Msg-id | 200102171808.NAA24405@candle.pha.pa.us обсуждение исходный текст |
| Ответ на | Re: Microsecond sleeps with select() (Tom Lane <tgl@sss.pgh.pa.us>) |
| Список | pgsql-hackers |
> Bruce Momjian <pgman@candle.pha.pa.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@candle.pha.pa.us | (610)
853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill,
Pennsylvania19026
В списке pgsql-hackers по дате отправления: