Question: 7. (20 points) A Saving Account Problem A saving account is shared by several people (threads). Each person may deposit and withdraw funds from the

7. (20 points) A Saving Account Problem A saving account is shared by several people (threads). Each person may deposit and withdraw funds from the account. The current balance in the account is the sum of all deposits to date minuses the sum of all withdraws to date. The balance must never become negative. A deposit never has to delay (except for mutual exclusion), but a withdrawal has to wait until there are sufficient funds. (a) Develop a monitor to solve this problem. The monitor should have two procedures: deposit(amount) and withdraw(amount). Assume the arguments to deposit and withdraw are positive. (b) Modify your answer to (a) so that withdraws are serviced FCFS (first come first serve). For example, suppose the current balance is $200, and one customer is waiting to withdraw $300. If another customer arrives, he must wait, even if he wants to withdraw at most $200. Assume the waiting queue is FIFO. 7. (20 points) A Saving Account Problem A saving account is shared by several people (threads). Each person may deposit and withdraw funds from the account. The current balance in the account is the sum of all deposits to date minuses the sum of all withdraws to date. The balance must never become negative. A deposit never has to delay (except for mutual exclusion), but a withdrawal has to wait until there are sufficient funds. (a) Develop a monitor to solve this problem. The monitor should have two procedures: deposit(amount) and withdraw(amount). Assume the arguments to deposit and withdraw are positive. (b) Modify your answer to (a) so that withdraws are serviced FCFS (first come first serve). For example, suppose the current balance is $200, and one customer is waiting to withdraw $300. If another customer arrives, he must wait, even if he wants to withdraw at most $200. Assume the waiting queue is FIFO
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
