Process Synchronization

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

Global Environment Model. MUTUAL EXCLUSION PROBLEM The operations used by processes to access to common resources (critical sections) must be mutually.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
CH7 discussion-review Mahmoud Alhabbash. Q1 What is a Race Condition? How could we prevent that? – Race condition is the situation where several processes.
Department of Computer Science Southern Illinois University Edwardsville Spring, 2010 Dr. Hiroshi Fujinoki CS 547/490 Network.
Concurrency.
Chapter 6: Process Synchronization. Outline Background Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores Classic Problems.
Semaphores. Announcements No CS 415 Section this Friday Tom Roeder will hold office hours Homework 2 is due today.
02/23/2004CSCI 315 Operating Systems Design1 Process Synchronization Notice: The slides for this lecture have been largely based on those accompanying.
1 Chapter 6: Concurrency: Mutual Exclusion and Synchronization Operating System Spring 2007 Chapter 6 of textbook.
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
1 Interprocess Communication Race Conditions Two processes want to access shared memory at same time.
Operating Systems CSE 411 CPU Management Oct Lecture 13 Instructor: Bhuvan Urgaonkar.
Semaphores. Readings r Silbershatz: Chapter 6 Mutual Exclusion in Critical Sections.
Chapter 2 (PART 1) Light-Weight Process (Threads) Department of Computer Science Southern Illinois University Edwardsville Summer, 2004 Dr. Hiroshi Fujinoki.
Operating Systems CMPSC 473 Mutual Exclusion Lecture 14: October 14, 2010 Instructor: Bhuvan Urgaonkar.
Chapter 1 Computer System Overview Sections 1.1 to 1.6 Instruction exe cution Interrupt Memory hierarchy Cache memory Locality: spatial and temporal Problem.
Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure the orderly execution.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-5 Process Synchronization Department of Computer Science and Software.
Concurrency in Shared Memory Systems Synchronization and Mutual Exclusion.
CS 2200 Presentation 18b MUTEX. Questions? Our Road Map Processor Networking Parallel Systems I/O Subsystem Memory Hierarchy.
Uniprocessor Process Management & Process Scheduling Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi.
Critical Section Tools (HW interface) locks implemented in ISA – T&S, CAS (O.S. )Semaphores – Counting and Binary (a.k.a a mutex lock) (Augmented O.S.)
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Process Synchronization. Concurrency Definition: Two or more processes execute concurrently when they execute different activities on different devices.
Interprocess Communication Race Conditions
Sarah Diesburg Operating Systems COP 4610
Semaphores Synchronization tool (provided by the OS) that does not require busy waiting. Logically, a semaphore S is an integer variable that, apart from.
PARALLEL PROGRAM CHALLENGES
Background on the need for Synchronization
Process Synchronization
Concurrent Processes.
CS 286 Computer Organization and Architecture
IS310 Hardware & Network Infrastructure Ronny L
CS 286 Computer Organization and Architecture
CS 286: Memory Paging and Virtual Memory
CS 286 Computer Organization and Architecture
Inter-Process Communication and Synchronization
Process Synchronization
Lecture 22 Syed Mansoor Sarwar
UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department
Outline Distributed Mutual Exclusion Introduction Performance measures
Lecture 2 Part 2 Process Synchronization
Critical section problem
Concurrency: Mutual Exclusion and Process Synchronization
Chapter 6 Synchronization Principles
Thread Synchronization including Mutual Exclusion
CS 286 Computer Architecture & Organization
CS 286 Computer Organization and Architecture
Basic Synchronization
Instruction Rescheduling and Loop-Unroll
Uniprocessor Process Management & Process Scheduling
Introduction to OS (concept, evolution, some keywords)
Deadlock Prevention & Avoidance
, Part II Process Synchronization
Real-Time Process Scheduling Concepts, Design and Implementations
Introduction to OS (concept, evolution, some keywords)
Department of Computer Science
Process/Code Migration and Cloning
OS Boot Sequence and File System
Department of Computer Science
Threads: Light-Weight Processes
Deadlock Prevention & Avoidance
Real-Time Process Scheduling Concepts, Design and Implementations
Process Synchronization
OS Boot Sequence and File System
Light-Weight Process (Threads)
Uniprocessor Process Management & Process Scheduling
MIPS R3000 Subroutine Calls and Stack
Sarah Diesburg Operating Systems CS 3430
Presentation transcript:

