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.)

Slides:



Advertisements
Similar presentations
Synchronization. How to synchronize processes? – Need to protect access to shared data to avoid problems like race conditions – Typical example: Updating.
Advertisements

Multiprocessors—Synchronization. Synchronization Why Synchronize? Need to know when it is safe for different processes to use shared data Issues for Synchronization:
CAS3SH3 Midterm Review. The midterm 50 min, Friday, Feb 27 th Materials through CPU scheduling closed book, closed note Types of questions: True & False,
Global Environment Model. MUTUAL EXCLUSION PROBLEM The operations used by processes to access to common resources (critical sections) must be mutually.
CS492B Analysis of Concurrent Programs Lock Basics Jaehyuk Huh Computer Science, KAIST.
Chapter 2 — Instructions: Language of the Computer — 1 Branching Far Away If branch target is too far to encode with 16-bit offset, assembler rewrites.
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.
Parallel Processing (CS526) Spring 2012(Week 6).  A parallel algorithm is a group of partitioned tasks that work with each other to solve a large problem.
Review: Multiprocessor Systems (MIMD)
1 CS318 Project #3 Preemptive Kernel. 2 Continuing from Project 2 Project 2 involved: Context Switch Stack Manipulation Saving State Moving between threads,
1 Lecture 21: Synchronization Topics: lock implementations (Sections )
1 CS 333 Introduction to Operating Systems Class 4 – Synchronization Primitives Semaphores Jonathan Walpole Computer Science Portland State University.
CS533 - Concepts of Operating Systems 1 CS533 Concepts of Operating Systems Class 8 Synchronization on Multiprocessors.
Jonathan Walpole Computer Science Portland State University
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
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.
CS252: Systems Programming Ninghui Li Final Exam Review.
CS510 Concurrent Systems Introduction to Concurrency.
Chapter 1 Computer System Overview Sections 1.1 to 1.6 Instruction exe cution Interrupt Memory hierarchy Cache memory Locality: spatial and temporal Problem.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
Exam Review Andy Wang Operating Systems COP 4610 / CGS 5765.
C H A P T E R E L E V E N Concurrent Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
Synchronization CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
CS510 Concurrent Systems Jonathan Walpole. Introduction to Concurrency.
Process Synchronization. Objectives To introduce the critical-section problem, whose solutions can be used to ensure the consistency of shared data To.
Implementing Mutual Exclusion Andy Wang Operating Systems COP 4610 / CGS 5765.
Big Picture Lab 4 Operating Systems C Andras Moritz
Multiprocessors – Locks
Chapter 3: Windows7 Part 5.
Outline Introduction Centralized shared-memory architectures (Sec. 5.2) Distributed shared-memory and directory-based coherence (Sec. 5.4) Synchronization:
Thread Synchronization
Sarah Diesburg Operating Systems COP 4610
CS703 – Advanced Operating Systems
COT 4600 Operating Systems Fall 2009
Background on the need for Synchronization
Process Synchronization
Synchronization.
Lecture 19: Coherence and Synchronization
Lecture 5: Synchronization
Parallel Shared Memory
Operating Systems CMPSC 473
Inter-Process Communication and Synchronization
Chapter 3: Windows7 Part 5.
Process Synchronization
Lecture 21: Synchronization and Consistency
Lecture: Coherence and Synchronization
Lecture 2 Part 2 Process Synchronization
Critical section problem
Concurrency: Mutual Exclusion and Process Synchronization
Kernel Synchronization I
Major Topics in Operating Systems
Implementing Mutual Exclusion
Kernel Synchronization II
Basic Synchronization
CSE 451: Operating Systems Autumn 2003 Lecture 7 Synchronization
CSE 451: Operating Systems Autumn 2005 Lecture 7 Synchronization
CSE 451: Operating Systems Winter 2003 Lecture 7 Synchronization
CSE 153 Design of Operating Systems Winter 19
CS333 Intro to Operating Systems
Chapter 6: Synchronization Tools
Andy Wang Operating Systems COP 4610 / CGS 5765
Andy Wang Operating Systems COP 4610 / CGS 5765
Process Synchronization
Process Synchronization
Andy Wang Operating Systems COP 4610 / CGS 5765
Sarah Diesburg Operating Systems CS 3430
Synchronization and liveness
Presentation transcript:

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.) Monitors & conditions – Java, C#, or make your own! Need only atomic lock ops at the ISA level, implement the rest yourself. But, as more tools are offered by the kernel, the OS will expand its role here, offering easier-to-use or optimized solutions – Win and Pulse example

Critical Section A section of code that shares data with other concurrent threads Sharing of data makes a section critical – Specifically, write contention In a kernel, many shared data structures – Need to synchronize these to guard against race conditions – OR, make kernel thread scheduling non- preemptive

How to Make an Atomic Exchange Try: MOVE $s3, $a1 ;move swap val into $s3 LL $s2, 0($s1) ; load linked SC $s3,0($s1) ; store conditional BEQZ $s3, try ;sc returns success in $s3 MOVE $v1, $s2 ;return load result ;simple atomic exchange ; if the contents of $s1 change between the LL and the SC? SC fails and returns 0. – Similar in spirit to return address verification ; note: context switch between LL and SC? SC fails and returns 0 in $s3 then

Another Lock: fetch-and-increment Try: LL $t2, 0($t1) DADDUI $t3, $t2, 1 ;our increment SC $t3, 0($t1) BEQZ $t3, try ;branch if store fails