Question: A certain bank account is shared by n persons. That is, any of the n account owners should be able to deposit money to or
A certain bank account is shared by n persons. That is, any of the n account owners should be able to deposit money to or withdraw money from the account. To prevent race conditions while accessing the shared account, you will write a monitor construct The monitor will have two procedures withdraw x) and on it (x) Withdrawers will be executed by a transaction that deducts X dollars from the balance. Similarly, deposit(x) will be executed by a transaction that adds X dollars to the balance. Each of the n processes can execute either with or depot Your monitor construct should suspend the transaction (proceso) invoking the withdraw function and only there are not cont funds. The balance should never be negative during the execution Multiple withdraw operation(s) may be all suspended it the balance is low. Following a deposit, suspended withdraw operation(n) munt be completed subject to the availability of funds. (For example, ir balonco = 100 and one process is suspended during the withdraw(500) transaction, a deposit of 200 dollars shouldn't enable the completion of the pending withdraw operation. When possible, multiple suspended withdraw operation should be resumed after a deposit But you should always give priority to the pending withdraw operation which had been waiting longest if that transaction can't be completed after the most recent deposit, other pending withdraw operations should not be able to resume either. HintThe FCES ordering in condition-variable waltina.gueue assumption given below. will automatically satisfy this last requirement Write the monitor construct including withdrawx) and deposit (x) procedures to solve this problem. You will assume that standard monitor wait and monitor signal operations are available for condition variables (as discussed during the lecturos). If multiple processes are suspended on a condition variable C. the execution of C signal() by Process A will resume the process waiting the longest on C (In other words, you will assume First-Come First Served ordering in condition-variable waiting queues). However, this newly awakened process will have to wait until A leaves the monitor (or waits for another condition). There is no signala or similar primitive that awakens all the processes waiting on a condition variable at once. Your solution should avoid race conditions, deadlocks and busy waiting
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
