problems with Time::HiRes on some SLES systems

Discussion in 'Perl Misc' started by Mark Seger, Sep 28, 2006.

  1. Mark Seger

    Mark Seger Guest

    I've been using this module for doing highly accurate sleeping. I would
    essentially set an alarm for n-seconds and then so a sleep for time time
    greater then n. When the signal is delivered and I act on it (or simply
    just return), my app simply continues after the sleep.

    I'm now trying this on several freshly installed sles10 systems and it
    wakes up early when the time is 5 or greater and I have no clue why. It
    runs just fine on every other system/architecture I've tried. Could
    something be missing from the installation? Is there some easy way to
    tell??

    Here's what the script looks like:

    #!/usr/bin/perl -w

    use Time::HiRes;

    $SIG{ALRM}=\&sigAlrm;

    for ($i=1; $i<60; $i++)
    {
    $time0=time;
    Time::HiRes::ualarm($i*1000000);
    sleep 100;
    printf "Alarm: $i Awake! %d secs\n", time-$time0;
    }

    # usleep wakeup
    sub sigAlrm
    {
    }

    and here's what it's producing on 3 systems:

    linux:/mjs # /usr/bin/perl sht.pl
    Alarm: 1 Awake! 1 secs
    Alarm: 2 Awake! 2 secs
    Alarm: 3 Awake! 3 secs
    Alarm: 4 Awake! 4 secs
    Alarm: 5 Awake! 0 secs
    Alarm: 6 Awake! 2 secs
    Alarm: 7 Awake! 3 secs
    Alarm: 8 Awake! 3 secs
    Alarm: 9 Awake! 1 secs
    Alarm: 10 Awake! 1 secs
    Alarm: 11 Awake! 3 secs
    Alarm: 12 Awake! 3 secs
    Alarm: 13 Awake! 0 secs
    Alarm: 14 Awake! 1 secs
    Alarm: 15 Awake! 2 secs

    I'm stumped...
    -mark
     
    Mark Seger, Sep 28, 2006
    #1
    1. Advertising

  2. Mark Seger

    Mark Seger Guest

    Mark Seger wrote:
    > I've been using this module for doing highly accurate sleeping. I would
    > essentially set an alarm for n-seconds and then so a sleep for time time
    > greater then n. When the signal is delivered and I act on it (or simply
    > just return), my app simply continues after the sleep.


    I've been in touch with the developer Jarkko Hietaniemi and he's
    confirmed this is indeed a problem and he will have a newer version
    coming out some time in the future.
    -mark
     
    Mark Seger, Sep 28, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ruby Student
    Replies:
    4
    Views:
    122
    Charles Oliver Nutter
    Sep 25, 2010
  2. Adam
    Replies:
    2
    Views:
    105
    Michele Dondi
    Nov 17, 2004
  3. mastermagrath
    Replies:
    4
    Views:
    480
    robic0
    Dec 1, 2005
  4. Mark Seger
    Replies:
    6
    Views:
    122
    Martijn Lievaart
    Apr 15, 2008
  5. John

    accuracy of Time::HiRes

    John, Jun 27, 2008, in forum: Perl Misc
    Replies:
    1
    Views:
    139
Loading...

Share This Page