6/16/2015 Chapter Eight Process Synchronisation. Index Objectives Concurrent processes and Asynchronous concurrent processes Process synchronisation Mutual.

Slides:



Advertisements
Similar presentations
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
Advertisements

1 Chapter 5 Concurrency: Mutual Exclusion and Synchronization Principals of Concurrency Mutual Exclusion: Hardware Support Semaphores Readers/Writers Problem.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 5: CPU Scheduling.
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.
Producer-Consumer One common situation: Producers and consumers communicate via a buffer.
1 Semaphores and Monitors CIS450 Winter 2003 Professor Jinhua Guo.
1 Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Operating Systems CMPSC 473 Mutual Exclusion Lecture 13: October 12, 2010 Instructor: Bhuvan Urgaonkar.
Informationsteknologi Wednesday, September 26, 2007 Computer Systems/Operating Systems - Class 91 Today’s class Mutual exclusion and synchronization 
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
1 Concurrency: Mutual Exclusion and Synchronization Chapter 5.
5.6 Semaphores Semaphores –Software construct that can be used to enforce mutual exclusion –Contains a protected variable Can be accessed only via wait.
5.6 Semaphores Semaphores –Software construct that can be used to enforce mutual exclusion –Contains a protected variable Can be accessed only via wait.
Concurrent Processes Lecture 5. Introduction Modern operating systems can handle more than one process at a time System scheduler manages processes and.
OS Spring’04 Concurrency Operating Systems Spring 2004.
Semaphores. Announcements No CS 415 Section this Friday Tom Roeder will hold office hours Homework 2 is due today.
Classical Synchronization Problems. Paradigms for Threads to Share Data We’ve looked at critical sections –Really, a form of locking –When one thread.
Process Synchronization
Chapter 2.3 : Interprocess Communication
Semaphores CSCI 444/544 Operating Systems Fall 2008.
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
Semaphores. Readings r Silbershatz: Chapter 6 Mutual Exclusion in Critical Sections.
Semaphores and Bounded Buffer Andy Wang Operating Systems COP 4610 / CGS 5765.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
6.3 Peterson’s Solution The two processes share two variables: Int turn; Boolean flag[2] The variable turn indicates whose turn it is to enter the critical.
Critical Problem Revisit. Critical Sections Mutual exclusion Only one process can be in the critical section at a time Without mutual exclusion, results.
Operating Systems CMPSC 473 Mutual Exclusion Lecture 14: October 14, 2010 Instructor: Bhuvan Urgaonkar.
Internet Software Development Controlling Threads Paul J Krause.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
Chapter 7 -1 CHAPTER 7 PROCESS SYNCHRONIZATION CGS Operating System Concepts UCF, Spring 2004.
CY2003 Computer Systems Lecture 04 Interprocess Communication.
Chapter 6 – Process Synchronisation (Pgs 225 – 267)
CSE 451: Operating Systems Winter 2012 Semaphores and Monitors Mark Zbikowski Gary Kimura.
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure the orderly execution.
Lecture 6: Monitors & Semaphores. Monitor Contains data and procedures needed to allocate shared resources Accessible only within the monitor No way for.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles Synchronization Emery Berger and Mark Corner University.
Concurrency in Shared Memory Systems Synchronization and Mutual Exclusion.
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
Process Synchronization. Objectives To introduce the critical-section problem, whose solutions can be used to ensure the consistency of shared data To.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 5: Process Synchronization.
Process Synchronization. Concurrency Definition: Two or more processes execute concurrently when they execute different activities on different devices.
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
Process Synchronization: Semaphores
Background on the need for Synchronization
“Language Mechanism for Synchronization”
Process Synchronization
Concurrent Processes.
Concurrency: Mutual Exclusion and Synchronization
The Critical-Section Problem (Two-Process Solution)
Midterm review: closed book multiple choice chapters 1 to 9
Semaphore Originally called P() and V() wait (S) { while S <= 0
Process Synchronization
Synchronization Hank Levy 1.
Lecture 2 Part 2 Process Synchronization
CSE 451: Operating Systems Winter Module 8 Semaphores and Monitors
CSE 451: Operating Systems Winter Module 7 Semaphores and Monitors
CSE 451: Operating Systems Winter Module 7 Semaphores and Monitors
Synchronization Hank Levy 1.
CSE 153 Design of Operating Systems Winter 19
CSE 153 Design of Operating Systems Winter 2019
CSE 451: Operating Systems Winter Module 7 Semaphores and Monitors
CIS 720 Lecture 6.
Steve’s Concurrency Slides
Presentation transcript:

6/16/2015 Chapter Eight Process Synchronisation

Index Objectives Concurrent processes and Asynchronous concurrent processes Process synchronisation Mutual exclusion

Index Terminology Critical Section –when it is accessing shared data in a system. Semaphore –Used to implement the idea of mutual exclusion due to multiple access Concurrent process –Processes are said to be concurrent if they exist at the same time.

Index Software implementation Idea of process synchronization While gate = closed : DO null operation (gate is open) gate := closed : so that other cannot use it ……….. Critical section ………. gate := open : let other to use it Above is impractical for multi- processes

Index Process Type Concurrent processes –processes exist at the same time –if on a single CPU system, then context switching are required Asynchronous concurrent processes –concurrent processes function independently –require occasional synchronization or interprocess communication

Index Asymmetric and Symmetric Processing

Index Mutual Exclusion To ensure the integrity of data, shared data cannot be used by more than ONE process at the same time Otherwsie data will be updated incorrectly

Index Critical Sections When a process is accessing shared modifiable data, it is in “Critical Section”

Index Features of Critical Sections when a process is in the critical section, other processes may continue execution outside the critical region. when a process leaves its critical section, one other process waiting to enter the critical section may proceed. Mutual exclusion can be implemented by means of SEMAPHORES.

Index Synchronization A process may not be able to continue until a service is provided. It involves the signaling between two or more processes. Process synchronization can be achieved by semaphores.

Index Process Synchronization

Index Two processes Compilation

Index Semaphore Semaphore was introduced by Dijksta in A semaphore is a protected variable S. The value can be accessed and altered by three operations, namely, wait (P(S)), signal (V(S)) and initialization operations only.

Index Characteristics of semaphores Binary semaphores can assume only the value 0 or 1 Counting semaphores can assume only non-negative integer values P(S) and V(S) are the initial Dutch words. P(S) refers to wait; while V(S) is signal.

Index Code for binary semaphore P operation on variable S, P(S) is if S > 0 then S := S - 1 (means no process is using) Else (wait on S to change value) V operation (V means to signify), V(S) is If (one or more processes is/are waiting on S to change.) then (let one of theses processes proceed ) else S:= S + 1 (no process in the semaphore queue)

Index Two-process synchonization

Index Software Example Program example-one var active: semaphore; Procedure process-A begin while true do begin P(active); critical-sec; : V(active); : end end; Procedure process-B begin while true do begin : P(active); critical-sec; : V(active); : end end;

Index Software Example (Continue…) Begin semaphore-init(active,1); /* initialise the semaphore variable active */ parbegin process-A; process-B; parend end.

Index Mutual Exclusion When a resource can be accessed by at least two processes, it can only be exclusively used by one of them until it is completed. In a system providing multiple processes, it is desirable to co- ordinate the activities of them The relationship can be described by a set of processes called producer- consumer.

Index Producer and Consumer

Index Implementation for mutual exclusion Dekker’s Primitives Interrupt masking locks

Index Example for Mutual Exclusion Procedure producer While true do {.... produce an item.... P(empty); P(mutex);.... add item to buffer;.... V(mutex); V(full); } Procedure consumer While true do { P(full); P(mutex);.... remove an item from buffer to “local”.... V(mutex); V(empty);.... consume the item in “local” }

Index Summary Process synchronisation used to solve synchronisation by semaphore. Those waiting to be served is at semaphore queue. To avoid deadlock, processes should ensure that the resources are exclusively used Producer and consumer model is used for mutual exclusion.