Resource Allocation. Pradipta De

Similar documents
The Drinking Philosophers Problem-1

A Modification to the Chandy-Misra Dining Philosophers Algorithm to Support Dynamic Resource Conflict Graphs

Resource Allocation - Dining Philosophers. Dining Philosophers - Properties. OK? EATING[(i%N)+1]) Impossibility Result for Symmetric Algorithm

Interprocess Communication By: Kaushik Vaghani

The Drinking Philosophers Problem: Resource Allocation in Distributed Systems

CSCC 69H3 2/1/13. Today: Deadlock. Remember example from last week? Example of Deadlock. Example: dining philosophers: Not just an OS Problem!

Process Synchronization

Introduction to Linear-Time Temporal Logic. CSE 814 Introduction to LTL

System Software. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 13

Lecture Topics. Announcements. Today: Concurrency (Stallings, chapter , 5.7) Next: Exam #1. Self-Study Exercise #5. Project #3 (due 9/28)

EE 382C Interconnection Networks

Deadlock Prevention, Avoidance, and Detection

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Processes The Process Model. Chapter 2. Processes and Threads. Process Termination. Process Creation

CSE306 - Homework2 and Solutions

Concurrency: Principles of Deadlock. Processes and resources. Concurrency and deadlocks. Operating Systems Fall Processes need resources to run

PESIT Bangalore South Campus

Process Management And Synchronization

Self Stabilization. CS553 Distributed Algorithms Prof. Ajay Kshemkalyani. by Islam Ismailov & Mohamed M. Ali

Classical Synchronization Problems. Copyright : University of Illinois CS 241 Staff 1

OPERATING SYSTEMS. Deadlocks

Processes The Process Model. Chapter 2 Processes and Threads. Process Termination. Process States (1) Process Hierarchies

Concurrency: Deadlock and Starvation. Chapter 6

Chapter 6 Concurrency: Deadlock and Starvation

Liveness properties. Deadlock

CSCE Operating Systems Deadlock. Qiang Zeng, Ph.D. Fall 2018

Multithreaded Programming Part II. CSE 219 Stony Brook University, Department of Computer Science

CS3502 OPERATING SYSTEMS

Concurrency. Chapter 5

Synchronization Principles II

Multicore and Multiprocessor Systems: Part I

What Is A Relation? Example. is a relation from A to B.

Distributed Deadlock Detection

Deadlocks. Deadlock in Resource Sharing Environment. CIT 595 Spring Recap Example. Representing Deadlock

The deadlock problem

CSC501 Operating Systems Principles. Process Synchronization

Chapter 6: Synchronization. Chapter 6: Synchronization. 6.1 Background. Part Three - Process Coordination. Consumer. Producer. 6.

Chapter 6: Process Synchronization

6.852: Distributed Algorithms Fall, Class 15

ECS 150 (Operating Systems) Goal To examine what causes deadlock, and what to do about it. Spring Quarter

COMP 150-CCP Concurrent Programming. Lecture 12: Deadlock. Dr. Richard S. Hall

Chapter 7: Process Synchronization!

Lecture Topics. Announcements. Today: Concurrency: Mutual Exclusion (Stallings, chapter , 5.7)

CMSC 330: Organization of Programming Languages. Threads Classic Concurrency Problems

Petri Nets ~------~ R-ES-O---N-A-N-C-E-I--se-p-te-m--be-r Applications.

Process Synchronization(2)

Deadlock. Concepts: Models: Practice: Aim: deadlock avoidance - to design systems where deadlock cannot occur. Chapter 6. Deadlock

CHAPTER 6: PROCESS SYNCHRONIZATION

CSE Traditional Operating Systems deal with typical system software designed to be:

Concurrency pros and cons. Concurrent Programming Problems. Mutual Exclusion. Concurrency is good for users

Process Synchronization

Class Notes, 3/21/07, Operating Systems

Operating Systems. Operating Systems Sina Meraji U of T

