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

AboutRoadmapCareersInternshipsFAQContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Puzzle Bank
  • SystemVerilog Language Puzzles25
    • Datatype and Bit Puzzles
    • Fork Join Puzzles
      • join vs join_any vs join_none
      • Loop Variable Capture in Detached Threads
      • wait fork Synchronization Point
      • disable Named Fork Scope
      • join_any Without Cleanup
      • Inner disable fork Does Not Kill Outer Sibling
    • Queue and Array Puzzles
    • String and Casting Puzzles
    • SystemVerilog Language Puzzles: Tricky Q&A
  • Difficulty Guide
  • Full Topic Map
  • Interview-Day Tips
  • Study Route: One Week Before the Interview
  • Study Route: Two Weeks
  • Study Route: Four Weeks (Full Course)4
  • OOP & Testbench Puzzles25
  • Concurrency & Timing Puzzles25
  • Randomization & Constraint Puzzles25
  • SVA Assertion Puzzles25
  • Functional Coverage Puzzles25
  • Logic & Aptitude Puzzles25
  • Scenario & Debug Puzzles25
  • UVM Testbench Puzzles25
  • Clock, Reset & CDC Puzzles25
  • Bus and Interface Protocol Puzzles25
  • Interview Prep: Puzzle Rounds7
  • DV Puzzle Cheatsheet
Loading lesson

←Fork Join Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. SystemVerilog Language Puzzles
  4. Fork Join Puzzles
  5. Inner disable fork Does Not Kill Outer Sibling
On this page

    VLSI DV Interview PuzzlesAll levels

    Inner disable fork Does Not Kill Outer Sibling

    Which prints survive this nested-fork pattern, and why?

    Puzzle

    Difficulty: Medium · Puzzle 6 of 6 · Topic: Fork Join Puzzles

    Which prints survive this nested-fork pattern, and why?

    Code

    p6.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    `timescale 1ns/1ns
    module p6;
      initial begin
        fork
          begin
            fork
              begin #2 $display("%0t A", $time); end
              begin #4 $display("%0t B", $time); end
            join_any
            disable fork;
            $display("%0t C", $time);
          end
          begin
            #3 $display("%0t D", $time);
          end
        join
        $display("%0t E", $time);
      end
    endmodule

    Hint

    `disable fork` applies to child processes of the process that calls it (its innermost active fork context).

    Step-by-step solution

    Diagram
    1) In inner fork, A prints at t=2; `join_any` unblocks immediately.
    2) `disable fork` then kills inner sibling B before t=4.
    3) C prints at t=2 after cleanup.
    4) Outer sibling D is in a different fork context, so it still prints at t=3.
    5) Outer join completes at t=3 and E prints at t=3.

    Answer

    Answer: A@2, C@2, D@3, E@3; B does not print

    How this was checked

    Checked by running the code in Icarus Verilog 13 and Verilator 5; the printed output supports the answer above. The inner disable fork kills B but not D. (Icarus, 4-state) The inner disable fork kills B but not D. (Verilator, 2-state)

    Why candidates get it wrong

    `disable fork` only affects the children of the process that calls it, so the inner call kills B but D, which belongs to the outer fork, still prints at t=3.

    Interviewer follow-up

    How would you explicitly terminate both outer branches from inside the first branch? Model answer: give the outer fork a label (`fork : outer`) and call `disable outer;` from the first branch; it terminates the whole labelled block, so D never prints and E follows immediately (note: Verilator 5.048 leaves the inner B thread running, Icarus kills it, so test on your simulator).

    Say it out loud

    I would ask whose children each disable fork kills, because it only kills children of the process that calls it. The inner join any resumes when A prints at 2, and the disable fork kills inner sibling B, then C prints at 2. The outer sibling D belongs to another fork, so it still prints at 3, and E follows at 3. The trap is thinking the disable fork stops everything nearby. I would check which fork each thread belongs to, and use a named disable if I need to kill the outer branches.

    Related topics

    • Threads and Control: Fork, Disable, Wait, Process

    • Back to Fork Join Puzzles

    • SystemVerilog Language Puzzles section

    Previous

    22 / 293

    Next: Queue and Array Puzzles

    Up next

    Up nextQueue and Array Puzzles

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • join vs join_any vs join_none
    • Loop Variable Capture in Detached Threads
    • wait fork Synchronization Point