Race Condition

From CasGroup

Jump to: navigation, search

A race condition can be defined as an anomalous behavior due to unexpected unexpected ordering of events and critical dependence on the relative timing of events. It characterizes an undesirable situation in a concurrent or distributed system where the cause for the output of a process depends on the arbitrary timing of other events. There are many participants (messages, threads, etc.) which have different speed, and each of the participants can win. Only the winner determines the resulting behavior.

In other words, the output of the process is unexpectedly and dependents critically on a sequence or timing of other events. For instance, a computation in a distributed system may depend on the arrival order of two different contradictory messages, the first says "maintain object", whereas the second says "release object", and the message which arrives first - the winner of the race - determines the result. A race condition can also occur when multiple processes access and manipulate the same data concurrently, and the outcome of the execution depends on the particular order in which the access takes place.

Race conditions are not only undesirable because the program doesn't work as it's supposed to do. In debugging they are also very undesirable, because you have to "run the race" many times before you can reproduce a situation which a certain fault, error or failure. The error may also vanish if you slow the processes down by debugging the computation step-by-step.

Personal tools