Microsecond sleeps with select()
От | Bruce Momjian |
---|---|
Тема | Microsecond sleeps with select() |
Дата | |
Msg-id | 200102171641.LAA16661@candle.pha.pa.us обсуждение исходный текст |
Ответы |
Re: Microsecond sleeps with select()
|
Список | pgsql-hackers |
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. The kernel only gets to control the cpu during those tick interrupts or if a user application makes a kernel call. Therefore, it is no surprise the most Unix kernels can't do 5 microsecond sleeps. The only way they could do it would be to reprogram the timer interrupt if a wakeup was going to occur in less than 10 milliseconds. I doubt many kernels do that because I don't think timer interrupt programming is a very quick or accurate operation. Also, reprogramming it would make the actual 100hz timer unreliable. Now, kernels could check on return from kernel to user code to see if someone is ready to be woken up, but I doubt they do that either. Looking at the BSDI kernel, all timeouts are expressed in ticks, which are 10 milliseconds. Obviously there is no checking during kernel call returns because they don't even store the sleeps with enough resolution to perform a check. In fact, the kernel doesn't even contain have a way to measure microsecond timings. -- 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 по дате отправления: