Thread Safe Sensor Frame Buffer That Drops the Oldest Frame
Last updated: November 29, 2026
Quick Overview
Implement a bounded buffer between a sensor driver thread and a consumer thread where put never blocks and evicts the oldest frame when full, get blocks with a timeout, and dropped frames are counted.
Zoox
November 29, 20260
0
0 solved
Implement a bounded buffer between a sensor driver thread and a consumer thread where put never blocks and evicts the oldest frame when full, get blocks with a timeout, and dropped frames are counted.
Onboard Zoox software is real-time C++, and a slow consumer must never stall a sensor driver; it is better to drop stale data and report it. This screen checks concurrency fundamentals (locks, condition variables, spurious wakeups) and the judgment to prefer freshness over completeness for perception inputs.
What the Interviewer Expects
- Chooses drop-oldest semantics and explains why blocking the producer is unsafe
- Protects shared state with one lock and uses a condition variable for waiting
- Handles spurious wakeups and timeouts correctly
- Exposes a dropped-frame counter for monitoring
- Discusses how a lock-free SPSC ring buffer would look in C++
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you implement this lock-free for a single producer and single consumer in C++ with atomics?
- What memory ordering do the head and tail indices need?
- How would you avoid copying large point clouds into the buffer?
- When would drop-newest be the right policy instead?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
One producer (sensor driver) and one or more consumers. put(frame) must never block, because a blocked driver misses hardware deadlines. When full, evict the oldest frame and count it. `get(timeout)...
High-Level Design
A deque guarded by a threading.Condition. put takes the lock, evicts if full, appends, and notifies one waiter. get uses wait_for with a predicate, which loops internally and so is safe agai...