[gtk-list] Select timing, please test this program (was: Signals in Gtk+)



Sascha Ziemann writes:
 > Tim Janik <timj@gtk.org> writes:
 > 
 > | since you use system calls like select() or alarm() for your timers
 > | anyways, the highest accuracy to gain is 20ms or 50Hz on intel and
 > | 10ms or 100Hz on alpha, iirc. 
 > 
 > The Intel value is correct, but I have no idea why. Does anybody know?

select() is implemented using the task switching loop in the kernel.
Each time the kernel thinks about switching tasks it does a quick
check to see whether any processes stuck in a select are eligable to
continue.

Therefore, the greatest accuracy you can get out of a select is equal
to the timeslice used by the kernel. The timeslice is determined by
hardware external to the processor with sends it a timer interrupt.
On a PC this means the "BIOS". The speed of the processor is
completely irrelevent.

Linux gets a 20ms timeslice out of the BIOS on a PC and a 10ms
timeslice out of the hardware on an alpha. A mail form Jan Gentsch 
suggests that Sun hardware generates a 10ms timeslice.

Kernels do not rely on the value of the timeslice. The hardware that 
generates it is not intended to be accurate. AFAIK the only portable 
way to find out its value is to run something like your test program. 
Linux uses something (very roughly) similar to this approach to
calculate the "BogoMIPS" of the hardware during the kernel boot.

The timeslice may limit the accuracy of your timers but does this
really matter to the code using the timer ?

Felix



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]