Control Loop Deadline Monitor With Jitter and Safe-Stop Trip

Last updated: November 29, 2026

Quick Overview

Implement a monitor for a fixed-period control loop that records each cycle's wake and completion time, counts deadline misses, tracks worst latency and period jitter in constant memory, and trips a safe-stop flag after N consecutive misses. Then explain what causes misses on a real-time Linux system.

Figure AI
Software Engineering Fundamentals
Software Engineer
Figure AI
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Medium

0

0

0 solved


Implement a monitor for a fixed-period control loop that records each cycle's wake and completion time, counts deadline misses, tracks worst latency and period jitter in constant memory, and trips a safe-stop flag after N consecutive misses. Then explain what causes misses on a real-time Linux system.

Whole-body control on a humanoid runs at hundreds of hertz, and a policy or controller that overruns its period can destabilize balance. Figure AI embedded and controls-adjacent software interviews are likely to mix a small implementation with real-time fundamentals: scheduling, priority inversion, memory allocation, and what a safe reaction looks like.

What the Interviewer Expects
  • Implements streaming statistics (Welford) without storing all samples
  • Separates latency (work time) from period jitter (wake time variation)
  • Uses consecutive misses, not total misses, for the trip condition
  • Names concrete causes of misses: page faults, priority inversion, CPU frequency scaling, interrupts, logging in the loop
  • Proposes mitigations such as mlockall, isolated cores, SCHED_FIFO, preallocated memory
Key Topics to Cover
Real-time scheduling
Welford's algorithm
Priority inversion
Deadline monitoring
Safe-stop design
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • Why is calling a logger or allocating memory inside the control loop dangerous, and what do you do instead?
  • Explain priority inversion and how priority inheritance mutexes help.
  • What should the robot physically do when the monitor trips, given that it is standing on two legs?
  • How would you measure end-to-end latency from sensor read to motor command, not just loop compute time?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

Each cycle reports wake and done in microseconds. A miss is done - wake > period. Track total misses, longest run of consecutive misses, worst latency, mean period and its standard deviation (ji...

High-Level Design

Keep counters for misses and the current miss streak. For the period between consecutive wakes, use Welford's online mean and variance, which is numerically stable and needs no history. The trip flag ...


Submit Your Answer
Markdown supported

Related Questions