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
    • Event Scheduling Puzzles
    • Race Condition Puzzles
    • Clocking Block Puzzles
    • Semaphore & Mailbox Puzzles
      • Lock Held Across Blocking Response Wait
      • Bounded Mailbox put Deadlock
      • try_get Busy Spin at Time 0
      • Leaked Semaphore Token on Error Path
      • Two Consumers Waiting on One Mailbox
      • Deadlock-Free Request Loop with try_put/try_get
    • Concurrency & Timing Puzzles: Tricky Q&A
  • Randomization & Constraint Puzzles25
  • SVA Assertion Puzzles25
  • Functional Coverage Puzzles25
  • Logic & Aptitude Puzzles25
  • Scenario & Debug Puzzles25
  • Interview Prep: Puzzle Rounds5
  • DV Puzzle Cheatsheet
Loading lesson

‹Semaphore & Mailbox Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. Concurrency & Timing Puzzles
  4. Semaphore & Mailbox Puzzles
  5. Bounded Mailbox put Deadlock

VLSI DV Interview Puzzles · All levels

Bounded Mailbox put Deadlock

This hangs with mailbox depth 1. Explain exactly why depth matters and where progress stops.

On this page

    Puzzle

    Difficulty: Hard · Puzzle 2 of 6 · Topic: Semaphore & Mailbox Puzzles

    This hangs with mailbox depth 1. Explain exactly why depth matters and where progress stops.

    Code

    tb.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    module tb;
      semaphore lock = new(1);
      mailbox #(int) mb = new(1);
    
      initial mb.put(99); // fill mailbox
    
      task producer();
        lock.get(1);
        mb.put(100); // blocks because mailbox full
        lock.put(1);
      endtask
    
      task consumer();
        int v;
        lock.get(1); // waits for lock
        mb.get(v);
        lock.put(1);
      endtask
    
      initial fork
        producer();
        consumer();
      join_none
    endmodule

    Hint

    Bounded put can block, creating wait dependency like get.

    Step-by-step solution

    Diagram
    1) mb starts full due to initial put(99).
    2) Producer acquires lock then blocks on mb.put(100).
    3) Consumer needs same lock before mb.get can free space.
    4) Producer waits for mailbox space; consumer waits for lock -> deadlock.

    Answer

    Answer: Depth=1 makes put blocking when full. Holding lock during put causes circular wait and permanent hang.

    Why candidates get it wrong

    Many candidates only model get as blocking, forgetting bounded put is equally blocking.

    Interviewer follow-up

    Would increasing mailbox depth to 2 truly fix correctness or only mask the bug?

    Related topics

    • Back to Semaphore & Mailbox Puzzles

    • Concurrency & Timing Puzzles section

    Previous

    74 / 210

    Next: try_get Busy Spin at Time 0

    Up next

    Up nexttry_get Busy Spin at Time 0

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Leaked Semaphore Token on Error Path
    • Two Consumers Waiting on One Mailbox
    • Deadlock-Free Request Loop with try_put/try_get