Liveness And Performance

Slides:



Advertisements
Similar presentations
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
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.
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.
Operating Systems Lecture Notes Deadlocks Matthew Dailey Some material © Silberschatz, Galvin, and Gagne, 2002.
02/27/2004CSCI 315 Operating Systems Design1 Process Synchronization Deadlock Notice: The slides for this lecture have been largely based on those accompanying.
CY2003 Computer Systems Lecture 05 Semaphores - Theory.
Practice Session 7 Synchronization Liveness Guarded Methods Model
SPL/2010 Liveness And Performance 1. SPL/2010 Performance ● Throughput - How much work can your program complete in a given time unit? ● Example: HTTP.
Deadlock CS Introduction to Operating Systems.
Chapter 6 Concurrency: Deadlock and Starvation
Starvation and Deadlock
1 Wednesday, June 28, 2006 Command, n.: Statement presented by a human and accepted by a computer in such a manner as to make the human feel that he is.
Review: Process Management Objective: –Enable fair multi-user, multiprocess computing on limited physical resources –Security and efficiency Process: running.
Modified from Silberschatz, Galvin and Gagne Lecture 13 Chapter 7: Deadlocks.
Deadlock CSCI 444/544 Operating Systems Fall 2008.
02/18/2008CSCI 315 Operating Systems Design1 Deadlock Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Process Synchronization
02/17/2010CSCI 315 Operating Systems Design1 Process Synchronization Notice: The slides for this lecture have been largely based on those accompanying.
Intro to OS CUCS Mossé Processes and Threads What is a process? What is a thread? What types? A program has one or more locus of execution. Each execution.
02/19/2007CSCI 315 Operating Systems Design1 Process Synchronization Notice: The slides for this lecture have been largely based on those accompanying.
CPS110: Deadlock Landon Cox February 5, Concurrency so far  Mostly tried to constrain orderings  Locks, monitors, semaphores  It is possible.
This Time - Deadlock Definition Conditions for deadlocks
CENG334 Introduction to Operating Systems Erol Sahin Dept of Computer Eng. Middle East Technical University Ankara, TURKEY URL:
CSE 153 Design of Operating Systems Winter 2015 Midterm Review.
Deadlocks Mark Stanovich Operating Systems COP 4610.
Deadlocks.  Deadlocks: Occurs when threads are waiting for resources with circular dependencies Often involve nonpreemptable resources, which cannot.
Silberschatz, Galvin and Gagne ©2009 Edited by Khoury, 2015 Operating System Concepts – 9 th Edition, Chapter 7: Deadlocks.
Implementing Mutual Exclusion Andy Wang Operating Systems COP 4610 / CGS 5765.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Deadlock CS Introduction to Operating Systems.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Deadlock.
NETW 3005 Monitors and Deadlocks. Reading For this lecture, you should have read Chapter 7. NETW3005 (Operating Systems) Lecture 06 - Deadlocks2.
Deadlock Operating Systems (CC2011NI) -Mr. Pranoy Man Pradhan.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Process Management Deadlocks.
Synchronization Deadlocks and prevention
Synchronization Deadlocks and prevention
CSCD 330 Network Programming
Threaded Programming in Python
Operating Systems Design (CS 423)
Deadlock Management.
Virtual Memory Networks and Communication Department.
Chapter 7 – Deadlock and Indefinite Postponement
Operating System: DEADLOCKS
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Introduction to Operating Systems
COP 4600 Operating Systems Fall 2010
Chapter 7: Deadlocks.
COT 4600 Operating Systems Fall 2009
Implementing Mutual Exclusion
Threaded Programming in Python
Conditions for Deadlock
Andy Wang Operating Systems COP 4610 / CGS 5765
Implementing Mutual Exclusion
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
Deadlocks Session - 13.
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
SE350: Operating Systems Lecture 5: Deadlock.
Introduction to Deadlocks
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
CENG334 Introduction to Operating Systems
CS703 - Advanced Operating Systems
CSE 153 Design of Operating Systems Winter 2019
EECE.4810/EECE.5730 Operating Systems
EECE.4810/EECE.5730 Operating Systems
CSE 542: Operating Systems
CSE 542: Operating Systems
Synchronization and liveness
Presentation transcript:

Liveness And Performance Lecture 10  Liveness And Performance

