Race Conditions and Hazards
Race Condition
A race condition is the condition where a system's substantive behaviour is dependent on the sequence or timing of other uncontrollable events.
Race conditions can occur especially in logic circuits, concurrent programming, and distributed computing.
Hazard
A hazard it a momentary unwanted switching transient at a circuits output (i.e glitch) due to uneven propagation delays along different paths of a combinational circuit.
In Electronics
See Hazard Free Circuits.
Consider the circuit:
The result of
This is an example of a hazard.
Critical and Non Critical Forms
A critical race condition occurs when the order in which internal variables change determines the eventual state the state machine will end up in
Likewise, a non-critical race condition is where order doesn't matter.
Static, Dynamic, and Essential Forms
A static race condition occurs when a signal and its negation are combined
A dynamic race condition occurs when there are multiple transitions when only one was intended
An essential race condition occurs when an input has two transitions in less than the total feedback propagation time
Design techniques such as K-maps help with discovering and eliminating race conditions.
In Software
A race condition can arise when a program has multiple code paths that are executing at the same time. If these paths take a different amount of time than expected, this can create bugs due to unanticipated behaviour.