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

Slides:



Advertisements
Similar presentations
Operating Systems Semaphores II
Advertisements

Operating Systems: Monitors 1 Monitors (C.A.R. Hoare) higher level construct than semaphores a package of grouped procedures, variables and data i.e. object.
CHAPTER3 Higher-Level Synchronization and Communication
1 C OMP 346 – W INTER 2015 Tutorial # 5. Semaphores for Barrier Sync A barrier is a type of synchronization method. A barrier for a group of threads or.
Ch 7 B.
May 23, 2002Serguei A. Mokhov, 1 Synchronization COMP346/ Operating Systems Tutorial 3 Revision 1.2 October 7, 2003.
CSCC69: Operating Systems
Concurrent Programming Problems OS Spring Concurrency pros and cons Concurrency is good for users –One of the reasons for multiprogramming Working.
Chapter 6 Process Synchronization Bernard Chen Spring 2007.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Process Synchronization. Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores.
CH7 discussion-review Mahmoud Alhabbash. Q1 What is a Race Condition? How could we prevent that? – Race condition is the situation where several processes.
China’s Software Industry August 2006 Instructor: Hengming Zou, Ph.D.
SOLUTIONS FOR THE SECOND 4330 QUIZ Jehan-Francois Paris Summer 2014.
1 Condition Synchronization. 2 Synchronization Now that you have seen locks, is that all there is? No, but what is the “right” way to build a parallel.
Operating Systems CMPSC 473 Mutual Exclusion Lecture 13: October 12, 2010 Instructor: Bhuvan Urgaonkar.
5.6 Semaphores Semaphores –Software construct that can be used to enforce mutual exclusion –Contains a protected variable Can be accessed only via wait.
Language Support for Concurrency. 2 Common programming errors Process i P(S) CS P(S) Process j V(S) CS V(S) Process k P(S) CS.
5.6.2 Thread Synchronization with Semaphores Semaphores can be used to notify other threads that events have occurred –Producer-consumer relationship Producer.
Synchronization Principles. Race Conditions Race Conditions: An Example spooler directory out in 4 7 somefile.txt list.c scores.txt Process.
CS444/CS544 Operating Systems Synchronization 2/21/2007 Prof. Searleman
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
A. Frank - P. Weisberg Operating Systems Introduction to Cooperating Processes.
CS444/CS544 Operating Systems Classic Synchronization Problems 2/26/2007 Prof. Searleman
Concurrency - 1 Tasking Concurrent Programming Declaration, creation, activation, termination Synchronization and communication Time and delays conditional.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
More Synchronisation Last time: bounded buffer, readers-writers, dining philosophers Today: sleeping barber, monitors.
Atomic Operations David Monismith cs550 Operating Systems.
Arrays and ArrayLists in Java L. Kedigh. Array Characteristics List of values. A list of values where every member is of the same type. Each member in.
IMPLEMENTING ARRAYLIST – Part 2 COMP 103. RECAP  Abstract Classes – overview, details in 2 nd year  Implementing the ArrayList: size(), get(), set()
Synchronization II: CPE Operating Systems
(Quickly) More on Null references: A null reference is a pointer to nothing. Pointers = space for address in memory Think of RAM, with each space in memory.
1 Using Semaphores CS 241 March 14, 2012 University of Illinois Slides adapted in part from material accompanying Bryant & O’Hallaron, “Computer Systems:
CSC321 Concurrent Programming: §5 Monitors 1 Section 5 Monitors.
Chap 6 Synchronization. Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms.
Solutions to Second 4330/6310 Quiz Spring First question Which of the following statements are true or false (2 points) and why? (3 points)
More review questions for the second midterm COSC 4330/6310.
1 Program5 Due Friday, March Prog4 user_thread... amount = … invoke delegate transact (amount)... mainThread... Total + = amount … user_thread...
2001 Networking Operating Systems (CO32010) 1. Operating Systems 2. Processes and scheduling 4.
Synchronization Producer/Consumer Problem. Synchronization - PC with Semaphores2 Abstract The producer/consumer problem is a classical synchronization.
Java Thread and Memory Model
Dr. R R DOCSIT, Dr BAMU. Basic Java :Multi Threading Cont. 2 Objectives of This Session Explain Synchronization in threads Demonstrate use of.
CIS Operating Systems Synchronization Professor Qiang Zeng Fall 2015.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Monitors CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Problems with Semaphores Used for 2 independent purposes –Mutual exclusion –Condition synchronization Hard to get right –Small mistake easily leads to.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles Synchronization Emery Berger and Mark Corner University.
Lecture 3 Concurrency and Thread Synchronization     Mutual Exclusion         Dekker's Algorithm         Lamport's Bakery Algorithm.
Comunication&Synchronization threads 1 Programación Concurrente Benemérita Universidad Autónoma de Puebla Facultad de Ciencias de la Computación Comunicación.
Chapter 71 Monitors (7.7)  A high-level-language object-oriented concept that attempts to simplify the programming of synchronization problems  A synchronization.
Operating System Concepts and Techniques Lecture 14 Interprocess communication-3 M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and.
Chapter IX Review Questions and Problems Jehan-François Pâris
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Operating Systems NWEN 301 Lecture 6 More Concurrency.
Solutions to the second midterm COSC 4330/6310 Summer 2013.
Day 13 Concurrency.
Operating Systems CMPSC 473
Monitors.
Day 15 Concurrency.
CS510 Operating System Foundations
CSCI 511 Operating Systems Chapter 5 (Part C) Monitor
Peculiarity of Peterson’s Solution to Process Synchronization
Lecture 25 Syed Mansoor Sarwar
Thread Synchronization
Semaphore Originally called P() and V() wait (S) { while S <= 0
Counter in Java class Counter { private integer count = 0; public void Increment() synchronized { ++count; } public integer GetCount() synchronized.
CSE 451: Operating Systems Winter 2004 Module 7+ Monitor Supplement
Problems discussed in the review session for the second midterm
Chapter 11 Classes.
Don Porter Portions courtesy Emmett Witchel
Presentation transcript:

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

Problem I: RPC Consider the following C function void trans (int *from, int *to, double amount){ *from -= amount; *to += amount; } //trans

Problem I: RPC What would happen if we execute trans (&bal, & bal, ); using –regular procedure calls ? –RPC calls?

Problem I : RPC We will have problems with RPC!

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

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

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

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