5 class my_class;
6 process m,n;
7 task run();
8 fork
9 begin : first_thread
10 m = process::self();
11 #10;
12 $display("first thread %0t", $time);
13 end
14
15 begin : second_thread
16 n = process::self();
17 #10;
18 #10;
19 $display("second thread %0t", $time);
20 end
21
22 join_none
23
24 wait(m!=null);
25 m.await();
26
27 $display("time before suspend %0t", $time);
28
29 // wait for first thread to finish using await, then suspend second thread for 10ns
30 n.suspend();
31 #10;
32 n.resume();
33 // resume second thread , expecting to display 30?
34 $display("time after resume %0t", $time);
35 endtask
36 endclass
output:
first thread 10
time before suspend 10
second thread 20
time after resume 20
Hello there,
My question is that why second thread seems not suspended for 10?
My intent is to wait for first thread to finish ,and suspend sencond thread for 10 , and then resume second thread, then the second thread display should be happening @time 30, but it showed 20 instead, can anyone explain to me where I was wrong or what’s going under the hood?
Thanks