In reply to ssakshi:
The rule says “until the parent thread executes a blocking statement or terminates”. This rule eliminates one race condition which allows you to queue up all your forked processes first before allowing them to execute.
It might to explain what’s going on by unrolling the for-loop from shimonc’s first example.
module fork_test1;
initial begin
int j;
j = 0;
begin
#1;
$display("j before fork %0d", j);
fork
$display("j inside fork-join_none block %0d", j);
join_none
$display("j after join_none %0d", j);
end
j++;
begin
#1; // this triggers the previous fork/join j is now 1
$display("j before fork %0d", j);
fork
$display("j inside fork-join_none block %0d", j);
join_none
$display("j after join_none %0d", j);
end
j++;
begin
#1; // this triggers the previous fork/join j is now 2
$display("j before fork %0d", j);
fork
$display("j inside fork-join_none block %0d", j);
join_none
$display("j after join_none %0d", j);
end
j++;
end // initial process terminates, triggers the previous fork/join j is now 3
endmodule:fork_test1