Question: Solve using two separate .c language programming files #1 Saving Account Problem. A saving account is shared by several people (threads). Each person may deposit

Solve using two separate .c language programming files

#1 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 from the results of the previous task 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. Write two programs to simulate solutions to part a and b, respectively. Each customer should be a thread that repeatedly does a deposit or withdrawal, then goes out to lunch for a random amount of time. The bank is to be represented by a monitor that has two operations: deposit(amount) and withdraw(amount). You may assume that amount is positive. You may also use two kinds of customer threads if you wish, one kind for deposits and one for withdrawals. Also, insert a sched_yield()as the last line in the deposit and withdraw functions.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!