ALL > Computer and Education > courses > university courses > undergraduate courses > Operating System > zstu-(2021-2022)-1 > student homework directories > 2019329621182刘辰萱 >
2019329621182-刘辰萱-homework-5 Version 0
👤 Author: by rootfreanjacn 2021-12-25 22:44:21

An example of data inconsistency that can occur because of a race condition is what can happen with a shared bank account. Dad adds money to an account and Student withdraws from the account. When either accesses the account, they execute a critical section consisting of three steps.





  1. Read account balance




  2. Update the balance




  3. Write the new balance to the account




One day, 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 Students withdraws $20 from the account and the new balance is recorded as $80. After adding the $50, Dad records the balance as $150, rather than $130, as it should be.


The solution:When one user performs operations on an account, another user is prohibited from performing operations

Please login to reply. Login

Reversion History

Loading...
No reversions found.