Process Synchronization CS 314 Operating Systems Process Synchronization Race Condition, Mutual Exclusion and Semaphores Department of Computer Science Southern Illinois University Edwardsville Fall, 2018 Dr. Hiroshi Fujinoki E-mail: hfujino@siue.edu ProcessSynch/000

CS 314 Operating Systems Race Condition & Mutual Exclusion = a situation in which the final results on a shared resource depends on unpredictable context-switching for the processes that share the resource Initially A = 0 Only each instruction is “atomic” Shared Memory P1 Process P2 A := A + 8 A A := A - 3 LOAD R3, (A) ADD R3, R3, -3 STORE (A), R3 LOAD R1, (A) ADD R1, R1, 8 STORE (A), R1 Processor A = 5 ProcessSynch/001

CS 314 Operating Systems Race Condition & Mutual Exclusion = a situation in which the final results on a shared resource depends on unpredictable context-switching for the processes that share the resource Context-Switching by OS happens here Shared Memory P1 Process P2 Process A A := A + 8 A := A - 3 LOAD R3, (A) LOAD R1, (A) ADD R3, R3, -3 ADD R1, R1, 8 Processor STORE (A), R3 STORE (A), R1 A = 8 ProcessSynch/002

CS 314 Operating Systems Race Condition & Mutual Exclusion = a situation in which the final results on a shared resource depends on unpredictable context-switching for the processes that share the resource Context-Switching by OS happens here Context-Switching by OS happens here Shared Memory P1 Process P2 Process A A := A + 8 A := A - 3 LOAD R3, (A) LOAD R1, (A) ADD R3, R3, -3 ADD R1, R1, 8 Processor STORE (A), R3 STORE (A), R1 A = -3 ProcessSynch/003

CS 314 Operating Systems Mutual Exclusion Critical Section is a section in a program where at most one process can exist at any given time Mutual Exclusion Mutual Exclusion (A.K.A. “Mutex”) is a solution for race condition If S > 0, do S = S - 1 then proceed If S = 0, wait on this semaphore Wait If no one waiting on S, set S = 1 If some one waiting on S, let the first proceed to CS and leave S = 0 Signal Shared Memory P1 Process P2 Process A A := A + 2 A := A - 9          P2 blocks here          Wait(S) Wait(S) Processor Critical Section LOAD R1, (A) Critical Section LOAD R1, (A) ADD R1, R1, 2 ADD R1, R1, 2 STORE (A), R1 STORE (A), R1 Signal(S) Signal(S)             Semaphore (Binary Semaphore) 1       ProcessSynch/004

https://www. safaribooksonline https://www.safaribooksonline.com/library/view/microprocessor-theory-and/9780470380314/27_apph.html

CS 314 Operating Systems Counting Semaphores The semaphores that are initialized by an integer larger than 1 A P4 Process P3 Process Semaphore (Binary Semaphore) 2 3 1 P1 Process P2 Process ProcessSynch/008

CS 314 Operating Systems Where are semaphores? A situation in which some processes suffer from waiting for their execution P4 Process P3 Process Semaphore (Binary Semaphore) P1 Process P2 Process 1 OS A host computer ProcessSynch/009

CS 314 Operating Systems Starvation A situation in which some processes suffer from waiting for their execution P3 Process P4 P5 Process P6 A Semaphore (Binary Semaphore) P1 Process P2 Process P7 Process P8 1 ProcessSynch/007

CS 314 Operating Systems Starvation A situation in which some processes suffer from waiting for their execution P3 Process P4 A Semaphore (Binary Semaphore) P1 Process P2 Process 1 ProcessSynch/005

CS 314 Operating Systems Starvation A situation in which some processes suffer from waiting for their execution P3 Process P4 P5 Process P6 A Semaphore (Binary Semaphore) P1 Process P2 Process 1 ProcessSynch/006