Download presentation
Presentation is loading. Please wait.
Published byNancy Nash Modified over 8 years ago
1
Chapter IX Review Questions and Problems Jehan-François Pâris jfparis@uh.edu
2
Problem I: RPC Consider the following C function void trans (int *from, int *to, double amount){ *from -= amount; *to += amount; } //trans
3
Problem I: RPC What would happen if we execute trans (&bal, & bal, 5000.00); using –regular procedure calls ? –RPC calls?
4
Problem I : RPC We will have problems with RPC!
5
Problem II: mutual exclusion What is wrong with the following solution to the mutual exclusion problem? //Global array shared int wait[2] = {0, 1}; void enter(int pid) { // pid must be 0 or 1 while (wait[pid]); } // enter_region void leave_region(int pid) { wait[pid] = 1; wait[1 – pid] = 0; } // leave_region
6
Problem III: monitors A pizza oven has enough space inside for ten pizzas and a small opening through which a single cook can put a pizza in the oven and remove it when it is ready. Add the required pseudocode to the following monitor to ensure the smooth operation of the oven.
7
Problem III: monitors Class pizza_oven { private int npizzas; // pizzas in oven private condition not_empty; private condition not_full;
8
Problem III: monitors – public void synchronized put_a_pizza() { _______________________ _______________________ put_a_pizza_in_the_oven(); _______________________ } // put_a_pizza()
9
Problem III: monitors – public void synchronized remove_a_pizza() { ___________________________ ___________________________ take_a_pizza_from_the_oven(); ___________________________ } // remove_a_pizza()
10
Problem III: monitors – pizza() { npizzas = 0; } // constructor } // Class oven
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.