On Sat, 1 Oct 2005 10:29:08 +0200 Magnus wrote:
MF> > My suggestion: when the current time is < last run, loop through the
MF> > alarms and calculate the diff between last run and next run for each.
MF> > Then set each one to run at (now + diff). Effectively, each alarm will
MF> > be run after the amount of time it was expecting to wait has passed.
MF> 
MF> Yes, but under that scheme timeouts might run late.
MF> 
MF> Assume that the last call to run_alarms happened at wall clock time Ta.
MF> 
MF> Then assume that at wall clock time Tb the wall clock is changed to TB.
MF> 
MF> Finally at wall clock time TC run_alarms is called again.
MF> 
MF> Under your scheme the adjustment to be applied to each alarm is (TC-Ta) but
MF> the adjustment should be (TB-Tb).

No, my adjustment would be (TC + (Ts - Ta), where Ts is the time the event was
scheduled to run,


Good point. I was thinking that TC would be close to TB (eg select would
return), but I don't think it actually does that.

MF> All this said I agree that your proposal is the best that can be done if we
MF> lack the monotonic clock.

Actually, depending on the OS, we might be able to do better. According to the
man page, select may update the passed time val with the time remaining had an
event not woken up the process. We could use that to offset all the timeouts.
But we'd have to make sure the everywhere in the code base is updated to track
this.

-- 
Robert Story; NET-SNMP Junkie
Support: <http://www.net-snmp.org/> <irc://irc.freenode.net/#net-snmp>
Archive: <http://sourceforge.net/mailarchive/forum.php?forum=net-snmp-coders>

You are lost in a twisty maze of little standards, all different. 


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to