Race conditions are possible in many computer systems. Consider an accounting system of an organization where multiple users have access to an account to which they can either deposit or withdraw from: deposit(amount) and withdraw(amount). These two functions are passed the amount that is to be deposited or withdrawn from the account balance. Assume that Mary and Joe are employees who have access to this account. Currently, the balance in the account is $3000. If Mary executes deposit(500) and simultaneously Joe executes withdraw(300) from the account, describe how a race condition is possible and what might be done to prevent the race condition from occurring. Show the possible balances with race condition and when race condition is prevented.
Race conditions are possible in many computer systems. Consider an accounting system of an organization where multiple users have access to an account to which they can either deposit or withdraw from: deposit(amount) and withdraw(amount). These two functions are passed the amount that is to be deposited or withdrawn from the account balance. Assume that Mary and Joe are employees who have access to this account. Currently, the balance in the account is $3000. If Mary executes deposit(500) and simultaneously Joe executes withdraw(300) from the account, describe how a race condition is possible and what might be done to prevent the race condition from occurring. Show the possible balances with race condition and when race condition is prevented.
Step by step
Solved in 2 steps