VLSI DV Interview Puzzles · All levels

Round Walkthrough: Rare Parallel Deadlock

Only high-parallel random seeds deadlock. Single-threaded mode never reproduces. Present a crisp interview-grade deadlock diagnosis.

Puzzle

Difficulty: Hard · Puzzle 5 of 6 · Topic: Real Interview Rounds: End-to-End Debug Walkthrough

Only high-parallel random seeds deadlock. Single-threaded mode never reproduces. Present a crisp interview-grade deadlock diagnosis.

Code

systemverilog
task seq_a();
  sem_cfg.get(1);
  #1;
  sem_bus.get(1);
  sem_bus.put(1);
  sem_cfg.put(1);
endtask

task seq_b();
  sem_bus.get(1);
  #1;
  sem_cfg.get(1);
  sem_cfg.put(1);
  sem_bus.put(1);
endtask

Hint

Interviewers like seeing lock-order reasoning and prevention strategy.

Step-by-step solution

diagram
1) Symptom: intermittent deadlock only under concurrency.
2) Hypotheses: lock inversion, semaphore leak, or mailbox producer starvation.
3) Instrumentation: log semaphore acquisition attempts with timestamp and owner.
4) Root cause: AB-BA lock inversion creates circular wait between seq_a and seq_b.
5) Fix + validation: enforce global lock order and run parallel stress seeds to confirm no circular wait.

Answer

Answer: Actual bug: opposite semaphore acquisition order across parallel sequences. Fix: enforce one lock order (or collapse locking domain).

Why candidates get it wrong

Calling it 'random instability' is a red flag in interviews.

Interviewer follow-up

How would you catch lock-order violations automatically at runtime?

Related topics