2
votes

This paper titled Systemverilog Event Regions Race Avoidance & Guidelines submits an example that contradicts the Systemverilog IEEE 1800-2012 LRM:

...when forking background processes, it is often very useful to allow newly created subprocesses a chance to start executing before continuing the execution of the parent process. This is easily accomplished with the following code:

program test;
  initial begin
    fork
        process1;
        process2;
        process3;
     join_none

      #0;
      // parent process continue
  end
endprogram

However IEEE Systemverilog LRM IEEE 1800-2012 states:

"join_none. 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."

Which is it?

1
BTW, I know this is just a simple example, but I would never recommend using a #0 anywhere in your code. If you don't understand the significance of using it, you won't understand the problems created by using it. - dave_59

1 Answers

2
votes

There is no contradiction here. Look at it this way:

join_none. 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.

We are being told that the forked processes do not start immediately. They wait for the parent process, which spawned them, to yield (by either terminating or by encountering a blocking statement). The fork statement basically schedules the processes. The scheduler gets a chance to start executing them only when the already running thread (parent process) yields.

The first example you quoted, suggests that you give a chance to the spawned processes to start executing. To do so it asks you to introduce a #0 statement. When the parent process encounters #0, a blocking statement, it yields. The spawned processes therefor get a chance to start executing.