Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions

Question

2. What is the business value of security and control?

Answered: 1 week ago