Time.sleep(0.0125) not available within Linux

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Torrie

    #16
    Re: Time.sleep(0.01 25) not available within Linux

    Lawrence D'Oliveiro wrote:
    In message <__KdneWJPotDx0 XVnZ2dnUVZ_gGdn Z2d@posted.usin ternet>, Grant
    Edwards wrote:
    >
    >On 2008-09-23, Blubaugh, David A. <dblubaugh@belc an.comwrote:
    >>
    >>I was wondering if anyone has come across the issue of not being allowed
    >>to have the following within a Python script operating under Linux:
    >>>
    >>time.sleep(0. 0125)
    >No, I have not. And I doubt anybody else has.
    >
    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, 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.




    Comment

    • Grant Edwards

      #17
      Re: Time.sleep(0.01 25) not available within Linux

      On 2008-09-30, Michael Torrie <torriem@gmail. comwrote:
      >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_TIME OUT (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_granu larity_ns
      4000000

      That looks suspiciously like 1/HZ in nanoseconds.

      --
      Grant

      Comment

      Working...