Chapter IX Review Questions and 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 Chapter 5 Concurrency: Mutual Exclusion and Synchronization Principals of Concurrency Mutual Exclusion: Hardware Support Semaphores Readers/Writers Problem.
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.
Chapter 8. Operator Overloading Operator overloading gives the opportunity to redefine C++ Operator overloading refers to redefine C++ operators such.
May 23, 2002Serguei A. Mokhov, 1 Synchronization COMP346/ Operating Systems Tutorial 3 Revision 1.2 October 7, 2003.
CSCC69: Operating Systems
Chapter 6 Process Synchronization Bernard Chen Spring 2007.
Chapter 6: Process Synchronization
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.
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.
Chapter 11 Distributed Processing Co-routines Each co-routine has own stack for activation records Keeps track of point to RESUME Symmetric (peer) relationship.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts Amherst Operating Systems CMPSCI 377 Lecture.
5.6 Semaphores Semaphores –Software construct that can be used to enforce mutual exclusion –Contains a protected variable Can be accessed only via wait.
Chapter 6: Process Synchronization. Outline Background Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores Classic Problems.
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
Chapter 6 – Concurrent Programming Outline 6.1 Introduction 6.2Monitors 6.2.1Condition Variables 6.2.2Simple Resource Allocation with Monitors 6.2.3Monitor.
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.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
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()
Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.
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...
Synchronization Producer/Consumer Problem. Synchronization - PC with Semaphores2 Abstract The producer/consumer problem is a classical synchronization.
Chapter VI Deadlocks Jehan-François Pâris
Threads II IS Outline  Quiz  Thread review  Stopping a thread  java.util.Timer  Swing threads javax.swing.Timer  ProgressMonitor.
Java Thread and Memory Model
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
IPC and IPS Problems Jehan-François Pâris
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.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
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
Midterm review: closed book multiple choice chapters 1 to 9
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:

Chapter IX Review Questions and 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 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.

Problem III: monitors Class pizza_oven { private int npizzas; // pizzas in oven private condition not_empty; private condition not_full;

Problem III: monitors – public void synchronized put_a_pizza() { _______________________ _______________________ put_a_pizza_in_the_oven(); _______________________ } // put_a_pizza()

Problem III: monitors – public void synchronized remove_a_pizza() { ___________________________ ___________________________ take_a_pizza_from_the_oven(); ___________________________ } // remove_a_pizza()

Problem III: monitors – pizza() { npizzas = 0; } // constructor } // Class oven