Scheduled references and late execution

Two controllers each initialize previous = 0 and use a 50 ms interval. Both check the following condition only at timestamps 50, 110, 150, and 200 ms:


C++
if (now - previous >= 50UL) {
    // Update previous using the selected policy.
    // Perform one action.
}


Policy A updates previous = now. Policy B updates previous += 50UL. All timestamp arithmetic is unsigned, no rollover occurs, each check executes the condition once, and the update and action take negligible time.


A timeline marks elapsed-time checks at 50, 110, 150, and 200 milliseconds.


Which pair of action histories is correct, and which policy preserves the original 50 ms scheduling grid?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Delay and Timing Functions Questions: