# How statements connect to the event scheduler, race condition time

**URL:** <https://verificationacademy.com/forums/t/how-statements-connect-to-the-event-scheduler-race-condition-time/51488>\
**Category:** SystemVerilog\
**Created:** [December 5, 2025, 1:43pm UTC](https://verificationacademy.com/forums/t/how-statements-connect-to-the-event-scheduler-race-condition-time/51488 "2025-12-05T13:43:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kai123](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/k/59ef9b/32.png) [@kai123](https://verificationacademy.com/forums/u/kai123)\
**Post date:** [December 5, 2025, 1:43pm UTC](https://verificationacademy.com/forums/t/how-statements-connect-to-the-event-scheduler-race-condition-time/51488/1 "2025-12-05T13:43:28Z")

</div>

The LRM has as an example, this piece of code and text for race conditions. It seems to me still unclear how it interacts with the event scheduling.

 ![image](https://verificationacademy.com/forums/uploads/default/original/2X/f/f64597a416c8926ecbd0d22e7f44cb6def5a7b82.png)

I tried to map the code to the scheduler =\>

first delta cycle:

1. assign p = q;

2. q = 1;

both get put into the active region. The net update gets scheduled for p when a change of q takes place, this creates an event and it gets puts into the inactive region…  
so then q =1, then p = 1. everyone seems happy.

for the next delta cycle:

while all the 3 statements get put into the active region( the 2 red arrows and the 1 green arrow)

maybe this is wrong but the expectation is still that because the “initial begin{ }end” is one process, it gets put together into the active region, and then it processes through these statements in order, as these are blocking statements inside the begin end. so:

execution order

1. q = 0; // this statement causes a change in q and thus schedules p = 0, for the inactive region.
2. $display(p); // this should display p =1, because p has not changed yet as p=0 is scheduled for later;

 ![image](https://verificationacademy.com/forums/uploads/default/original/2X/3/3268258016994df4687c5e2687d62743c7754ef2.png)

I have tested this and 3/4 simulators show p = 1 from the $display task.

Why is there a race condition here? The order seems known?

From the text it seems to indicate that the “update event” of q also gets put into the first active region together with display?? is it really not put into the inactive region?

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [December 9, 2025, 4:57pm UTC](https://verificationacademy.com/forums/t/how-statements-connect-to-the-event-scheduler-race-condition-time/51488/2 "2025-12-09T16:57:18Z")

</div>

`q=0;` gets scheduled in the active region of timestep 1. All procedural statements here get executed in the active region. Even if you changed the `#1` to `#0`, the blocking assignment statement still occurs in the active region.

Although the statements between the `begin` and `end` keywords represent a single process, each statement is an independent active event. The non-determinism arises because the order of events between different processes executing within the same event region creates a race condition.

This non-determinism provides several benefits to simulation:

- It allows your design to be executed on a multi-core/multi-CPU platform, which is actually much closer to the actual hardware representation.
- It enables optimizations in software that combine multiple processes into a single process. (it could choose to update `p` only as `q` gets updated.
- it could combine `p` and `q` variables into a single representation.
