Concurrency (2) CSE 132. Question The following four numbers are in 8-bit 2’s complement form: 00000000101010100101010111111111 Which order below represents.

Slides:



Advertisements
Similar presentations
Apoorva Vadi M.S Information Systems New York University
Advertisements

Operating Systems: Monitors 1 Monitors (C.A.R. Hoare) higher level construct than semaphores a package of grouped procedures, variables and data i.e. object.
Parallel Programming – Barriers, Locks, and Continued Discussion of Parallel Decomposition David Monismith Jan. 27, 2015 Based upon notes from the LLNL.
Operating Systems Mehdi Naghavi Winter 1385.
CS252: Systems Programming Ninghui Li Based on Slides by Prof. Gustavo Rodriguez-Rivera Topic 14: Deadlock & Dinning Philosophers.
Practice Session 7 Synchronization Liveness Deadlock Starvation Livelock Guarded Methods Model Thread Timing Busy Wait Sleep and Check Wait and Notify.
Chapter 6 Process Synchronization Bernard Chen Spring 2007.
Chapter 6: Process Synchronization
5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 5: CPU Scheduling.
Multiprocessor Synchronization Algorithms ( ) Lecturer: Danny Hendler The Mutual Exclusion problem.
Concurrency (3) CSE 132. iClicker/WUTexter Question The following four numbers are in 8-bit 2’s complement form: Which.
6.5 Semaphore Can only be accessed via two indivisible (atomic) operations wait (S) { while S
Classical Problems of Concurrency
02/19/2010CSCI 315 Operating Systems Design1 Process Synchronization Notice: The slides for this lecture have been largely based on those accompanying.
Chapter 6: Process Synchronization. Outline Background Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores Classic Problems.
Concurrency: Deadlock and Starvation Chapter 6. Revision Describe three necessary conditions for deadlock Which condition is the result of the three necessary.
A Introduction to Computing II Lecture 18: Concurrency Issues Fall Session 2000.
Process Synchronization
Chapter 7 – Deadlock and Indefinite Postponement
Definitions Process – An executing program
Adopted from and based on Textbook: Operating System Concepts – 8th Edition, by Silberschatz, Galvin and Gagne Updated and Modified by Dr. Abdullah Basuhail,
Concurrency: Deadlock1 ©Magee/Kramer 2 nd Edition Chapter 6 Deadlock.
CSC321 §9 Deadlock 1 Section 9 Deadlock. CSC321 §9 Deadlock 2 Deadlock: four necessary and sufficient conditions  Serially reusable resources: the processes.
Operating Systems CSE 411 CPU Management Oct Lecture 13 Instructor: Bhuvan Urgaonkar.
28/10/1999POS-A1 The Synchronization Problem Synchronization problems occur because –multiple processes or threads want to share data; –the executions.
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.
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION Third Edition ANDREW S. TANENBAUM ALBERT S. WOODHULL Yan hao (Wilson) Wu University of the Western.
Operating Systems CSE 411 CPU Management Dec Lecture Instructor: Bhuvan Urgaonkar.
CENG334 Introduction to Operating Systems Erol Sahin Dept of Computer Eng. Middle East Technical University Ankara, TURKEY URL:
Threads and Singleton. Threads  The JVM allows multiple “threads of execution”  Essentially separate programs running concurrently in one memory space.
Deadlock cs550 Operating Systems David Monismith.
CS 241 Section Week #7 (10/22/09). Topics This Section  Midterm Statistics  MP5 Forward  Classical Synchronization Problems  Problems.
Deadlock Conditions for Deadlock Deadlock Prevention Deadlock Detection Deadlock Recovery Dining Philosophers Semaphores.
6.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Module 6: Process Synchronization.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 3-3: Process Synchronization Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
CS4315A. Berrached:CMS:UHD1 Process Synchronization Chapter 8.
Dining Philosophers & Monitors Questions answered in this lecture: How to synchronize dining philosophers? What are monitors and condition variables? What.
1 Java Programming Java Programming II Concurrent Programming: Threads ( II)
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 5: Process Synchronization.
Synchronization Questions answered in this lecture: Why is synchronization necessary? What are race conditions, critical sections, and atomic operations?
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
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
Semaphore Synchronization tool that provides more sophisticated ways (than Mutex locks) for process to synchronize their activities. Semaphore S – integer.
Process Synchronization
Chapter 5: Process Synchronization – Part 3
Auburn University COMP 3500 Introduction to Operating Systems Synchronization: Part 4 Classical Synchronization Problems.
Chapter 5: Process Synchronization
Chapter 5: Process Synchronization – Part II
Chapter 5: Process Synchronization
Classical Synchronization Problems
Chapter 7 – Deadlock and Indefinite Postponement
Definitions Concurrent program – Program that executes multiple instructions at the same time. Process – An executing program (the running JVM for Java.
Chapter 5: Process Synchronization (Con’t)
Lecture 25 Syed Mansoor Sarwar
Process Synchronization
Module 7a: Classic Synchronization
Critical section problem
Chapter 7: Synchronization Examples
Programming with Shared Memory Java Threads and Synchronization
Programming with Shared Memory Java Threads and Synchronization
Conditions for Deadlock
Operating System 6 CONCURRENCY: MUTUAL EXCLUSION AND SYNCHRONIZATION
CENG334 Introduction to Operating Systems
EECE.4810/EECE.5730 Operating Systems
CSE 542: Operating Systems
CSE 542: Operating Systems
Presentation transcript:

Concurrency (2) CSE 132

Question The following four numbers are in 8-bit 2’s complement form: Which order below represents lowest to highest? A: B: C: D: E: none of the above

Synchronization Implicit “lock” associated with every object Synchronized methods acquire object’s lock prior to entering method and then release lock once method is complete Synchronized statement allows finer control (illustrated next) Either way, lock enforces mutual exclusion, only one thread at a time is allowed in “critical section,” or region of code controlled by lock

Synchronized statement public void addName(String name) { synchronized(this) { lastName = name; nameCount++; } nameList.add(name); } Argument is object whose lock is acquired Doesn’t synchronize add() method invocation

PropertyChangeSupport Bound properties – anonymous notification when a property’s value changes Properties are identified by strings – Must be identical for both publishers and subscribers Publishers indicate to PCS that property changed Subscribers are then notified of new property value Provides excellent observability for multi- threaded applications

Example Publishers – three RandomPerson objects Subscribers – interested in different properties about the publishers Properties – things persons are doing: – Walk “strolling” – TV “watching TV” – Nap “snoozing” – Guitar “playing guitar”

Dining Philosophers Five silent philosophers sit at a round table with bowls of rice. A chopstick is placed between each pair of adjacent philosophers. Each philosopher must alternately think and eat. Eating is not limited by the amount of rice left: assume an infinite supply. However, a philosopher can only eat while holding both the chopstick to the left and the chopstick to the right. Each philosopher can pick up an adjacent chopstick, when available, and put it down, when holding it. These are separate actions: chopsticks must be picked up and put down one by one. How do we design a concurrent algorithm such that each philosopher won't starve, i.e., can forever continue to alternate between eating and thinking.