[Babel-users] Main Loop Frequency

Lorenzo Ghiro lorenzo.ghiro at studenti.unitn.it
Tue Mar 7 14:01:11 UTC 2017


Hi everybody!

I would like to know how to schedule an operation (write to file) with
below-second frequency, any advise?

My strategy up to now has been to check, in the main loop, how many time
passed from the last operation's occurence. Given that variable now is
updated in every loop iteration, my code looks like this:

struct timeval now, lastOp;
gettime(&now);
gettime(&lastOp);
...
//babel main loop
while(1) {
gettime(&now);
if (microSecDiff(&now, &lastOp)>499000) {
doThatOperation();
gettime(&lastOp);
}
...
}

However, running a Babel instance on my laptop, I notice that the main loop
is performed with a strange frequency...sometimes approx 1Hz sometimes
slower. Consequently, if I perform a check of how many microseconds are
passed from the last loop iteration I miss the below-second deadline that I
desire.

The main loop frequency that I notice is standard or anomalous? What I
notice is related to the "clock monotonicity" enforced with the use of
gettime()? Or I have this problem just because my laptop has a bad clock?

Any hint would be very much appreciated :)

Thank you and regards,

Lorenzo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/babel-users/attachments/20170307/6aa177eb/attachment.html>


More information about the Babel-users mailing list