In reply to dave_59:
In reply to venkatarami reddy:
You are are correct in the first case none of the forked threads start executing until the parent thread blocks or terminates.
If you unroll the for-loop in the second case, you get your answers
i=0;
#0;
fork
$display("i=%0d",i);
join_none
i++;
#0; // i is 1
fork
$display("i=%0d",i);
join_none
i++;
#0; // i is 2
fork
$display("i=%0d",i);
join_none
i++;
#0; // i is 3
fork
$display("i=%0d",i);
join_none
i++;
#0; // i is 4
fork
$display("i=%0d",i);
join_none
i++l
// i is 5
- since
#0blocking statements executes in NBA region and 2 ) for loop it gets repeated for 4 times so we are getting output as 1 2 3 4 3)and increment of i happens post fork join_none execution in this case
?