Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Puzzle Bank
  • SystemVerilog Language Puzzles25
  • Difficulty Guide
  • Full Topic Map
  • Interview-Day Tips
  • OOP & Testbench Puzzles25
  • Concurrency & Timing Puzzles25
  • Randomization & Constraint Puzzles25
  • SVA Assertion Puzzles25
  • Functional Coverage Puzzles25
  • Logic & Aptitude Puzzles25
  • Scenario & Debug Puzzles25
    • Testbench Debug Puzzles: Why Did the Test Hang?
    • Deadlock Scenario Puzzles: Objection and Phase Stalls
      • Early Return Leaves Objection Raised
      • fork...join_none Thread Leak
      • Semaphore Token Leak on Error Path
      • Mailbox Consumer Blocks Forever
      • Lock Inversion with Two Semaphores
      • Child Sequence Raises Objection but Never Drops
    • Scoreboard Puzzles: Mismatch or Ordering Bug?
    • Real Interview Rounds: End-to-End Debug Walkthrough
    • Scenario & Debug Puzzles: Tricky Q&A
  • Interview Prep: Puzzle Rounds5
  • DV Puzzle Cheatsheet
Loading lesson

‹Deadlock Scenario Puzzles: Objection and Phase Stalls
  1. Topics
  2. DV Interview Puzzles
  3. Scenario & Debug Puzzles
  4. Deadlock Scenario Puzzles: Objection and Phase Stalls
  5. Semaphore Token Leak on Error Path

VLSI DV Interview Puzzles · All levels

Semaphore Token Leak on Error Path

Two parallel sequences share one bus lock and eventually freeze under error injection. Only failing seeds hit the deadlock.

On this page

    Puzzle

    Difficulty: Medium · Puzzle 3 of 6 · Topic: Deadlock Scenario Puzzles: Objection and Phase Stalls

    Two parallel sequences share one bus lock and eventually freeze under error injection. Only failing seeds hit the deadlock.

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    semaphore bus_sem = new(1);
    
    task send_req(my_item req);
      bus_sem.get(1);
      if (req.timeout_fault) begin
        \`uvm_error("DRV", "timeout")
        return; // bug: token never returned
      end
      drive_req(req);
      bus_sem.put(1);
    endtask

    Hint

    Resource ownership must be balanced even in exceptional exits.

    Step-by-step solution

    Diagram
    1) Add semaphore occupancy debug counters around get/put.
    2) Reproduce with timeout_fault and observe token count never returns.
    3) Refactor with cleanup block so put executes for all post-get exits.
    4) Consider try/finally-style coding pattern for shared resources.
    5) Add assertion: semaphore token count reaches initial value at phase end.

    Answer

    Answer: Bug: return on timeout path leaks semaphore token, blocking all later requests. Fix: always put token after successful get, regardless of error path.

    Why candidates get it wrong

    People suspect simulator scheduling; this is deterministic resource leak.

    Interviewer follow-up

    Would a mailbox-based arbitration model be safer here than manual semaphores?

    Related topics

    • Back to Deadlock Scenario Puzzles: Objection and Phase Stalls

    • Scenario & Debug Puzzles section

    Previous

    188 / 210

    Next: Mailbox Consumer Blocks Forever

    Up next

    Up nextMailbox Consumer Blocks Forever

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Early Return Leaves Objection Raised
    • Lock Inversion with Two Semaphores
    • Child Sequence Raises Objection but Never Drops