Skip to content

Commit

Permalink
Revert "Skip task/timer updated if late for more than a few periods"
Browse files Browse the repository at this point in the history
This reverts commit 2318f82.
  • Loading branch information
meyerj authored and francisco-miguel-almeida committed Apr 9, 2019
1 parent da78139 commit 6e7dcbb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
8 changes: 1 addition & 7 deletions rtt/os/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ namespace RTT {

// Wait
int ret = 0;
Time now = rtos_get_time_ns();
if ( wake_up_time > now )
if ( wake_up_time > rtos_get_time_ns() )
ret = msem.waitUntil( wake_up_time ); // case of no timers or running timers
else
ret = -1; // case of timer overrun.
Expand All @@ -102,11 +101,6 @@ namespace RTT {
TimerIds::iterator tim = mtimers.begin() + next_timer_id;
if ( tim->period ) {
// periodic timer
// if late by more than 4 periods, skip late updates
int maxDelayInPeriods = 4;
if (now - tim->expires > tim->period*maxDelayInPeriods) {
tim->expires += tim->period*((now - tim->expires) / tim->period);
}
tim->expires += tim->period;
} else {
// aperiodic timer
Expand Down
9 changes: 1 addition & 8 deletions rtt/os/gnulinux/fosi_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,9 @@ namespace RTT

if (task->wait_policy == ORO_WAIT_ABS)
{
// in the case of overrun by more than 4 periods,
// skip all the updates before now, with the next update aligned to period
int maxDelayInPeriods = 4;
NANO_TIME period = task->period;
if (now - wake > maxDelayInPeriods*period) {
period = period * ((now - wake) / period);
}
// program next period:
// 1. convert period to timespec
TIME_SPEC ts = ticks2timespec( nano2ticks(period) );
TIME_SPEC ts = ticks2timespec( nano2ticks( task->period) );
// 2. Add ts to periodMark (danger: tn guards for overflows!)
NANO_TIME tn = (task->periodMark.tv_nsec + ts.tv_nsec);
task->periodMark.tv_nsec = tn % 1000000000LL;
Expand Down

1 comment on commit 6e7dcbb

@meyerj
Copy link
Member Author

@meyerj meyerj commented on 6e7dcbb Apr 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has later been reverted in 745a501.

Please sign in to comment.