Download
ipc and ips problems n.
Skip this Video
Loading SlideShow in 5 Seconds..
IPC and IPS Problems PowerPoint Presentation
Download Presentation
IPC and IPS Problems

IPC and IPS Problems

92 Vues Download Presentation
Télécharger la présentation

IPC and IPS Problems

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. IPC and IPS Problems Jehan-François Pârisjfparis@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 executetrans (&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 arrayshared int wait[2] = {0, 1}; void enter(int pid) { // pid must be 0 or 1while (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