Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
Race condition

Race condition

Dec 26 2011

Race condition. Another name: data race. A programming error in a multitask system when the system's work depends on the order in which code sections are executed. Race condition is a classical Heisenbug. Race condition occurs when several threads of a multithread application try to simultaneously get access to the data, meanwhile at least one thread performs saving. Race condition can lead to unpredictable results and they are often difficult to detect. Sometimes race condition's consequences occur only after a large period of time and in some other part of the application. Besides, such errors are very difficult to reproduce. To avoid race condition, synchronization methods are used allowing you to properly arrange operations executed by different threads. Here is an example. Assume one thread execute operation x = x + 3 over a shared variable x, while another thread executes operation x = x + 5. These operations for each thread are actually divided into three separate suboperations: to read x from memory, to increase x and then write x in memory. Depending on mutual order of suboperations executed by the threads the final value of x variable can excess the original one by 3, 5 or 8.

References

Popular related articles


Comments (0)

Next comments next comments
close comment form
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam