When shared resources are modified at the same time by multiple resources, data errors or inconsistencies may occur. An example of data inconsistency that can occur because of a race condition is what can happen with a shared bank account. Dear Old Dad adds money to an account and Poor Student withdraws from the account. When either accesses the account, they execute a critical section consisting of three steps.
Read account balance
Update the balance
Write the new balance to the account

One day, Dear Old Dad checks the balance and seeing that it is $100 decides to add $50 to the account. Unfortunately, access to the account is not locked, so just then Poor Students withdraws $20 from the account and the new balance is recorded as $80. After adding the $50, Dear Old Dad records the balance as $150, rather than $130, as it should be.
The nature of the problem is more clear when we examine the assembly language code for such an operation:
.

The root of the problem stems from a context switch occurring in the middle of the execution of the critical section.