Performance Latency - the time required to perform some action or to produce some result. Measured in some time-units. Example: It takes four hours to assemble a car.

Performance Throughput -is the number of actions executed or produced per unit of time. Measured in units of whatever is being produced per unit of time. Examples: The factory assembles 1000 cars a day. HTTP web server - how many pages per second can the server actually serve? memory bandwidth: MBs/sec.

Performance Efficiency – What is the computational complexity of your program? How efficiently are you using the RTEs resources? Related to both latency and throughput.

Liveness "Something useful eventually happens within an activity“ We have seen several cases where a program stops: Acquiring locks. Waiting on Objects. Waiting for I/O. Waiting for CPU time. Failures. Resource exhaustion.

LiveLock narrow hallway - one person may pass at time Alice started walking down the hallway Bob is approaching her from the other side. Alice decides to let Bob pass her by moving left. Bob, at the same time, decides to let Alice pass him by moving right

LiveLock narrow hallway - one person may pass at time Alice started walking down the hallway Bob is approaching her from the other side. Alice decides to let Bob pass her by moving left. Bob, at the same time, decides to let Alice pass him by moving right Both move to same side - still in each-other's way! Alice moves to her right Bob, at the same time, moves to his left. Alice and Bob are doing something, but there is no global progress!

LiveLock Livelock = two threads canceling each others' actions. due to bad design - re-design system

Runtime diagram wait()/notifyAll() force threads to work one after the other. Each time, the threads "undo" the work done by the other one.

DeadLock Deadlock =  two or more competing actions are waiting for each other to finish in a circular chain neither ever does

Deadlock

Deadlock – erasing board two people erase one board, with one eraser If person A takes board and B takes the eraser, a deadlock occurs. To finish erasing board A needs the eraser B needs the board

A first tries to grab board. If succeeds, he tries to grab the eraser.  Taking algorithm: A first tries to grab board. If succeeds, he tries to grab the eraser. B does the same, but in the opposite order. "grab" = locking the appropriate object

Thread.yield() notify the system that the current thread is willing to "give up the CPU" for a while scheduler selects different thread to run

Deadlock Thread 1 Thread 2 acquire lock for a on entering a.swapValue(b) execute t=getValue() successfully (since already held) block waiting for lock of b on entering v= other.getValue() Thread 2 acquire lock for b on entering  b.swapValue (a) execute t=getValue() successfully (since already held) block waiting for lock of a on entering v = other.getValue()

Deadlock – circular dependency

Deadlock caused by circular lock Both threads are blocked due to circular wait Resource ordering solution: grab locks in the same order to avoid deadlocks

Deadlock caused by wait

Dining Philosophers Problem

Dining Philosophers Problem N philosophers (=threads) in a circle, each with a plate of in front of him. N forks (=resources) - between any two philosophers there is exactly one fork Philosophers ponder and eat (=methods) To eat, a philosopher must grab both forks to his left and right (=locks). He then eats and returns forks to table

running the code with 3 Confuciuses: 0 is pondering 1 is pondering 2 is pondering 0 is hungry 1 is hungry 2 is hungry deadlock: each grabbed his left fork, and will wait forever for his right fork

Deadlock Prevention Solution 1: Break symmetry/cycle make sure one Philosopher grabs the right fork first. Solution 2: Resource ordering make sure forks are grabbed in some global order (rather than left and right of each philosopher).

Deadlock Prevention Solution 3: Request all resources atomically each thread asks for ALL resources atomically. adding another lock known to all philosophers, which they must grab before trying to grab any fork and release once they have grabbed both forks. not recommended - requires another lock, managed by the programmer, requires book-keeping, or careful implementation.

Resource Ordering: make two philosophers grab the same fork FIRST.

Starvation dining philosophers. No Circular dependency. “t1 is faster that t2” Ponder Eat t2 rarely (if at all) succeeds in grabbing the fork shared with t1. t2 Starving.

Starvation Several threads all waiting for a shared resource, which is repeatedly available. At least one thread never (or rarely) gets its hands on the shared resource. Identifying starvation is hard Solving starvation is done at design time.

Starvation solution Use synchronization primitives which support ordering. synchronized construct does not guarantee ordering of blocked threads Semaphore class supports ordering. Fairness flag in C’tor. 

Semaphore fairness First-In-First-Out (FIFO): thread that has been waiting the longest is always selected.

dining philosophers with no starvation