*******PLEASE EXPLAIN HOW YOU GOT THE ANSWER, because i have my own answers to c
ID: 3565579 • Letter: #
Question
*******PLEASE EXPLAIN HOW YOU GOT THE ANSWER, because i have my own answers to compare it too and how you obtained your answer.
Operating System Concurrent processes
PROBLEM SAMPLE 2
Q5 (18 points)
N customers enter the bakery to buy cookies. Each customer gets its turn[i], by computing a next
number, and waits to be served. The clerk uses a counter to keep track of the served customers.
The clerk serves the customer whose turn[i] is equal to the counter. After each serve( ), the
clerk increments the counter. When the counter reaches N, the clerk considers that it is done and
leaves for home.
(Shared variables)
turn[i] = 0 i = 1,
Explanation / Answer
Consider the following flow of execution of the operating system concurrent process problem:
a)
Two customers cannot compute same number. When a customer enters the bakery, customer will be provided with a number which determines the turn of that person. Once the number is given to one customer, the next number will be computed and the next customer is provided with successive number.
b)
Each customer will have different number value. In turn, each customer will have different turns. Customers with different numbers will not get same turn. So, the customer will get a chance to select the cookies he need. There will not any clash or competition. Once the transaction completely ends with one customer, the next customer will get the chance to buy cookies.
c)
The process is concurrent. Both clerk() and customer() start at same time. The customer will have a number given when the clerk starts serving. Customers will not starve by waiting forever as the serving process starts as soon the customer is given the number.
d)
The clerk will have to all the customers who are waiting for the service. N is the number of customers. In the beginning of the program, N is defined to be 10. It can have maximum of 10 and clerk will serve maximum of 10 customers. Hence, the clerks leaves the bakery once the counter reaches “N”.
e)
The program runs logic only for clerk and customer. The number of cookies or stock of the cookies is not taken care. The code does not consider the stock of cookies. Hence, the clerk running out of cookies is not predictable from the code.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.