Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
QA interview question
Embedded & IoT QASeniorSpecialistTroubleshooting

How would you expose race conditions involving interrupts, tasks and shared peripherals?

Answer

Identify shared state and pre-emption points, then vary interrupt timing, priority, load and task scheduling while checking atomicity and ordering invariants. Use stress repetition with reproducible seeds, instrumentation that minimally changes timing, and targeted unit tests around critical sections. Capture the event sequence needed to reproduce any failure rather than only the final symptom.

Strong answer includes

  • models shared state and pre-emption points
  • balances stress with deterministic reproduction
  • recognizes that instrumentation can change timing

Practical example

A shared circular buffer between an ISR and the main task corrupts data roughly once every few thousand hours of runtime. Adding a debug print to catch the bug makes it disappear entirely, because the print call shifts timing enough to avoid the race. The team eventually reproduces it reliably by adding a fixed-delay hook only inside the critical section and sweeping the delay value, which pinpoints the missing atomic guard on the buffer index.

#embedded#interrupts#concurrency#race-condition

Sources

Testing — Zephyr Project DocumentationZephyr Project · Embedded unit, integration, simulation and hardware test frameworks and executionKUnit — Linux Kernel Unit TestingLinux Kernel · In-kernel unit testing, dependency isolation, test harnesses, QEMU and architecture coverage