Concurrency Problem. Thread Synchronization: Too Much Milk. The Fundamental Issue. Critical Sections. Order of thread execution is non-deterministic
|
|
- Violet Craig
- 6 years ago
- Views:
Transcription
1 Concurrency Problem Synchronization: oo Much Milk Order of thread execution is non-determistic Multiprocessg v A system may conta multiple processors Ë cooperatg threads/processes can execute simultaneously Multi-programmg v /process execution can be terleaved because of timeslicg Operations are often not atomic Example: x x + is not atomic! Goal: Ensure that your concurrent program works under ALL possible terleavg 2 he Fundamental Issue Critical Sections In all these cases, what we thought to be an atomic operation is not done atomically by the mache Defition: An atomic operation is one that executes to completion without any terruption or failure An atomic operation has an all or nothg flavor: Either it executes to completion, or it did not execute at all, and it executes without terruptions Atomic no no one one can can see see a partially-executed state!! Key Key challenge: how how to to implement atomic semantics? A critical section is an abstraction that consists of a number of consecutive program structions all code with the section executes atomically Critical sections are used profusely an OS to protect data structures (e.g., queues, shared variables, lists, ) A critical section implementation must be: correct: for a given k, only k thread can execute the critical section at any given time (usually, k ) efficient: gettg to and out of critical section must be fast concurrency control: a good implementation allows maximum concurrency preservg correctness flexible: a good implementation must have as few restrictions as practically possible 3 4
2 5 Safety and Liveness A really cool theorem Safety property : nothg bad happens holds every fite execution prefix v Wdows never crashes v if one general attacks, both do v a program never termates with a wrong answer Liveness property: somethg good eventually happens no partial execution is irremediable v Wdows always reboots v both generals eventually attack v a program eventually termates Every property is a combation of a safety property and a liveness property (Alpern and Schneider) 6 Nice, but what s your pot? Critical Section: Implementation Safety: At most k threads are concurrently the critical section Liveness: A thread that wants to enter the critical section, will eventually succeed Anythg else? Bounded waitg: If a thread i is entry section, then there is a bound on the number of times that other threads are allowed to enter the critical section before thread i s request is granted Is Is bounded waitg a safety or or a liveness property? 7 Basic idea: Restrict programmg model Permit access to shared variables only with a critical section General program structure Entry section v Lock before enterg critical section v Wait if already locked v Key pot: synchronization may volve wait Critical section code Exit section v Unlock when leavg the critical section Object-oriented programmg style Associate a lock with each shared object Methods that access shared object are critical sections Acquire/release locks when enterg/exitg a method that defes a critical section extbook shows shows non-oo non-oo examples; much much easier easier to to thk thk OO OO 8
3 9 Coordation: Reality V! oo much milk! Jack Look the fridge; out of milk Leave for store Arrive at store Buy milk Arrive home; put milk away Jill Look fridge; out of milk Leave for store Arrive at store Buy milk Arrive home; put milk away Oh, no! Fridge and and milk milk are are shared data data structures Formalizg oo Much Milk Shared variables Look the fridge for milk check a variable Put milk away update a variable Safety property At most one person buys milk Liveness Someone buys milk when needed How can we solve this problem? 0 oo Much Milk: Solution #0 oo Much Milk: Solution # ( Jack); Jack); // // relax relax (Milk); (Milk);// // relax relax : : Jill Jill ( Jill); Jill); // // relax relax (Milk); (Milk);// // relax relax : : Jack Jack If If (nomilk) (nomilk) // // check check milk milk if if (nonote) (nonote) // // check check if if roommate roommate is is gettg gettg milk milk leave leave Note; Note; remove remove Note; Note; Will this solution work? Safe? Yes! Must have to buy milk! Live? What if the other guy never comes around to check the milk Bounded waitg? Sure, and the bound is! Introduce the concept of a note vleave a note lock vremove note unlock vdon t buy if note wait Will this solution work? Safe? No! s can get context switched after checkg whether there is a note, but before leavg a note Live? Yes! A note left will be eventually removed Bounded waitg? his solution is worse than before!! It works sometime and doesn t some other times What if we switch the order of checks? 2
4 3 oo Much Milk: Solution #2 Solution #3 (a.k.a. Peterson s algorithm): combe ideas of 0 and 2 Jack Jack Leave Leave Blue Blue note note If If (nonote (nonote Pk) Pk) if if (nomilk) (nomilk) Remove Remove Blue Blue note note Jill Jill Leave Leave Pk Pk note note If If (nonote (nonote Blue) Blue) if if (nomilk) (nomilk) Remove Remove Pk Pk note note Variables: i : : thread i is executg, or attemptg to execute, id of thread allowed to enter if multiple want to Claim: We can achieve mutual exclusion if the followg variant holds before enterg the critical section: Safe? Live? What happens if note has no color? j ( j Ÿ i)) Ÿ i i false ( 0 ( 0 Ÿ )) Ÿ ) Ÿ ( ( Ÿ 0)) Ÿ 0 ) fi (( 0) Ÿ ( )) false 4 owards a solution We hit a snag he problem boils down to establishg the followg right after entry i j ( j Ÿ i)) Ÿ i j i) Ÿ i How can we do that? entry i i : ( j Ÿ i); 0 (!termate) 0 : true 0 ( Ÿ 0) 0 (!termate) : true ( 0 Ÿ ); Ÿ 0 ) he assignment to 0 validates the variant! 5 6
5 7 What can we do? Safe? Add assignment to to establish the second disjunct 0 0 (!termate) (!termate) (!termate) (!termate) a 0 : 0 : : : 0 a : : ; ; : : 0 0 ( ( Ÿ Ÿ ( ( ); ); 0 0 at(a at(a ) ))) Ÿ 0 0 at(a at(a 0 ) 0 ))) : 0 : : : N N 0 N 0 N 0 0 (!termate) (!termate) (!termate) (!termate) a 0 : 0 : : : 0 a : : ; ; : : 0 0 ( ( Ÿ Ÿ ( ( 0 0 ); ); at(a at(a ) ) ) ) Ÿ Ÿ 0 0 at(a at(a 0 ) 0 ) ) ) : 0 : : : N N 0 N N 0 If both, then at(a ) 0) Ÿ Ÿ 0 at(a 0 ) ) Ÿ Ÿ at(a 0 ) Ÿ at(a ) ( 0) Ÿ ( ) false 8 Live? Bounded waitg? 0 0 (!termate) (!termate) (!termate) (!termate) S S : : ( ( 0) 0) R R : : ( ( 0) 0) 0 : 0 : : : a S S 2 : 2 : 0 ( ( 0) 0) a R R 2 : 2 : ( ( 0) 0) : : ; ; : : S S 2 2 R R 2 2 ( ( Ÿ Ÿ ( ( ); ); S S 3 : 3 : at(a ) ) 0) 0) R R 3 : 3 : Ÿ Ÿ 0 0 at(a 0 ) 0 ) ) ) 0 0 S S 3 3 R R : 0 : : : S S R R N N 0 0 N N Non-blockg: 0 before N 0, stuck at loop S Ÿ R 2 Ÿ ( 0) Ÿ ( 0) false Deadlock-free: and 0 at, before enterg the critical section S 2 Ÿ R 2 Ÿ ( ( 0)) Ÿ ( Ÿ ( )) fi ( 0) Ÿ ( ) false (!termate) (!termate) 0 : 0 : : : ; ; ( ( Ÿ Ÿ : 0 : N N 0 0 Yup! 0 0 (!termate) (!termate) : : : : ( ( ); ); 0 0 : : N N
6 2 oo Much Milk: Lessons Last solution works, but it is really unsatisfactory Solution is complicated; provg correctness is tricky even for the simple example While thread is waitg, it is consumg CPU time How can we do better? Defe higher-level programmg abstractions to simplify concurrent programmg Use hardware features to elimate busy waitg Stay tuned
Safety and liveness for critical sections
Safety and liveness for critical sections! At most k threads are concurrently in the critical section A. Safety B. Liveness C. Both! A thread that wants to enter the critical section will eventually succeed
More informationThread Synchronization: Too Much Milk
Thread Synchronization: Too Much Milk 1 Implementing Critical Sections in Software Hard The following example will demonstrate the difficulty of providing mutual exclusion with memory reads and writes
More informationThread Synchronization: Foundations. Properties. Safety properties. Edsger s perspective. Nothing bad happens
Edsger s perspective Testing can only prove the presence of bugs Thread Synchronization: Foundations Properties Property: a predicate that is evaluated over a run of the program (a trace) every message
More informationToday: Synchronization. Recap: Synchronization
Today: Synchronization Synchronization Mutual exclusion Critical sections Example: Too Much Milk Locks Synchronization primitives are required to ensure that only one thread executes in a critical section
More informationLast Class: CPU Scheduling! Adjusting Priorities in MLFQ!
Last Class: CPU Scheduling! Scheduling Algorithms: FCFS Round Robin SJF Multilevel Feedback Queues Lottery Scheduling Review questions: How does each work? Advantages? Disadvantages? Lecture 7, page 1
More informationPage 1. Challenges" Concurrency" CS162 Operating Systems and Systems Programming Lecture 4. Synchronization, Atomic operations, Locks"
CS162 Operating Systems and Systems Programming Lecture 4 Synchronization, Atomic operations, Locks" January 30, 2012 Anthony D Joseph and Ion Stoica http://insteecsberkeleyedu/~cs162 Space Shuttle Example"
More informationCS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2002
CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2002 Lecture 6: Synchronization 6.0 Main points More concurrency examples Synchronization primitives 6.1 A Larger Concurrent
More informationEECS 482 Introduction to Operating Systems
EECS 482 Introduction to Operating Systems Winter 2018 Baris Kasikci Slides by: Harsha V. Madhyastha http://knowyourmeme.com/memes/mind-blown 2 Recap: Processes Hardware interface: app1+app2+app3 CPU +
More informationChapter 5: Synchronization 1
1 Start of Lecture: January 25, 2014 2 Reminders Assignment 1 is due this Friday at 6:00 p.m. Couple comments about Exercise 1: Thought questions: be honest and sincere about questions you have while reading;
More informationThreads and Too Much Milk! CS439: Principles of Computer Systems February 6, 2019
Threads and Too Much Milk! CS439: Principles of Computer Systems February 6, 2019 Bringing It Together OS has three hats: What are they? Processes help with one? two? three? of those hats OS protects itself
More informationThreads and Critical Sections. Otto J. Anshus, Thomas Plagemann, Tore Brox-Larsen, Kai Li
Threads and Critical Sections Otto J. Anshus, Thomas Plagemann, Tore Brox-Larsen, Kai Li Thread and Address Space Thread A sequential execution stream within a process (also called lightweight process)
More informationPage 1. Another Concurrent Program Example" Goals for Today" CS162 Operating Systems and Systems Programming Lecture 4
CS162 Operating Systems and Systems Programming Lecture 4 Synchronization, Atomic operations, Locks, Semaphores" January 31, 2011! Ion Stoica! http://insteecsberkeleyedu/~cs162! Space Shuttle Example"
More informationThreads and Too Much Milk! CS439: Principles of Computer Systems January 31, 2018
Threads and Too Much Milk! CS439: Principles of Computer Systems January 31, 2018 Last Time CPU Scheduling discussed the possible policies the scheduler may use to choose the next process (or thread!)
More informationPage 1. Recap: ATM Bank Server" Recap: Challenge of Threads"
Recap: ATM Bank Server" CS162 Operating Systems and Systems Programming Lecture 4 Synchronization, Atomic operations, Locks" February 4, 2013 Anthony D Joseph http://insteecsberkeleyedu/~cs162 ATM server
More informationSupplementary Notes on Concurrent ML
Supplementary Notes on Concurrent ML 15-312: Foundations of Programmg Languages Frank Pfenng Lecture 25 November 21, 2002 In the last lecture we discussed the π-calculus, a mimal language with synchronous
More informationConcurrent Programing: Why you should care, deeply
Concurrent Programing: Why you should care, deeply 1 Student Questions 1. it is said that user-level threads are implemented by a library at the user-level. we have POSIX for starting user threads in C++.
More information5. Synchronization. Operating System Concepts with Java 8th Edition Silberschatz, Galvin and Gagn
5. Synchronization Operating System Concepts with Java 8th Edition Silberschatz, Galvin and Gagn operating system Synchronization 3 Review - thread on single core Process 1 p1 threads Process N threads
More informationConcurrency & Synchronization. COMPSCI210 Recitation 25th Feb 2013 Vamsi Thummala Slides adapted from Landon Cox
Concurrency & Synchronization COMPSCI210 Recitation 25th Feb 2013 Vamsi Thummala Slides adapted from Landon Cox Midterm Review http://www.cs.duke.edu/~chase/cps11 0-archive/midterm-210-13s1.pdf Please
More information2 Threads vs. Processes
9 2 Threads vs. Processes A process includes an address space (defining all the code and data pages) a resource container (OS resource and accounting information) a thread of control, which defines where
More informationImplementing Mutual Exclusion. Sarah Diesburg Operating Systems CS 3430
Implementing Mutual Exclusion Sarah Diesburg Operating Systems CS 3430 From the Previous Lecture The too much milk example shows that writing concurrent programs directly with load and store instructions
More informationDeadlock and Monitors. CS439: Principles of Computer Systems September 24, 2018
Deadlock and Monitors CS439: Principles of Computer Systems September 24, 2018 Bringing It All Together Processes Abstraction for protection Define address space Threads Share (and communicate) through
More informationLecture #7: Implementing Mutual Exclusion
Lecture #7: Implementing Mutual Exclusion Review -- 1 min Solution #3 to too much milk works, but it is really unsatisfactory: 1) Really complicated even for this simple example, hard to convince yourself
More informationDeadlock Revisited. CS439: Principles of Computer Systems November 29, 2017
Deadlock Revisited CS439: Principles of Computer Systems November 29, 2017 Last Time Distributed File Systems Remote Procedure Calls (RPC) Consistency Models Coherence, Staleness, Consistency Network File
More informationSynchronization II: EventBarrier, Monitor, and a Semaphore. COMPSCI210 Recitation 4th Mar 2013 Vamsi Thummala
Synchronization II: EventBarrier, Monitor, and a Semaphore COMPSCI210 Recitation 4th Mar 2013 Vamsi Thummala Check point: Mission in progress Master synchronization techniques Develop best practices for
More informationCSE 153 Design of Operating Systems
CSE 153 Design of Operating Systems Winter 19 Lecture 7/8: Synchronization (1) Administrivia How is Lab going? Be prepared with questions for this weeks Lab My impression from TAs is that you are on track
More informationMutual Exclusion and Synchronization
Mutual Exclusion and Synchronization Concurrency Defined Single processor multiprogramming system Interleaving of processes Multiprocessor systems Processes run in parallel on different processors Interleaving
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 11 Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Multilevel Feedback Queue: Q0, Q1,
More informationECE3055B Fall 2004 Computer Architecture and Operating Systems Final Exam Solution Dec 10, 2004
Georgia Tech Page of 4 ECE3055B Fall 24 Computer Architecture and Operatg Systems Fal Exam Solution Dec 0, 24. (5%) General Q&A. Give concise and brief answer to each of the followg questions... (2%) What
More informationA house of cards? Advanced Synchronization and Deadlock. Contra Threads: Events. Contra Threads: Events
A house of cards? Advanced Synchronization and Deadlock Locks + CV/signal a great way to regulate access to a single shared object......but general multi-threaded programs touch multiple shared objects
More informationDistributed Systems. coordination Johan Montelius ID2201. Distributed Systems ID2201
Distributed Systems ID2201 coordination Johan Montelius 1 Coordination Coordinating several threads in one node is a problem, coordination in a network is of course worse: failure of nodes and networks
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 1018 L10 Synchronization Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Development project: You
More informationConcurrent Programing: Motivation, Theory, Practice. Emmett Witchel First Bytes Teacher Conference July 2008
Concurrent Programing: Motivation, Theory, Practice Emmett Witchel First Bytes Teacher Conference July 2008 1 Uniprocessor Performance Not Scaling Performance (vs. VAX-11/780) 10000 20% /year 1000 52%
More informationConcurrent Programing: Motivation, Theory, Practice. Emmett Witchel First Bytes Teacher Conference July 2008
Concurrent Programing: Motivation, Theory, Practice Emmett Witchel First Bytes Teacher Conference July 2008 1 Uniprocessor Performance Not Scaling Performance (vs. VAX-11/780) 10000 1000 100 10 1 20% /year
More informationPage 1. Why allow cooperating threads?" Threaded Web Server"
Why allow cooperating threads?" CS162 Operating Systems and Systems Programming Lecture 4 Synchronization, Atomic operations, Locks" February 3, 2014! Anthony D Joseph! http://insteecsberkeleyedu/~cs162!
More informationLast Class: Deadlocks. Today
Last Class: Deadlocks Necessary conditions for deadlock: Mutual exclusion Hold and wait No preemption Circular wait Ways of handling deadlock Deadlock detection and recovery Deadlock prevention Deadlock
More informationDeadlock and Monitors. CS439: Principles of Computer Systems February 7, 2018
Deadlock and Monitors CS439: Principles of Computer Systems February 7, 2018 Last Time Terminology Safety and liveness Atomic Instructions, Synchronization, Mutual Exclusion, Critical Sections Synchronization
More informationLast Class: Synchronization
Last Class: Synchronization Synchronization primitives are required to ensure that only one thread executes in a critical section at a time. Concurrent programs Low-level atomic operations (hardware) load/store
More informationDealing with Issues for Interprocess Communication
Dealing with Issues for Interprocess Communication Ref Section 2.3 Tanenbaum 7.1 Overview Processes frequently need to communicate with other processes. In a shell pipe the o/p of one process is passed
More informationSynchronization I. Jo, Heeseung
Synchronization I Jo, Heeseung Today's Topics Synchronization problem Locks 2 Synchronization Threads cooperate in multithreaded programs To share resources, access shared data structures Also, to coordinate
More informationPROCESS SYNCHRONIZATION
PROCESS SYNCHRONIZATION Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization Monitors Synchronization
More informationSynchronising Threads
Synchronising Threads David Chisnall March 1, 2011 First Rule for Maintainable Concurrent Code No data may be both mutable and aliased Harder Problems Data is shared and mutable Access to it must be protected
More informationPage 1. CS162 Operating Systems and Systems Programming Lecture 6. Synchronization. Goals for Today
Goals for Today CS162 Operating Systems and Systems Programming Lecture 6 Concurrency examples Need for synchronization Examples of valid synchronization Synchronization February 4, 2010 Ion Stoica http://inst.eecs.berkeley.edu/~cs162
More informationCMSC421: Principles of Operating Systems
CMSC421: Principles of Operating Systems Nilanjan Banerjee Assistant Professor, University of Maryland Baltimore County nilanb@umbc.edu http://www.csee.umbc.edu/~nilanb/teaching/421/ Principles of Operating
More informationSynchronization. CISC3595/5595 Fall 2015 Fordham Univ.
Synchronization CISC3595/5595 Fall 2015 Fordham Univ. Synchronization Motivation When threads concurrently read/write shared memory, program behavior is undefined Two threads write to the same variable;
More informationCS162 Operating Systems and Systems Programming Lecture 7. Mutual Exclusion, Semaphores, Monitors, and Condition Variables
CS162 Operating Systems and Systems Programming Lecture 7 Mutual Exclusion, Semaphores, Monitors, and Condition Variables September 22, 2010 Prof John Kubiatowicz http://insteecsberkeleyedu/~cs162 Review:
More informationCS 153 Design of Operating Systems Winter 2016
CS 153 Design of Operating Systems Winter 2016 Lecture 7: Synchronization Administrivia Homework 1 Due today by the end of day Hopefully you have started on project 1 by now? Kernel-level threads (preemptable
More informationConcurrent Programming with Threads: Why you should care deeply
Concurrent Programming with Threads: Why you should care deeply Don Porter Portions courtesy Emmett Witchel Performance (vs. VAX-11/780) Uniprocessor Performance Not Scaling 10000 20% /year 1000 52% /year
More informationCS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2004
CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2004 Lecture 9: Readers-Writers and Language Support for Synchronization 9.1.2 Constraints 1. Readers can access database
More informationLast Class: Synchronization. Review. Semaphores. Today: Semaphores. MLFQ CPU scheduler. What is test & set?
Last Class: Synchronization Review Synchronization Mutual exclusion Critical sections Example: Too Much Milk Locks Synchronization primitives are required to ensure that only one thread executes in a critical
More informationR13 SET - 1 2. Answering the question in Part-A is compulsory 1 a) Define Operating System. List out the objectives of an operating system. [3M] b) Describe different attributes of the process. [4M] c)
More informationChapter 6: Process [& Thread] Synchronization. CSCI [4 6] 730 Operating Systems. Why does cooperation require synchronization?
Chapter 6: Process [& Thread] Synchronization CSCI [4 6] 730 Operating Systems Synchronization Part 1 : The Basics Why is synchronization needed? Synchronization Language/Definitions:» What are race conditions?»
More information10/17/ Gribble, Lazowska, Levy, Zahorjan 2. 10/17/ Gribble, Lazowska, Levy, Zahorjan 4
Temporal relations CSE 451: Operating Systems Autumn 2010 Module 7 Synchronization Instructions executed by a single thread are totally ordered A < B < C < Absent synchronization, instructions executed
More informationConcurrent & Distributed Systems Supervision Exercises
Concurrent & Distributed Systems Supervision Exercises Stephen Kell Stephen.Kell@cl.cam.ac.uk November 9, 2009 These exercises are intended to cover all the main points of understanding in the lecture
More informationCSE 486/586 Distributed Systems
CSE 486/586 Distributed Systems Mutual Exclusion Steve Ko Computer Sciences and Engineering University at Buffalo CSE 486/586 Recap: Consensus On a synchronous system There s an algorithm that works. On
More informationDeadlocks. Copyright : University of Illinois CS 241 Staff 1
Deadlocks 1 Deadlock Which way should I go? 2 Deadlock I Oh can no! almost I m get stuck! across GRIDLOCK! 3 Deadlock Definition Deadlocked process Waiting for an event that will never occur Typically,
More informationCSE 451: Operating Systems Winter Lecture 7 Synchronization. Steve Gribble. Synchronization. Threads cooperate in multithreaded programs
CSE 451: Operating Systems Winter 2005 Lecture 7 Synchronization Steve Gribble Synchronization Threads cooperate in multithreaded programs to share resources, access shared data structures e.g., threads
More informationDeadlock Revisited. CS439: Principles of Computer Systems April 23, 2018
Deadlock Revisited CS439: Principles of Computer Systems April 23, 2018 Last Time Distributed File Systems Remote Procedure Calls (RPC) Consistency Models Coherence, Staleness, Consistency Network File
More informationCOMP 3430 Robert Guderian
Operating Systems COMP 3430 Robert Guderian file:///users/robg/dropbox/teaching/3430-2018/slides/06_concurrency/index.html?print-pdf#/ 1/76 1 Concurrency file:///users/robg/dropbox/teaching/3430-2018/slides/06_concurrency/index.html?print-pdf#/
More informationUNIT:2. Process Management
1 UNIT:2 Process Management SYLLABUS 2.1 Process and Process management i. Process model overview ii. Programmers view of process iii. Process states 2.2 Process and Processor Scheduling i Scheduling Criteria
More informationCS420: Operating Systems. Process Synchronization
Process Synchronization James Moscola Department of Engineering & Computer Science York College of Pennsylvania Based on Operating System Concepts, 9th Edition by Silberschatz, Galvin, Gagne Background
More informationModels of concurrency & synchronization algorithms
Models of concurrency & synchronization algorithms Lecture 3 of TDA383/DIT390 (Concurrent Programming) Carlo A. Furia Chalmers University of Technology University of Gothenburg SP3 2016/2017 Today s menu
More informationOperating Systems. Synchronization
Operating Systems Fall 2014 Synchronization Myungjin Lee myungjin.lee@ed.ac.uk 1 Temporal relations Instructions executed by a single thread are totally ordered A < B < C < Absent synchronization, instructions
More informationAtomicity and Virtualization. Atomicity. Critical section. Edsger s perspective. Virtualizing a resource requires managing concurrent accesses
Atomicity and Virtualization Atomicity Virtualizing a resource requires managing concurrent accesses data structures must transition between consistent states atomic actions transform state indivisibly
More information! Why is synchronization needed? ! Synchronization Language/Definitions: ! How are locks implemented? Maria Hybinette, UGA
Chapter 6: Process [& Thread] Synchronization CSCI [4 6] 730 Operating Systems Synchronization Part 1 : The Basics! Why is synchronization needed?! Synchronization Language/Definitions:» What are race
More informationSynchronization I. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Synchronization I Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics Synchronization problem Locks 2 Synchronization Threads cooperate
More informationConcurrency. Glossary
Glossary atomic Executing as a single unit or block of computation. An atomic section of code is said to have transactional semantics. No intermediate state for the code unit is visible outside of the
More informationThreads. Concurrency. What it is. Lecture Notes Week 2. Figure 1: Multi-Threading. Figure 2: Multi-Threading
Threads Figure 1: Multi-Threading Figure 2: Multi-Threading Concurrency What it is 1. Two or more threads of control access a shared resource. Scheduler operation must be taken into account fetch-decode-execute-check
More informationCSE 120. Fall Lecture 6: Semaphores. Keith Marzullo
CSE 120 Principles of Operating Systems Fall 2007 Lecture 6: Semaphores Keith Marzullo Announcements Homework #2 out Homework #1 almost graded... Discussion session on Wednesday will entertain questions
More informationSynchronization Spinlocks - Semaphores
CS 4410 Operating Systems Synchronization Spinlocks - Semaphores Summer 2013 Cornell University 1 Today How can I synchronize the execution of multiple threads of the same process? Example Race condition
More informationPre- and post- CS protocols. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 7. Other requirements for a mutual exclusion algorithm
CS 361 Concurrent programming Drexel University Fall 2004 Lecture 7 Bruce Char and Vera Zaychik. All rights reserved by the author. Permission is given to students enrolled in CS361 Fall 2004 to reproduce
More informationSynchronization. CS61, Lecture 18. Prof. Stephen Chong November 3, 2011
Synchronization CS61, Lecture 18 Prof. Stephen Chong November 3, 2011 Announcements Assignment 5 Tell us your group by Sunday Nov 6 Due Thursday Nov 17 Talks of interest in next two days Towards Predictable,
More informationAsynchronous Programming Under the Hood. Week 6
Asynchronous Programming Under the Hood Week 6 How to Implement Event Dispatchers Recall: Record registered callbacks in a data structure (easy) Wait for an event to happen (easy) Call the callbacks when
More informationCS 31: Introduction to Computer Systems : Threads & Synchronization April 16-18, 2019
CS 31: Introduction to Computer Systems 22-23: Threads & Synchronization April 16-18, 2019 Making Programs Run Faster We all like how fast computers are In the old days (1980 s - 2005): Algorithm too slow?
More informationCSE 451: Operating Systems Winter Lecture 7 Synchronization. Hank Levy 412 Sieg Hall
CSE 451: Operating Systems Winter 2003 Lecture 7 Synchronization Hank Levy Levy@cs.washington.edu 412 Sieg Hall Synchronization Threads cooperate in multithreaded programs to share resources, access shared
More informationOperating Systems (1DT020 & 1TT802) Lecture 6 Process synchronisation : Hardware support, Semaphores, Monitors, and Condition Variables
Operating Systems (1DT020 & 1TT802) Lecture 6 Process synchronisation : Hardware support, Semaphores, Monitors, and Condition Variables April 22, 2008 Léon Mugwaneza http://www.it.uu.se/edu/course/homepage/os/vt08
More informationTyped Assembly Language for Implementing OS Kernels in SMP/Multi-Core Environments with Interrupts
Typed Assembly Language for Implementing OS Kernels in SMP/Multi-Core Environments with Interrupts Toshiyuki Maeda and Akinori Yonezawa University of Tokyo Quiz [Environment] CPU: Intel Xeon X5570 (2.93GHz)
More informationCOMP 530: Operating Systems Concurrent Programming with Threads: Why you should care deeply
Concurrent Programming with Threads: Why you should care deeply Don Porter Portions courtesy Emmett Witchel 1 Uniprocessor Performance Not Scaling Performance (vs. VAX-11/780) 10000 1000 100 10 1 20% /year
More informationWhat is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem?
What is the Race Condition? And what is its solution? Race Condition: Where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular
More informationCondition Variables CS 241. Prof. Brighten Godfrey. March 16, University of Illinois
Condition Variables CS 241 Prof. Brighten Godfrey March 16, 2012 University of Illinois 1 Synchronization primitives Mutex locks Used for exclusive access to a shared resource (critical section) Operations:
More informationLast class: Today: CPU Scheduling. Start synchronization
Last class: CPU Scheduling Today: Start synchronization Synchronization Processes (threads) share resources. How do processes share resources? How do threads share resources? It is important to coordinate
More informationPROVING THINGS ABOUT PROGRAMS
PROVING THINGS ABOUT CONCURRENT PROGRAMS Lecture 23 CS2110 Fall 2010 Overview 2 Last time we looked at techniques for proving things about recursive algorithms We saw that in general, recursion matches
More informationDeadlock CS 241. March 19, University of Illinois
Deadlock CS 241 March 19, 2014 University of Illinois Slides adapted in part from material accompanying Bryant & O Hallaron, Computer Systems: A Programmer's Perspective, 2/E 1 The Dining Philosophers
More informationMidterm Exam Amy Murphy 19 March 2003
University of Rochester Midterm Exam Amy Murphy 19 March 2003 Computer Systems (CSC2/456) Read before beginning: Please write clearly. Illegible answers cannot be graded. Be sure to identify all of your
More informationSystèmes d Exploitation Avancés
Systèmes d Exploitation Avancés Instructor: Pablo Oliveira ISTY Instructor: Pablo Oliveira (ISTY) Systèmes d Exploitation Avancés 1 / 32 Review : Thread package API tid thread create (void (*fn) (void
More informationAdministrivia. Assignments 0 & 1 Class contact for the next two weeks Next week. Following week
Administrivia Assignments 0 & 1 Class contact for the next two weeks Next week midterm exam project review & discussion (Chris Chambers) Following week Memory Management (Wuchi Feng) 1 CSE 513 Introduction
More informationLinked Lists: The Role of Locking. Erez Petrank Technion
Linked Lists: The Role of Locking Erez Petrank Technion Why Data Structures? Concurrent Data Structures are building blocks Used as libraries Construction principles apply broadly This Lecture Designing
More informationPROCESS SYNCHRONIZATION READINGS: CHAPTER 5
PROCESS SYNCHRONIZATION READINGS: CHAPTER 5 ISSUES IN COOPERING PROCESSES AND THREADS DATA SHARING Shared Memory Two or more processes share a part of their address space Incorrect results whenever two
More informationThe concept of concurrency is fundamental to all these areas.
Chapter 5 Concurrency(I) The central themes of OS are all concerned with the management of processes and threads: such as multiprogramming, multiprocessing, and distributed processing. The concept of concurrency
More informationCSE 153 Design of Operating Systems Fall 2018
CSE 153 Design of Operating Systems Fall 2018 Lecture 5: Threads/Synchronization Implementing threads l Kernel Level Threads l u u All thread operations are implemented in the kernel The OS schedules all
More informationThreads and concurrency
Threads and concurrency Motivation: operating systems getting really complex Multiple users, programs, I/O devices, etc. How to manage this complexity? Main techniques to manage complexity in programs?
More informationThreads and concurrency
Threads and concurrency Motivation: operating systems getting really complex Multiple users, programs, I/O devices, etc. How to manage this complexity? Main techniques to manage complexity in programs?
More informationCSCI [4 6] 730 Operating Systems. Example Execution. Process [& Thread] Synchronization. Why does cooperation require synchronization?
Process [& Thread] Synchronization CSCI [4 6] 730 Operating Systems Synchronization Part 1 : The Basics Why is synchronization needed? Synchronization Language/Definitions: What are race conditions? What
More informationOperating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy
Operating Systems Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. AL-AZHAR University Website : eaymanelshenawy.wordpress.com Email : eaymanelshenawy@yahoo.com Reference
More informationAdvanced Topic: Efficient Synchronization
Advanced Topic: Efficient Synchronization Multi-Object Programs What happens when we try to synchronize across multiple objects in a large program? Each object with its own lock, condition variables Is
More informationConcurrency: State Models & Design Patterns
Concurrency: State Models & Design Patterns Practical Session Week 02 1 / 13 Exercises 01 Discussion Exercise 01 - Task 1 a) Do recent central processing units (CPUs) of desktop PCs support concurrency?
More informationLecture #7: Shared objects and locks
Lecture #7: Shared objects and locks Review -- 1 min Independent v. cooperating threads -- can't reason about all possible interleavings Too much milk: Solution #3 to too much milk works, but it is really
More informationConcurrency - II. Recitation 3/24 Nisarg Raval Slides by Prof. Landon Cox and Vamsi Thummala
Concurrency - II Recitation 3/24 Nisarg Raval Slides by Prof. Landon Cox and Vamsi Thummala So far lock () if (nonote && nomilk){ leave note at store unlock () buy milk lock () remove note unlock () else
More informationSynchronization COMPSCI 386
Synchronization COMPSCI 386 Obvious? // push an item onto the stack while (top == SIZE) ; stack[top++] = item; // pop an item off the stack while (top == 0) ; item = stack[top--]; PRODUCER CONSUMER Suppose
More informationCPSC/ECE 3220 Summer 2018 Exam 2 No Electronics.
CPSC/ECE 3220 Summer 2018 Exam 2 No Electronics. Name: Write one of the words or terms from the following list into the blank appearing to the left of the appropriate definition. Note that there are more
More informationIntroduction to Locks. Intrinsic Locks
CMSC 433 Programming Language Technologies and Paradigms Spring 2013 Introduction to Locks Intrinsic Locks Atomic-looking operations Resources created for sequential code make certain assumptions, a large
More information