subject

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, ..., N (N is initialized to 10) number = 0; served [i]=0; counter = 0; customer i() {number++; turn[i] = number; while (!served[i]){}; getServed(); go home;} clerk () {while (counter < N){counter++; for (int j=1; j<=N; j++){if (counter == turn[j]){served[j] = True; serve();//simulated by sleep served[j] = True; serve();//simulated by sleep served[j] = False;//if}//for}//while leave;}//clerk
All customer() and clerk() processes execute concurrently.
a) Is it possible for two customers to compute the same number? Explain. If yes, give the execution sequence that will show it.
b) Under the hypothesis that each customer has computed a different number value, is it possible for customers to compete for the same cookies (because their turn [i] is the same)? Explain. If yes, give the execution sequence that will show it.
c) Under the hypothesis that all customers have their turn [i] set before the clerk starts executing, is it possible for a customer to starve (busy wait forever)? Explain. If yes, give the execution sequence that will show it.
d) Is it possible for the clerk to never go home? Explain. If yes, give the execution sequence that will show it.
e) If there are N cookies on the shelf, is it possible for the clerk to run out of cookies before all the customers got served? Explain. If yes, give the execution sequence that will show it.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 13:30
Asoftware company hired ray, a college graduate to work in their development team. ray is assigned to work in the coding phase of a project. what happens during the coding phase of a software development project? a. the customer receives a working model of the software. b. developers convert the program design into code. c. developers gather requirements directly from the stakeholders. d. testing teams check the product for quality.
Answers: 1
question
Computers and Technology, 22.06.2019 15:20
This os integrated the processing power of windows nt with the easy-to-use gui of windows 98. windows 2000 windows 3.11 windows for workgroups windowa millennium edition
Answers: 1
question
Computers and Technology, 23.06.2019 19:00
Acompany is hiring professionals for web designing. the firm is small with few resources. they want employees who possess problem-solving skills and can independently carry out responsibilities. which kind of employee should they select?
Answers: 2
question
Computers and Technology, 24.06.2019 03:00
Click the "draw structure" button to activate the drawing utility. draw two diastereomers of (1z,4r)−1,4−dimethylcyclodecene and name them, including (e)/(z) and (r)/(s) notation. part 1 out of 4 draw the diastereomer containing a chiral center with s configuration here. window open
Answers: 1
You know the right answer?
N customers enter the bakery to buy cookies. Each customer gets its turn[i], by computing a next num...
Questions
question
Health, 28.09.2021 23:40
question
Social Studies, 28.09.2021 23:40
question
Mathematics, 28.09.2021 23:40
Questions on the website: 13722361