Re: Is this a race?



The #0 will cause the execution of the statement to be deferred, much
like an actual delay would. This is actually specified in the LRM,
though not completely correctly. The history is presumably something
like the following.

Verilog-XL apparently did not just throw a delay control of #0 away,
but handled it like any other delay control. It suspended the process
and re-scheduled it on the time queue for a time 0 away from now, i.e.
the current time queue. This deferred it to the end of the current
time queue (or perhaps put it on a new time queue to be executed
immediately after the current one, which has a similar effect). The
result was that a delay control of #0 would cause the current process
to be deferred until after all the other processes that were triggered
by the same inputs. Users started relying on the bad practice of
inserting #0 in their procedural code to try to resolve race conditions
(or if that wasn't sufficient, #0 #0 or #0 #0 #0).

So much legacy code relied on this, that a guarantee was put into the
LRM to try to ensure that this bad code would continue to work. In the
section on deterministic and nondeterministic event ordering, they
essentially needed to specify that #0 would defer a process to the end
of the event queue. But since the specification of nondeterministic
event ordering allowed processing the events on the queue in any order,
that wouldn't have helped. So they specified that it would go onto a
separate "inactive" queue until the "active" queue was processed, and
then the "inactive" queue would become the "active" queue.

The problem with this way of specifying it is that it is too strong.
There was never really a separate "inactive" queue; it was just a way
of saying "after the currently scheduled events". If taken literally,
the way it is specified implies that #0 not only defers until after the
currently scheduled events, but also after any events scheduled later
for the current time, as long as those events don't go onto the
"inactive" queue also. For example, it implies that a #0 delay is
bigger than an arbitrary number of continuous assignment delays in
series, which was not true in Verilog-XL.

Then the SystemVerilog committees got the idea that this "inactive"
queue was an actual separate queue that guaranteed this much stronger
ordering, and started building more elaborate things that assumed it.
Not good.

.



Relevant Pages

  • Re: Threading Delay
    ... normally with no delay or some may have the delay. ... > app with 512 threads, and when you see the delay, break into debuggee ... Each thread grabs it data from a queue. ... >> function exits. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: MIDI conjunction device
    ... I would agree on a one byte delay with UARTs, ... Ignoring bit-banged receivers and transmitter, ... If we queue each character for transmission as thery are received, ...
    (comp.arch.embedded)
  • [PATCH] workqueue: update kerneldoc
    ... to clear up any confusion is simply to improve the kerneldoc comment. ... * Returns non-zero if it was successfully added. ... We queue the work to the CPU it was submitted, ... struct work_struct *work, unsigned long delay) ...
    (Linux-Kernel)
  • Re: SingleThreadExecutor and PriorityBlockingQueue
    ... It true that you can specify the queue as the last parameter to ThreadPoolExecutor but in this case it does not solve the problem. ... The constructor for PriorityBlockingQueue also has a last parameter which lets you specify a Comparator which defines the order; that means the non-comparability of FutureTask doesn't matter. ...
    (comp.lang.java.programmer)
  • IP Printing Issues in Tiger
    ... I have an odd issue with IP printing in Tiger. ... a printer using IPP where that printer requires me to specify a queue, ... like the Fiery EX12 that we have, for example, the Printer Setup ... Utility seems to ignore the queue name that I enter. ...
    (comp.sys.mac.printing)