Lably
Skip to content

Race condition

When a system's behavior depends on timing of uncontrollable events

  • 17 min read
  • 4 chapters

Related on Lably

Through Electronics, Software and System

The term race condition was in use by 1954, for example in David A. Huffman's doctoral thesis "The synthesis of sequential switching circuits".

Race conditions can occur especially in logic circuits or concurrent or distributed software programs. Using mutual exclusion can prevent race conditions.

In electronics

A typical example of a race condition may occur when a logic gate combines signals that have traveled along different paths from the same source. The inputs to the gate can change at slightly different times in response to a change in the source signal. The output may, for a brief period, change to an unwanted state before settling back to the designed state. Certain systems can tolerate such glitches, but if this output functions as a clock signal for further systems that contain memory, for example, the system can rapidly depart from its designed behaviour (in effect, the temporary glitch becomes a permanent glitch).

Consider, for example, a two-input AND gate fed with the following logic: output=A∧A¯A logic signal A on one input and its Boolean negation A¯ on another input can never, in theory, output a true value as A∧A¯≠1. If, however, changes in the value of A take longer to propagate to the second input than the first when A changes from false to true, then a brief period will ensue during which both inputs are true, and so the gate's output will also be true.

A practical example of a race condition can occur when logic circuitry is used to detect certain outputs of a counter. If all the bits of the counter do not change exactly simultaneously, there will be intermediate patterns that can trigger false matches.

Critical and non-critical forms

A critical race condition occurs when the order in which internal variables are changed determines the eventual state that the state machine will end up in.

A non-critical race condition occurs when the order in which internal variables are changed does not determine the eventual state that the state machine will end up in.

Static, dynamic, and essential forms

A static race condition occurs when a signal and its complement are combined.

A dynamic race condition occurs when it results in multiple transitions when only one is intended. They are due to interaction between gates. It can be eliminated by using no more than two levels of gating.

An essential race condition occurs when an input has two transitions in less than the total feedback propagation time. Sometimes they are cured using inductive delay line elements to effectively increase the time duration of an input signal.

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Computing and communication