Question: 3. Program Design (10) There are black and white balls in a box. Now two processes A and B are employed to separate the black
3. Program Design (10) There are black and white balls in a box. Now two processes A and B are employed to separate the black and white balls. Process A takes out a black ball each access, and process B takes out a white ball each access. Write the PV semaphore operations for process A and B for the following situations, respectively. Note that the semaphore and its initial value should be defined. 1) When A is using the box, B is not allowed to use the box. When B is using the box, As is not allowed to use the box. Write the PV operations for the ball producer machine and process A/B 2) The two processes should take turns to pick up balls from the box, which means that after process A access to the box, process B should access to the box, then process A, process B, process A, process B... Write the PV operations for the ball producer machine and process A/B 4. Short-answer Questions (20) 1.(5) Draw the diagram of process state. 2.(6) Describe the differences among short-term, medium-term and long-term scheduling. 3.(4) Peterson's solution is a classic software-based solution to the critical-section problem. Explain why Peterson's solution can solve the critical-section problem. Here is the Peterson's solution. do { flag[i] = true; turn =j; while (flag[i] && turn == j); I/critical section flag[i] = false; //remainder section } while (true); 4.(5) What is deadlock? List the four necessary conditions for deadlock
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