The Dining Philosophers Problem CMSC 330: Organization of Programming Languages

Concurrency pros and cons. Concurrent Programming Problems. Linked list example. Linked list example. Mutual Exclusion. Concurrency is good for users

Operating systems. Lecture 12

CMSC 330: Organization of Programming Languages. The Dining Philosophers Problem

Using Diposets to Model Concurrent Systems

CS370 Operating Systems

Roadmap. Readers-Writers Problem. Readers-Writers Problem. Readers-Writers Problem (Cont.) Dining Philosophers Problem.

Concurrency: Deadlock and Starvation. Chapter 6

Deadlock. INF2140 Parallel Programming: Lecture 6. March 07, INF2140 Parallel Programming: Lecture 6 Deadlock

Deadlock and Monitors. CS439: Principles of Computer Systems September 24, 2018

Concurrency: Deadlock 1. Magee/Kramer 2 nd Edition

Synchronization Principles

Operating Systems: (Tue)

Deadlock. Concurrency: Deadlock and Starvation. Reusable Resources

Operating Systems: William Stallings. Starvation. Patricia Roy Manatee Community College, Venice, FL 2008, Prentice Hall

CSE332: Data Abstractions Lecture 25: Deadlocks and Additional Concurrency Issues. Tyler Robison Summer 2010

Process Synchronization

The Language for Specifying Lexical Analyzer

CSE 486/586 Distributed Systems

Process Synchronization. CISC3595, Spring 2015 Dr. Zhang

Mutual Exclusion. 1 Formal problem definitions. Time notion CSE /17/2015. Outline of this lecture:

Sections 01 (11:30), 02 (16:00), 03 (8:30) Ashraf Aboulnaga & Borzoo Bonakdarpour

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - XI Deadlocks - II. Louisiana State University

Starvation and Deadlock

Roadmap. Bounded-Buffer Problem. Classical Problems of Synchronization. Bounded Buffer 1 Semaphore Soln. Bounded Buffer 1 Semaphore Soln. Tevfik Ko!

Chapter 6. Deadlock. DM519 Concurrent Programming

COMP Parallel Computing. PRAM (3) PRAM algorithm design techniques

Readers/Writers Problem. Readers/Writers: Scenario 1. Readers/Writers Problem. Today: Synchronization for Readers/Writers Problem

Multicore and Multiprocessor Systems: Part I

Chapter 6: Synchronization. Operating System Concepts 8 th Edition,

Semaphores. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Deadlocks Characterization & Detection

Using Spin to Help Teach Concurrent Programming

D commercial, industrial, and research establishments. One of

Process Co-ordination OPERATING SYSTEMS

Introduction to Operating Systems

Lecture 3: Intro to Concurrent Processing using Semaphores

Concept of a process

Concurrent Computing

Chapter 5: Process Synchronization. Operating System Concepts Essentials 2 nd Edition

Operating Systems Antonio Vivace revision 4 Licensed under GPLv3

Lecture 10: Multi-Object Synchronization

Synchronization. Silvina Hanono Wachman Computer Science & Artificial Intelligence Lab M.I.T.

Semaphores INF4140. Lecture 3. 0 Book: Andrews - ch.04 ( ) INF4140 ( ) Semaphores Lecture 3 1 / 34

Reinhard v. Hanxleden 1, Michael Mendler 2, J. Aguado 2, Björn Duderstadt 1, Insa Fuhrmann 1, Christian Motika 1, Stephen Mercer 3 and Owen Brian 3

Synchronization. Peter J. Denning CS471/CS571. Copyright 2001, by Peter Denning

Transaction Processing Concurrency control

Transcription:

Resource Allocation Pradipta De pradipta.de@sunykorea.ac.kr

Outline Dining Philosophers Problem Drinking Philosophers Problem

Dining Philosophers Problem f(5) 5 f(1) Each philosopher goes through, Think (R) hungry (T) eat (C) think (E) 4 1 Needs two forks to eat mutual exclusion problem on two resources f(2) f(4) 3 f(3) 2 Fork to right = f(i) Fork to left = f(i+1)

