1 Interprocess Communication 1. Ways of passing information 2. Guarded critical activities (e.g. updating shared data) 3. Proper sequencing in case of.

Slides:



Advertisements
Similar presentations
Module 6: Process Synchronization
Advertisements

Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
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.
1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved OPERATING SYSTEMS DESIGN.
25 seconds left…...
Synchronization Methods Topics Mutual-exclusion methods Producer/consumer problem Readers/writers problem CS 105 “Tour of the Black Holes of Computing”
Operating Systems Mehdi Naghavi Winter 1385.
Synchronization and Deadlocks
1 Implementations: User-level Kernel-level User-level threads package each u.process defines its own thread policies! flexible mgt, scheduling etc…kernel.
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Chapter 2 Processes and Threads
Chapter 6: Process Synchronization
Background Concurrent access to shared data can lead to inconsistencies Maintaining data consistency among cooperating processes is critical What is wrong.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
EEE 435 Principles of Operating Systems Interprocess Communication Pt II (Modern Operating Systems 2.3)
Process Synchronization. Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores.
Operating System Concepts and Techniques Lecture 12 Interprocess communication-1 M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and.
Mutual Exclusion.
CH7 discussion-review Mahmoud Alhabbash. Q1 What is a Race Condition? How could we prevent that? – Race condition is the situation where several processes.
CSC 322 Operating Systems Concepts Lecture - 8: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Interprocess Communication
Cpr E 308 Spring 2004 Recap for Midterm Introductory Material What belongs in the OS, what doesn’t? Basic Understanding of Hardware, Memory Hierarchy.
EEE 435 Principles of Operating Systems Interprocess Communication Pt I (Modern Operating Systems 2.3)
1 Threads CSCE 351: Operating System Kernels Witawas Srisa-an Chapter 4-5.
Concurrency, Race Conditions, Mutual Exclusion, Semaphores, Monitors, Deadlocks Chapters 2 and 6 Tanenbaum’s Modern OS.
Chapter 2: Processes Topics –Processes –Threads –Process Scheduling –Inter Process Communication (IPC) Reference: Operating Systems Design and Implementation.
Avishai Wool lecture Introduction to Systems Programming Lecture 4 Inter-Process / Inter-Thread Communication.
Synchronization Principles. Race Conditions Race Conditions: An Example spooler directory out in 4 7 somefile.txt list.c scores.txt Process.
Chapter 2.3 : Interprocess Communication
1 Outline Processes Threads Inter-process communication (IPC) Classical IPC problems Scheduling.
1 Interprocess Communication Race Conditions Two processes want to access shared memory at same time.
1 Race Conditions/Mutual Exclusion Segment of code of a process where a shared resource is accessed (changing global variables, writing files etc) is called.
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION Third Edition ANDREW S. TANENBAUM ALBERT S. WOODHULL Yan hao (Wilson) Wu University of the Western.
Operating Systems CSE 411 CPU Management Oct Lecture 13 Instructor: Bhuvan Urgaonkar.
1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
1 Processes Chapter Processes 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 2 Processes and Threads Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Cpr E 308 Spring 2004 Real-time Scheduling Provide time guarantees Upper bound on response times –Programmer’s job! –Every level of the system Soft versus.
Chapter 6 – Process Synchronisation (Pgs 225 – 267)
Process Synchronization Tanenbaum Ch 2.3, 2.5 Silberschatz Ch 6.
1 Interprocess Communication (IPC) - Outline Problem: Race condition Solution: Mutual exclusion –Disabling interrupts; –Lock variables; –Strict alternation.
2.3 interprocess communcation (IPC) (especially via shared memory & controlling access to it)
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Module 6: Process Synchronization Background The.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
Operating Systems Inter-Process Communications. Lunch time in the Philosophy Department. Dining Philosophers Problem (1)
1 Interprocess Communication Yücel Saygın | These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum.
Operating Systems COMP 4850/CISG 5550 Interprocess Communication, Part II Dr. James Money.
6.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Module 6: Process Synchronization.
1 Processes and Threads Part II Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
操作系统原理 OPERATING SYSTEM Chapter 2 Processes and Threads 进程与线程.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Synchronization Questions answered in this lecture: Why is synchronization necessary? What are race conditions, critical sections, and atomic operations?
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Mutual Exclusion Mutexes, Semaphores.
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
Interprocess Communication Race Conditions
Process Synchronization
Process Synchronization: Semaphores
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Process Synchronization
Critical section problem
Concurrency: Mutual Exclusion and Process Synchronization
Lecture 11: Mutual Exclusion
CS333 Intro to Operating Systems
Interprocess Communication & Synchronization
CSE 542: Operating Systems
CSE 542: Operating Systems
Synchronization CSE 2431: Introduction to Operating Systems
Presentation transcript:

1 Interprocess Communication 1. Ways of passing information 2. Guarded critical activities (e.g. updating shared data) 3. Proper sequencing in case of dependencies 2 and 3 apply to threads as well.

2 Race Conditions Two processes want to access shared memory at the same time. The final result depends on who runs precisely when.

3 Critical Regions (1) Part of the program where shared memory is accessed. Four conditions to provide correct and efficient communication : 1. Mutual exclusion: No two processes simultaneously in critical region 2. No assumptions made about speeds or numbers of CPUs 3. Progress: No process running outside its critical region may block another process 4. Fairness: No process must wait forever to enter its critical region (assuming fair scheduling!)

4 Critical Regions (2) Mutual exclusion using critical regions

5 Attempts for Mutual Exclusion Using Busy Waiting 1. Disabling all interrupts (only by kernel!) 2. Lock variables => fatal race condition 3. Strict alternation using spin locks - violates condition 3 4. Petersons solution 5. Test-and-set locks (TSL) Priority inversion problem (H loops while L is in critical section)

6 Strict Alternation Proposed solution to critical region problem (a) Process 0. (b) Process 1.

7 Petersons Solution Interested(process)=False => process is not in and does not want to enter critical section If both are interested, a process can enter only if it is the others turn.

8 Test-and-set lock Entering and leaving a critical region using the TSL instruction Atomic instruction, implemented in hardware

9 Sleep and Wakeup Producer-consumer problem with fatal race condition

10 Semaphores Integer variable with two atomic operations down: if 0, then go to sleep; if >0, then decrement value up:increment value and let a sleeping process to perform a down Implementation by disabling all interrupts by the kernel.

11 Semaphores The producer-consumer problem using semaphores

12 Mutexes Implementation of mutex_lock and mutex_unlock for synchronization of threads in user space

13 Monitors (1) Example of a monitor - only one process inside the monitor at any time

14 Monitors (2) Outline of producer-consumer problem with monitors –only one monitor procedure active at one time –buffer has N slots Condition variables with wait and signal

15 Message Passing The producer-consumer problem with N messages

16 Barriers Use of a barrier –processes approaching a barrier –all processes but one blocked at barrier –last process arrives, all are let through

17 Dining Philosophers Philosophers eat/think Eating needs 2 forks Pick one fork at a time How to prevent deadlock

18 A nonsolution to the dining philosophers problem

19 Deadlock-free code for Dining Philosophers (1)

20 Deadlock-free code for Dining Philosophers (2)

21 The Readers and Writers Problem

22 The Sleeping Barber Problem

23 Solution to the Sleeping Barber Problem