# Fork join\_none

**URL:** <https://verificationacademy.com/forums/t/fork-join-none/37738>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, for-loop-fork-join\_none\
**Created:** [June 20, 2020, 11:52am UTC](https://verificationacademy.com/forums/t/fork-join-none/37738 "2020-06-20T11:52:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anveshdangeti](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/8baadc/32.png) [@anveshdangeti](https://verificationacademy.com/forums/u/anveshdangeti)\
**Post date:** [June 20, 2020, 11:52am UTC](https://verificationacademy.com/forums/t/fork-join-none/37738/1 "2020-06-20T11:52:10Z")

</div>

```verilog
module fork_test();
initial begin
for (int j=0; j<3; j++)
begin

fork

$display(j);

join_none

end
end
endmodule

```

when i am running the above code getting output below like this  
3  
3  
3  
please explain me how getting the output

---

<div class="post-metadata">

**Author:** ![shanthi](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/54ee81/32.png) [@shanthi](https://verificationacademy.com/forums/u/shanthi)\
**Post date:** [June 20, 2020, 12:32pm UTC](https://verificationacademy.com/forums/t/fork-join-none/37738/2 "2020-06-20T12:32:20Z")

</div>

[i]In reply to [anvesh dangeti](https://verificationacademy.com/forums/t/fork-join-none/37738):[/i

When fork join\_none is used, the parent process continues to execute concurrently with all the processes spawned by the fork. The spawned processes do not start executing until the parent thread executes a blocking statement or terminates.

The parent thread is here a **for loop**. The process inside the parent thread that is spawned inside the fork is **$display**.

So in this case, $dispaly does not execute until the parent thread terminates (for loop completes the iteration for 3 times)as there are no blocking statements in the parent thread. By the time the $display executes the for loop has gone through the 3 iterations., so the value of j displayed will be 3.

Regards,  
Shanthi

---

<div class="post-metadata">

**Author:** ![anveshdangeti](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/8baadc/32.png) [@anveshdangeti](https://verificationacademy.com/forums/u/anveshdangeti)\
**Post date:** [June 20, 2020, 1:44pm UTC](https://verificationacademy.com/forums/t/fork-join-none/37738/3 "2020-06-20T13:44:13Z")

</div>

```verilog
module fork_test1;
initial begin
for (int j=0; j<3; j++)
begin
#1;
fork

$display(j);

join_none

end
end
endmodule

```

when i am putting delay #1.the output below like this  
output:  
1  
2  
3

---

<div class="post-metadata">

**Author:** ![svats](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/e47c2d/32.png) [@svats](https://verificationacademy.com/forums/u/svats)\
**Post date:** [June 20, 2020, 1:59pm UTC](https://verificationacademy.com/forums/t/fork-join-none/37738/4 "2020-06-20T13:59:46Z")

</div>

It is because before going for next iteration the previous iteration encounters a blocking or delay statement i.e. #1 which makes the scheduled fork-join\_none statement to execute with the current value of the j. As per LRM for Fork-Join\_None :  
_The spawned processes do not start executing until the parent thread executes a blocking statement or terminates_

Thanks

---

<div class="post-metadata">

**Author:** ![cgales](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/ccd318/32.png) [@cgales](https://verificationacademy.com/forums/u/cgales)\
**Post date:** [June 21, 2020, 8:12pm UTC](https://verificationacademy.com/forums/t/fork-join-none/37738/5 "2020-06-21T20:12:47Z")

</div>

_In reply to [anvesh dangeti](https://verificationacademy.com/forums/t/fork-join-none/37738/4):_

Look at [this thread](https://verificationacademy.com/forums/systemverilog/fork-joinnone-inside-loop).
