Presentation is loading. Please wait.

Presentation is loading. Please wait.

IPC and IPS Problems Jehan-François Pâris

Similar presentations


Presentation on theme: "IPC and IPS Problems Jehan-François Pâris"— Presentation transcript:

1 IPC and IPS 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 3: 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. (8×2 pts) Class pizza_oven { private int npizzas; // pizzas in oven private condition not_empty; private condition not_full; public void synchronized put_a_pizza() { __________________________________________ __________________________________________ put_a_pizza_in_the_oven(); __________________________________________ __________________________________________ } // put_a_pizza() public void synchronized remove_a_pizza() { __________________________________________ __________________________________________ take_a_pizza_from_the_oven(); __________________________________________ __________________________________________ } // remove_a_pizza() oven() { npizzas = 0; } // constructor } // Class oven

7 Problem 3: monitors Class pizza_oven { private int npizzas; // pizzas in oven private condition not_empty; private condition not_full; public void synchronized put_a_pizza() { __________________________________________ __________________________________________ put_a_pizza_in_the_oven(); __________________________________________ __________________________________________ } // put_a_pizza() public void synchronized remove_a_pizza() { __________________________________________ __________________________________________ take_a_pizza_from_the_oven(); __________________________________________ __________________________________________ } // remove_a_pizza() oven() { npizzas = 0; } // constructor } // Class oven

8 Problem 3: monitors Pizan() { npizzas = 0; } // constructor } // Class oven


Download ppt "IPC and IPS Problems Jehan-François Pâris"

Similar presentations


Ads by Google