Simple (Wrong) Solution Each process on entering T region, Wait for its right fork, then for its left fork After getting both forks, execute C Release both forks after exiting C If all the processes are identical, and the shared variables (forks) have same initial value, then there is no solution to DP problem No symmetric solution to DP problem Why? CSE 535 Resource Allocation

Simple (Wrong) DP Solution Does it satisfy Mutual Exclusion? A process reaching C does have two forks Does it satisfy progress property? All processes enter try region one after another Each gets the right fork, but now there is deadlock over left fork Must break symmetry of the ring Unique identifiers to create ordering Different programs for odd/even id processes Initialize the shared variables differently

Right-Left DP Algorithm Main idea Careful design of the order in which forks are sought Assume an execution as follows: P5 has both forks P4 gets right fork, waits for left fork P3 gets right fork, waits for left fork P2 gets right fork, waits for left fork Length of waiting chain = 3 i.e. n-2 Processes enter CS sequentially time to enter CS is proportional to waiting chain length CSE 535 Resource Allocation

Right-Left DP Algorithm Assume n processes (n is even) Two different programs for odd and even indexed processes Odd numbered processes seek Right fork first, then left fork Even numbered processes seek Left fork first, then right fork CSE 535 Resource Allocation

Right-Left DP Algorithm f(6) 6 f(1) P1 P2 P3 P4 P5 P6 5 1 f(1) f(3) f(3) f(5) f(5) f(1) f(2) f(2) f(4) f(4) f(6) f(6) f(5) f(2) Still need to break the tie between two processes requesting same fork -- use the process index 4 f(4) 3 f(3) 2 Has bounded time to enter CS guarantees progress

Conflict graph p4 p5 p4 p5 p3 p1 p3 p1 Conflict Graph p2 Precedence Graph Conflict Graph: An undirected graph in which each node represents a process and an edge between process P i and P j denotes one or more resources are shared between P i and P j Precedence Graph adds orientation to each edge generating an acyclic graph, where edge P i to P j P i has precedence over P j Conflict graph for single resource shared among all processes ME problem? CSE 535 Resource Allocation p2

Edge Reversal Algorithm p4 p5 p3 p1 Acyclic orientation with p2 and p4 as sources, or processes with precedence over its neighbors p2 Reverse orientation of edges after use p4 p5 p3 p1 Orientation after p2 and p4 leave CS p2

Edge Reversal Algorithm Assume that a philosopher is not hungry, but the edge still reverses (light load condition) Do not reverse edge when CS completed Process requests fork when hungry Distinguish two cases Process has fork, but not used it (clean fork) Process has fork, and have used it (dirty fork) Edge is from u->v (u has precedence over v) if u holds fork, and it is clean v holds fork, and it is dirty Fork is in transit from v to u Start from acyclic precedence graph, and at each step algorithm maintains the graph to remain acyclic

Drinking Philosophers Problem A philosopher does not always require all the resources it shares with its neighbors. May need only a subset of the resources, and the required resources may change across sessions Example: two processes Pi and Pj can access different files in one session ( allow concurrent access), but same files in another session ( requires conflict resolution) Philosopher states = {tranquil, thirsty, drinking} Requires a set of resources (modelled as bottles) when thirsty to enter drinking phase

Drinking Philosopher Solution Builds on Dining Philosophers Solution Use forks as auxiliary resources to resolve conflict Bottles are real resource for sharing Forks and bottles are shared between two processes Rules: Thinking, thirsty P becomes hungry in finite time Eating, nonthirsty P starts thinking U sends the bottle to v, on receiving req, iff U does not need the bottle U is not drinking and does not hold the fork for edge u,v

Drinking Philosophers Algorithm Fork is with process u, Thirsty need bottle Bottle not with u Receives req, and has bottle, Satisfy condition to release bottle, then send bottle