<div dir="ltr"><div><div>Hi everybody!</div><div><br></div><div>I would like to know how to schedule an operation (write to file) with below-second frequency, any advise?</div><div><br></div><div>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:</div><div><br></div><div>struct timeval now, lastOp;</div><div>gettime(&now);</div><div>gettime(&lastOp);</div><div>...</div><div>//babel main loop</div><div>while(1) {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>gettime(&now);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>if (microSecDiff(&now, &lastOp)>499000) {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">           </span>doThatOperation();</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">             </span>gettime(&lastOp);<span class="gmail-Apple-tab-span" style="white-space:pre"> </span></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">       </span>}</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">      </span>...</div><div>}</div><div><br></div><div>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.</div><div><br></div><div>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?</div><div><br></div><div>Any hint would be very much appreciated :)</div><div><br></div><div>Thank you and regards,</div><div><br></div><div>Lorenzo</div><div><br></div></div></div>