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. Two Consumers Waiting on One Mailbox

VLSI DV Interview Puzzles · All levels

Two Consumers Waiting on One Mailbox

Producer sends two items after both consumers are blocked on get. Is consumer wake-up order guaranteed?

On this page

    Puzzle

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

    Producer sends two items after both consumers are blocked on get. Is consumer wake-up order guaranteed?

    Code

    tb.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    module tb;
      mailbox #(int) mb = new();
    
      task consumer(string name);
        int v;
        mb.get(v);
        $display("[%0t] %s got %0d", $time, name, v);
      endtask
    
      initial fork
        consumer("C1");
        consumer("C2");
      join_none
    
      initial begin
        #5 mb.put(10);
        #0 mb.put(20);
        #1 $finish;
      end
    endmodule

    Hint

    Mailbox preserves message FIFO, but waiter scheduling fairness is not strict across processes.

    Step-by-step solution

    Diagram
    1) Message order in mailbox is FIFO: 10 then 20.
    2) Which blocked consumer gets first wake-up is not a robust fairness contract to rely on.
    3) One run may print C1->10, C2->20; another may swap consumer names with same data order.

    Answer

    Answer: Data order is FIFO (10 then 20), but consumer-to-item mapping is not a portability-safe fairness guarantee.

    Why candidates get it wrong

    Assuming blocked getter wake-up order is deterministic across all tools can break regressions.

    Interviewer follow-up

    How would you enforce deterministic ownership (per-agent mailbox or tagged routing)?

    Related topics

    • Back to Semaphore & Mailbox Puzzles

    • Concurrency & Timing Puzzles section

    Previous

    77 / 210

    Next: Deadlock-Free Request Loop with try_put/try_get

    Up next

    Up nextDeadlock-Free Request Loop with try_put/try_get

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Lock Held Across Blocking Response Wait
    • Bounded Mailbox put Deadlock
    • try_get Busy Spin at Time 0