c - Posix Timer periodically skips ahead half of its period -


I have a task related to the posx timer (timer_cut), which executes every 20 ms / 50hz. Works fine for most part, except for every 334.5 seconds (approx), the timer starts 10 ms for a circle. The interval for the next 334.5-ish seconds is all 20 ms again.

I've included the relevant code to configure the timer. Gumstix Verdex Pro runs this application with the default version of Gumstix Linux on XL6P. I have also set it with the FIFA scheduling algorithm.

My stomach says this is an integer overflow problem. Maybe there is something else using the same signal?

This problem is not a show stop but I really want to understand why this is happening.

Here's the code to configure the timer:

  // --------------------- ------- ------------------------------------------- ------- // Create a timer, which sets fire on the specified time and calls the timer event // handler. // // handler: To call the function when the timer expires: Number of microsoft to add timer / MS: Number of milliseconds to add in timer / second: Number of seconds to add to timer. - ------------------------------------------------- - --------------------------- Zero create timer (zero (* handler) (zero), uint32 us, uint32 ms, uint32 seconds) { Struct signification sign; Straight sigevent sigev; Timer_t timer; Straight Eatimerspeak Ewalwal; Straight Eatimerspec Ottawal; Timer_info_t * newTimer = NULL; // start the signal signal if (timer == faucet) signalNum = SIGRTMAX; If (SignalName and Lieutenant; SIGRTMIN) exit, outer ("no available signal, unable to make timers"); Sigemptyset (& amp; cigact.sa_mask); Sigact.sa_flags = SA_SIGINFO; Sigact.sa_sigaction = signalHandler; // Set signals to capture the signal if (signage (signaling, signal, and signet, null) == -1) exit the sound ("signification (failure), timer unable to live"); // Create a POSIX timer to generate sine sign sigev.sigev_notify = SIGEV_SIGNAL; Sigev.sigev_signo = signNum; Sigev.sigev_value.sival_ptr = & timer; Long ret = timer_create (CLOCK_REALTIME, & amp; sigev, & timerid); If (rate == 0) {// stop overflow in the calculation of the NSec below (MS> = 1000) {sec + = (MS / 1000); Ms = ms% 1000; } Itval.it_value.tv_sec = sec; Itval.it_value.tv_nsec = (long) (we * 1000l) + (tall) (ms * 1000 l * 1000 l); // configure it as a recurrence timer Itval.it_interval.tv_sec = itval.it_value.tv_sec; Itval.it_interval.tv_nsec = itval.it_value.tv_nsec; If (timer_settime (timerid, 0, and evalval, and otitle)! = 0) Exit thunder ("time_settime (error)!"); } And with the exit always ("timer_create () error!"); NewTimer = (timer_info_t *) mlok (size file (timer_info_t)); NewTimer-> Timer = timer; NewTimer-> Handler = handler; NewTimer-> SigNum = signNum; NewTimer-> Next = null; // Check to see if this is the first time (timer == faucet) {timer = new timer; Atexit (deleteTimers); } And the last timer-> gt; Next = new timer; Last time = new timer; SignalNum--; }   

Thanks in advance.

My guess is that you are using 'NTP', and due to the timing of those intervals is. Instead you can try using CLOCK_MONOTONIC , but it can also be affected accordingly.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -