Definition

# race condition

Contributor(s): Brien Posey

A race condition is an undesirable situation that occurs when a device or system attempts to perform two or more operations at the same time, but because of the nature of the device or system, the operations must be done in the proper sequence to be done correctly.

A simple example of a race condition is a light switch. In some homes there are multiple light switches connected to a common ceiling light. When these types of circuits are used, the switch position becomes irrelevant. If the light is on, moving either switch from its current position turns the light off. Similarly, if the light is off, then moving either switch from its current position turns the light on. With that in mind, imagine what might happen if two people tried to turn on the light using two different switches at exactly the same time. One instruction might cancel the other or the two actions might trip the circuit breaker.

Race conditions are most commonly associated with computer science. In computer memory or storage, a race condition may occur if commands to read and write a large amount of data are received at almost the same instant, and the machine attempts to overwrite some or all of the old data while that old data is still being read. The result may be one or more of the following: a computer crash, an "illegal operation," notification and shutdown of the program, errors reading the old data or errors writing the new data. A race condition can also occur if instructions are processed in the incorrect order.

Suppose for a moment that two processes need to perform a bit flip at a specific memory location. Under normal circumstances the operation should work like this:

 Process 1 Process 2 Memory Value Read value 0 Flip value 1 Read value 1 Flip value 0

In this example, Process 1 performs a bit flip, changing the memory value from 0 to 1. Process 2 then performs a bit flip and changes the memory value from 1 to 0.

If a race condition occurred causing these two processes to overlap, the sequence could potentially look more like this:

 Process 1 Process 2 Memory Value Read value 0 Read value 0 Flip value 1 Flip value 1

In this example, the bit has an ending value of 1 when its value should be 0. This occurs because Process 2 is unaware that Process 1 is performing a simultaneous bit flip.

### Preventing race conditions

In computing environments, race conditions can be prevented by serialization of memory or storage access. This means if read and write commands are received close together, the read command is executed and completed first by default.

In a network, a race condition may occur if two users attempt to access an available channel at the same instant, and neither computer receives notification the channel is occupied before the system grants access. Statistically, this kind of coincidence will most likely occur in networks with long lag times, such as those that use geostationary satellites. To prevent such a race condition from developing, a priority scheme must be devised. For example, the subscriber whose username begins with the earlier letter of the alphabet (or the lower numeral) may get priority by default when two subscribers attempt to access the system within a prescribed increment of time. Hackers can take advantage of race-condition vulnerabilities to gain unauthorized access to networks.

Race conditions occasionally occur in logic gates when certain inputs come into conflict. Because the gate output state takes a finite, nonzero amount of time to react to any change in input states, sensitive circuits or devices following the gate may be fooled by the state of the output, and thereby not operate properly.

This was last updated in April 2015

## Content

Find more PRO+ content and other member only offers, here.

#### Join the conversation

Send me notifications when other members comment.
How can a race condition be detected and corrected?
Cancel
In the case of web applications, my team has coordinated tests for concurrency and robustness by coming up with a list of operations and having each team member (as well as a few other people we recruited to help) perform those operations, all using the application at the same time.

Not a very sophisticated process, but it has worked for us to weed out issues. Once, using this method, we actually found a case of a data set being returned to the wrong user's session. That would have been bad had we not caught it!
Cancel

## SearchSolidStateStorage

• ### Will the eMMC controller market keep up with flash innovation?

EMMC host controllers may have a hard time handling advances in flash memory technology, like 3D NAND and newer connection ...

• ### Small but mighty eMMC flash storage grows its enterprise role

Many common devices, like your cell phone and tablet, use eMMC flash for storage. But the internet of things will soon make eMMC ...

• ### How eMMC 5.0 can improve your organization's small storage needs

The latest eMMC specification puts the tiny flash storage devices on a level playing field with many SSDs when it comes to speed ...

## SearchConvergedInfrastructure

• ### Holy COW! New Hampshire med center turns to Pivot3 vSTAC for VDI

Southern New Hampshire Medical Center put its traditional server-storage architecture out to pasture when it added ...

• ### Examining the state of the hyper-converged infrastructure market

HCI market leaders have emerged, but some question how long they'll retain their hold over the rapidly evolving segment.

• ### Nutanix networking management includes microsegmentation, APIs

Nutanix adds 'one-click networks' to its hyper-convergence as part of its plans to become an on-premises version of Amazon Web ...

## SearchCloudStorage

• ### Hitachi Content Intelligence searches, analyzes data

Hitachi Content Intelligence, built into Hitachi Content Portfolio object storage, extracts data and metadata from repositories ...

• ### OpenStack Newton storage features include data encryption

Storage updates in OpenStack's Newton release include at-rest data encryption in Swift, a message API for async tasks in Cinder ...

Google Cloud Platform expands Zadara Storage VPSA and ZIOS hyperscale cloud SaaS options, which already support Amazon Web ...

## SearchDisasterRecovery

• ### Case closed: Law firm selects iland DRaaS for faster, easier DR

Minutes count in legal work, and Graubard Miller needed a simpler platform for disaster recovery. The verdict: The law firm chose...

• ### Disaster recovery and business continuity plans require updating

Updating business continuity and disaster recovery plans can seem daunting, but it becomes easier when you delegate tasks and ...

• ### Enhance cloud resiliency with proper data management

Explore factors that can influence your level of cloud resilience, such as outages in different geographic locations, and the ...

## SearchDataBackup

• ### Mobile data backup helped by encryption, data policies

More and more corporate data is being created and living on mobile devices such as tablets and smartphones. That dynamic requires...

• ### Veeam backup software protects mental health facility's Hyper-V

A mental health and addiction facility had an ongoing problem with its virtual machine backup and recovery until it was solved ...

• ### Commvault backup software builds in cloud capability, virtualization

By embracing new technology, like the cloud and virtualization, Commvault Systems provides businesses with a complete backup ...

Close