From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org> |
Subject: | Microsecond sleeps with select() |
Date: | 2001-02-17 16:41:17 |
Message-ID: | 200102171641.LAA16661@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(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
From | Date | Subject | |
---|---|---|---|
Next Message | Lamar Owen | 2001-02-17 16:53:29 | Re: Non-locale 7.1beta4 binaries on RedHat 6.2 test results. |
Previous Message | Tom Lane | 2001-02-17 16:40:55 | Re: Non-locale 7.1beta4 binaries on RedHat 6.2 test results. |