M
Mark Seger
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
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