Chapter 7: Synchronization Examples

Slides:



Advertisements
Similar presentations
Operating Systems Semaphores II
Advertisements

Ch 7 B.
Chapter 6: Process Synchronization
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Stuff  Exam timetable now available  Class back in CS auditorium as of Wed, June 4 th  Assignment 2, Question 4 clarification.
Operating Systems CMPSC 473 Mutual Exclusion Lecture 13: October 12, 2010 Instructor: Bhuvan Urgaonkar.
6.5 Semaphore Can only be accessed via two indivisible (atomic) operations wait (S) { while S
COSC 3407: Operating Systems Lecture 8: Semaphores, Monitors and Condition Variables.
Classical Problems of Concurrency
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization.
Chapter 6: Process Synchronization. Outline Background Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores Classic Problems.
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 8, 2005 Objectives Understand.
Synchronization April 14, 2000 Instructor Gary Kimura Slides courtesy of Hank Levy.
CS444/CS544 Operating Systems Classic Synchronization Problems 2/26/2007 Prof. Searleman
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Process Synchronization.
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 8, 2005 Module 6: Process Synchronization.
Adopted from and based on Textbook: Operating System Concepts – 8th Edition, by Silberschatz, Galvin and Gagne Updated and Modified by Dr. Abdullah Basuhail,
Operating Systems CSE 411 CPU Management Oct Lecture 13 Instructor: Bhuvan Urgaonkar.
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 8, 2005 Background Concurrent.
Semaphores and Bounded Buffer Andy Wang Operating Systems COP 4610 / CGS 5765.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 23 Classic Synchronization.
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.
Operating Systems CMPSC 473 Mutual Exclusion Lecture 14: October 14, 2010 Instructor: Bhuvan Urgaonkar.
Midterm 1 – Wednesday, June 4  Chapters 1-3: understand material as it relates to concepts covered  Chapter 4 - Processes: 4.1 Process Concept 4.2 Process.
4061 Session 21 (4/3). Today Thread Synchronization –Condition Variables –Monitors –Read-Write Locks.
1 Chapter 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Special Machine Instructions for Synchronization Semaphores.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization.
1 Interprocess Communication (IPC) - Outline Problem: Race condition Solution: Mutual exclusion –Disabling interrupts; –Lock variables; –Strict alternation.
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Module 6: Process Synchronization Background The.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 11: Synchronization (Chapter 6, cont)
6.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Module 6: Process Synchronization.
Process Synchronization CS 360. Slide 2 CS 360, WSU Vancouver Process Synchronization Background The Critical-Section Problem Synchronization Hardware.
CSE Operating System Principles Synchronization.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 22 Semaphores Classic.
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 ©2009 Operating System Concepts – 8 th Edition Chapter 6: Process Synchronization.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 5: Process Synchronization.
Classic problems of Synchronization : Producers/Consumers problem: The producers/ consumers problem may be stated as follows: Given a set of cooperating.
Chapter 6 Synchronization Dr. Yingwu Zhu. The Problem with Concurrent Execution Concurrent processes (& threads) often access shared data and resources.
6.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles 6.5 Semaphore Less complicated than the hardware-based solutions Semaphore S – integer.
Deadlock and Starvation
CS703 - Advanced Operating Systems
Chapter 6: Process Synchronization
Semaphore Synchronization tool that provides more sophisticated ways (than Mutex locks) for process to synchronize their activities. Semaphore S – integer.
Chapter 5: Process Synchronization
Process Synchronization: Semaphores
Auburn University COMP 3500 Introduction to Operating Systems Synchronization: Part 4 Classical Synchronization Problems.
Background on the need for Synchronization
Process Synchronization
Chapter 5: Process Synchronization – Part II
Chapter 5: Process Synchronization
Deadlock and Starvation
Chapter 6-7: Process Synchronization
CSE451 Basic Synchronization Spring 2001
Chapter 6: Process Synchronization
Chapter 5: Process Synchronization
Chapter 5: Process Synchronization
Process Synchronization
Chapter 5: Process Synchronization (Con’t)
Semaphore Originally called P() and V() wait (S) { while S <= 0
Process Synchronization
Synchronization Hank Levy 1.
Chapter 7: Synchronization Examples
CSE 451: Operating Systems Autumn Lecture 8 Semaphores and Monitors
Synchronization Hank Levy 1.
CSE 153 Design of Operating Systems Winter 2019
Chapter 5: Process Synchronization
Problem: CFQ (Circular Fifo Queue)
FIRST SOLUTION Producer Process Consumer Process
Presentation transcript:

Chapter 7: Synchronization Examples

Chapter 7: Synchronization Examples Classic Problems of Synchronization Synchronization within the Kernel POSIX Synchronization Synchronization in Java Alternative Approaches

Classical Problems of Synchronization Classical problems used to test newly-proposed synchronization schemes Bounded-Buffer Problem Readers and Writers Problem Dining-Philosophers Problem

Bounded-Buffer Problem Correctness constraints for solution Consumer must wait for producer to fill buffers, if none full (scheduling constraint) Producer must wait for consumer to empty buffers, if all full (scheduling constraint) Only one thread can manipulate buffer queue at a time (mutual exclusion) General rule of thumb: Use a separate semaphore for each constraint. Note how semaphores are being used in multiple ways. n buffers, each can hold one item Semaphore mutex = 1 // mutual exclusion Semaphore full = 0 // consumer’s constraint, if 0, no item in buffer Semaphore empty = n // producer’s constraint, if full, nowhere to put item

Bounded Buffer Problem (Cont.) The structure of the producer process do { ... /* produce an item in next_produced */ wait(empty); wait(mutex); ... /* add next produced to the buffer */ signal(mutex); signal(full); } while (true); Consumer process Do { wait(full); wait(mutex); ... /* remove an item from buffer to next_consumed */ ... signal(mutex); signal(empty); ... /* consume the item in next consumed */ ... } while (true);

Semaphore solution Questions Why does producer wait() + signal() different semaphores than the consumer? Is order of wait()’s important? Yes! Can cause deadlock Is order of signal()’s important? No, except that it might affect scheduling efficiency What if we have 2 producers or 2 consumers? Do we need to change anything?

Readers-Writers Problem A data set is shared among a number of concurrent Threads Readers – only read the data set concurrently; they do not perform any updates Writers – can both read and write (update) concurrently Problem – allow multiple readers to read at the same time Only one single writer can access the shared data at the same time Several variations of how readers and writers are considered – all involve some form of priorities