At what simulation time does $display("Done") execute? initial begin fork…
At what simulation time does $display("Done") execute? initial begin fork #10 $display("Thread 1"); #5 $display("Thread 2"); #15 $display("Thread 3"); join $display("Done"); end
- $t = 10$
- $t = 15$
- $t = 30$
- $t = 5$
Correct answer
B. $t = 15$
Explanation
fork ... join executes child processes concurrently and blocks until the longest parallel thread finishes. Thread 3 takes 15 time units, so the join unblocks and prints "Done" at $t = 15$.