subject

Ten children wait to get their gift. Each child gets its turn[i] by computing a number[i]. A clown has in his hat ten balls; each ball has a unique number, from one to ten. After all children have their turn set, the clown is ready to share the gifts. The clown picks a random ball, and gives a gift to the child(ren) whose turn value is the same as the number on the ball (after that, he throws away the selected ball). Once the clown has no balls left, he leaves. (Shared variables) turn() = 0 i= 1, ... 10 (N=10) number[= 0; called/=0; numBalls= 10 child (int i) { clown() { number[i] =1+max (number[1], number(2)... number[N]); while (numBalls > OX turn[i] = number[i]; pick a ball; Il sleep while (!called[i]){ }; for(int j=1; j<=N; j++){ get the gift; Il sleep if(turn[i] == number on the ball){ numBalls- called[i] = True; go home; Il sleep give the gift l/sleep } } // for } // while leave; } llclown Note: you can break down the computation of number into: load , compute, store All child() processes and clown execute concurrently. a) Is it possible for two children to store the same value for numberſij? (for example number[2] = 2 and number[3] = 2) If yes, give the execution sequence that shows it. If no, explain why not.
b) On the hypothesis that each child has a different number(i), is it possible for two or more children to have the same value for their turn variable? Explain. If yes, give the execution sequence that will show it. If not possible, explain why.

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 21:30, Devan6264
You need to write some code that responds to a text change in a jtextfield. how can you do that? create a class that implements the interface actionlistener and override the method textfieldchanged create a class that extends the superclass actionlistener and override the method actionperformed create a class that implements the interface actionlistener and override the method actionperformed create a class that extends the superclass actionlistener and override the method textfieldchanged
Answers: 2
image
Computers and Technology, 21.06.2019 22:30, klk597703
Aprovides legal protection for something an individual has created
Answers: 1
image
Computers and Technology, 22.06.2019 10:00, kimmmmmmy333
According to alisa miller foreign news bureaus
Answers: 3
image
Computers and Technology, 22.06.2019 18:00, alyssacyamamoto8050
Budgets you to do all of the following expect a) send frivolously b) avoid over spending c) gain financial independence d) examine your priorities and goals
Answers: 2
You know the right answer?
Ten children wait to get their gift. Each child gets its turn[i] by computing a number[i]. A clown h...

Questions in other subjects: