Please complete the fill in and answer the following questions below: Briefly ex
ID: 3576852 • Letter: P
Question
Please complete the fill in and answer the following questions below:
Briefly explain how the diming-philosophers processes using monitors for synchronization. monitor Dimming Philosophers { enum { THINKING;HUNGRY, EATING)state [5]; condition self [5]; void pickup (int i) { state[i] = HUNGRY; test(i); if (state[i] != EATING) self [i].wait; } void putdown (int i) { state[i] = THINKING; test left and right neighbors test((i + 1) % 5); test((i + 4)% 5); } void test (int i) { if ((state[(i + 4) % 5] != EATING) && (state[i] =HUNGRY) && (state[(i + 1)% 5] != EATING)) { _ state[i] = EATING; self[i] .signal 0; } } initialization_code() { for (int i = 0; iExplanation / Answer
1. proffessors can do three activities eating, thinking and waiting , there are five professor
2. self is the activity that the professor should posses for themselves.
3. pickup function is for picking up the fork. If the professor has one fork then he's hungry and he should wait for another fork to be available.
4. if the professor is not eating and has a fork then he is waiting for the other fork to be available till then.
5. Putdown function is for putting the fork which that professor is having down on the table.
6. then the professor sitting on the right side has a chance to eat if the other fork is available to him and he is hungry as well and after that the professor sitting on the left of the first professor has the same chance.
7.test function can make the professor to eat if the professor on his alternate seats are not eating.
8. This statement states that if the professor is hungry and the professors sitting on his sides are not eating then he can eat.
9. In signal function the hungry professor with two forks can eat for whatever time and qunatity he wants after which he can put the fork down which can be available to the professor sitting on his sides.
10. Initialization_code function starts the state[i] from i=0, which indicates that the professor sitting on the first postion on the round table starts with the state THINKING. Later i will increment that means other professors also will start thinking of eating.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.