All jobs / Embedded / hardware / RTOS
Embedded / hardware interview question · 1–3 years
A UART interrupt needs to hand a byte to a task through an RTOS queue. What must the ISR do differently?
The strongest answer
Call the FromISR version of the queue API, which never blocks, and pass the higher-priority-task-woken flag to the yield macro so the woken task runs as the ISR exits
Why it works
Right — no blocking, and the yield is what makes the handoff prompt instead of waiting for the next tick.
What a good answer covers
- ISRs use the FromISR calls and never block.
- Send with the FromISR variant.
- Pass the woken flag to the yield.
- Keep the interrupt priority RTOS-callable.
Answers that fall short
- Close, but not the strongest: Use the FromISR version of the call — the ordinary one can block, and an ISR must never block
Correct, and the important half; the woken flag and the yield are what remove a tick of latency. - Weak: Nothing special; the queue is thread-safe, so the ordinary send works from anywhere
The ordinary call can block waiting for space, and blocking inside an ISR is how a system stops dead. - Red flag: Take the queue’s mutex in the ISR first, so no task can be writing at the same moment
Taking a mutex in an ISR is forbidden: there is no task to own it and nothing that can block.
Who gets asked this
More RTOS questions
- Average loop time is fine; the plant oscillates. What did you miss?
- A task should sample every 10 ms. It sleeps for 10 ms at the end of each pass, and over minutes the period…
- Two tasks write a global “state” byte. What is the grown-up move?
- A low-priority task holds a lock a high-priority task needs. What do you name?
- One task corrupts another’s stack. What do you add besides “be careful”?
- You have a 2 ms control deadline. What number do you present?
- A low-priority logger never runs. What do you check before “buy a faster MCU”?
- Two teams share one firmware, each has added mutexes, and you have now had two hangs that reproduce about…