Time.sleep(0.0125) not available within Linux
Grant Edwards
grante at visi.com
Tue Sep 30 20:41:15 EDT 2008
On 2008-09-30, Michael Torrie <torriem at gmail.com> wrote:
>> Just a thought, your minimum sleep time is probably limited by
>> the resolution of the system "HZ" clock. Type
>>
>> less /proc/config.gz
>>
>> and search for the value of the "CONFIG_HZ" setting. On the
>> Athlon 64 machine I'm using to write this, it's 250, which
>> should allow for sleep intervals in multiples of 0.004
>> seconds.
>
> Since most distributions do not create this file in /proc for whatever
> reason,
It's also common to put a copy of the config file in /boot (or
wherever the kernel binaries are installed). I prefer the
/proc/config.gz setup myself, and that's how I configure all my
systems.
> and some people are being deliberately obtuse, does anyone
> know how to ask the kernel what the timer resolution is? Is
> it stored anywhere else in /proc or /sys? I kind of think
> most distros set it to 1000 Hz, but I'm not sure.
We could look in /usr/include:
$ grep -r ' HZ ' /usr/include
/usr/include/scsi/sg.h:#define SG_DEFAULT_TIMEOUT (60*HZ) /* HZ == 'jiffies in 1 second' */
/usr/include/linux/ixjuser.h:* IXJCTL_HZ sets the value your Linux kernel uses for HZ as defined in
/usr/include/linux/n_r3964.h: * Fixed HZ usage on 2.6 kernels
/usr/include/asm/param.h:#define HZ 100
But, I happen to know that's wrong and I'm running a kernel with HZ=250.
So let's look elsewhere. How about in /proc/sys/kernel?
$ cat /proc/sys/kernel/sched_min_granularity_ns
4000000
That looks suspiciously like 1/HZ in nanoseconds.
--
Grant
More information about the Python-list
mailing list