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 = I, , N (N s 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 (counterturn[j]) {
servedj[] = 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: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:00
Which of the following is not contained on the slide show toolbar? a. next button b. slide button c. close button d. pen too
Answers: 2
question
Computers and Technology, 22.06.2019 18:00
When is it appropriate to use an absolute reference
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
Awide variety of “ apps “ are available to customize devices. which category of app does the word processing software fall into?
Answers: 2
question
Computers and Technology, 22.06.2019 21:30
Write a function named printfloatrepresentation(float number) that will print the floating point representation of a number using the format given below. (sign bit) exponent in binary (assumed bit).significandfor example if the number passed an argument is 71 yourprogram should print (0) 10000101 (1).00011100000000000000000similarly if the number passed to the function as argument is -71 the program should print (1) 10000101 (1).00011100000000000000000
Answers: 3
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
Mathematics, 25.10.2020 14:00
question
Mathematics, 25.10.2020 14:00
question
Mathematics, 25.10.2020 14:00
Questions on the website: 13722363