VLSI DV Interview Puzzles · All levels
try_get Busy Spin at Time 0
No deadlock occurs, but simulation appears frozen at t=0. Explain root cause and proper fix.
Puzzle
Difficulty: Easy · Puzzle 3 of 6 · Topic: Semaphore & Mailbox Puzzles
No deadlock occurs, but simulation appears frozen at t=0. Explain root cause and proper fix.
Code
systemverilog
module tb;
mailbox #(int) mb = new();
int item;
initial begin
forever begin
if (!mb.try_get(item)) begin
// no delay, no event wait
end
end
end
endmoduleHint
A non-blocking API still needs timing control in polling loops.
Step-by-step solution
diagram
1) try_get returns immediately when mailbox empty.
2) Loop has no blocking statement or delay.
3) Process consumes simulator cycles in same time slot, often stuck at t=0.
4) Add blocking get, wait event, or small delay/backoff in empty case.Answer
Answer: This is a zero-delay busy spin, not a protocol deadlock. Add wait/delay or switch to blocking get.
Why candidates get it wrong
Non-blocking call does not imply low-overhead loop by itself.
Interviewer follow-up
What backoff policy would you use to avoid both starvation and performance collapse?