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



On 15 Sep, Felix Bellaby wrote:
> 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.

Please don't confuse accuracy with precision. My watch is not very
accurate: it gains 5 seconds a day. It is however very precise in that
it gains 5 seconds every single day.

> 
> 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.
> 

Linux uses a tick interval of 10 ms on a PC. Believe it or not, the
kernel actually decides to do this itself.

> 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.

You might consider running such a test program yourself

> 
> The timeslice may limit the accuracy of your timers but does this
> really matter to the code using the timer ?
> 
> Felix
> 
> -- 
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
> 

-- 
David Sears                 | dns@connix.com, dns@essnjay.com
Huntington, CT USA-06484    | david_sears@csi.com



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