OpenMP and more Deadlock 2/16/18

Similar documents
Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

Chapter 6. Deadlock. (A Quick Introduction)

Operating Systems. Lecture3.2 - Deadlock Management. Golestan University. Hossein Momeni

COS 318: Operating Systems. Deadlocks. Jaswinder Pal Singh Computer Science Department Princeton University

Resources. Lecture 4. Deadlocks. Resources (2) Resources (1) Four Conditions for Deadlock. Introduction to Deadlocks

Last Class: Monitors. Real-world Examples

Chapter 3. Deadlocks

Chapter 3. Deadlocks

Deadlock Prevention. CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han

Deadlocks Prof. James L. Frankel Harvard University. Version of 7:05 PM 7-Mar-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved.

Chapter 3: Deadlocks

Introduction to OS. Deadlock. MOS Ch. 6. Mahmoud El-Gayyar. Mahmoud El-Gayyar / Introduction to OS 1

Deadlocks. Thomas Plagemann. With slides from C. Griwodz, K. Li, A. Tanenbaum and M. van Steen

Parallel Computing. Lecture 16: OpenMP - IV

Operating Systems ECE344. Ding Yuan

Questions from last time

Deadlocks. Tore Larsen. With slides from T. Plagemann, C. Griwodz, K. Li, A. Tanenbaum and M. van Steen

Process P holds resource R. Process P is waiting for resource R. P Process P holds T and requests R. R Process Q holds R and requests T

MODERN OPERATING SYSTEMS. Third Edition ANDREW S. TANENBAUM. Chapter 6 Deadlocks

More on Synchronization and Deadlock

CSE 306/506 Operating Systems Deadlock. YoungMin Kwon

Shared and Preemptable Resources. A few resources may be sharable. Anyone can write the system log.

Deadlocks. Today. Next Time. ! Resources & deadlocks! Dealing with deadlocks! Other issues. ! Memory management

CS 318 Principles of Operating Systems

MODERN OPERATING SYSTEMS. Third Edition ANDREW S. TANENBAUM. Chapter 6 Deadlocks

DEADLOCKS M O D E R N O P E R A T I N G S Y S T E M S C H A P T E R 6 S P R I N G

Deadlocks. Today. Next Time. Resources & deadlocks Dealing with deadlocks Other issues. I/O and file systems

1 of 6 Lecture 7: March 4. CISC 879 Software Support for Multicore Architectures Spring Lecture 7: March 4, 2008

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

Concurrency: Deadlock and Starvation. Chapter 6

Resource management. Real-Time Systems. Resource management. Resource management

Administrivia. Assignments 0 & 1 Class contact for the next two weeks Next week. Following week

CSE120 Principles of Operating Systems. Prof Yuanyuan (YY) Zhou Deadlock

Chapter 3: Deadlocks. Chapter 3

What is Deadlock? Two or more entities need a resource to make progress, but will never get that resource. Examples from everyday life:

Deadlock. Rab Nawaz Jadoon DCS. Assistant Professor COMSATS Lahore Pakistan. Department of Computer Science

Introduction to Parallel Programming Part 4 Confronting Race Conditions

Last Class: Synchronization Problems!

OPERATING SYSTEMS. After A.S.Tanenbaum, Modern Operating Systems, 3rd edition. Uses content with permission from Assoc. Prof. Florin Fortis, PhD

CS450/550 Operating Systems

Readings and References. Deadlock. Deadlock. Simple Traffic Gridlock Example. Reading. CSE Computer Systems November 30, 2001.

Deadlock 1 Chapter 6

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

CS 4410 Operating Systems. Review 1. Summer 2016 Cornell University

! What is a deadlock? ! What causes a deadlock? ! How do you deal with (potential) deadlocks? Maria Hybinette, UGA

Spinlocks. Spinlocks. Message Systems, Inc. April 8, 2011

CSE 380 Computer Operating Systems

Fall 2015 COMP Operating Systems. Lab 06

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

6. Concurrency: Deadlock

ECE519 Advanced Operating Systems

Chapter 7: Deadlocks 1

Real-Time Systems. Lecture #4. Professor Jan Jonsson. Department of Computer Science and Engineering Chalmers University of Technology

Deadlock. Disclaimer: some slides are adopted from Dr. Kulkarni s and book authors slides with permission 1

Deadlock. Readings and References. Simple Traffic Gridlock Example. Deadlock. Reading. Other References. CSE 410, Spring 2006 Computer Systems

CS 470 Spring Mike Lam, Professor. Advanced OpenMP

OPERATING SYSTEMS. Prescribed Text Book. Operating System Principles, Seventh Edition. Abraham Silberschatz, Peter Baer Galvin and Greg Gagne

Concurrency, Thread. Dongkun Shin, SKKU

Solved MCQs on Operating System Principles. Set-1

Deadlock. A Bit More on Synchronization. The Deadlock Problem. Deadlock Characterization. Operating Systems 2/7/2005. CSC 256/456 - Spring

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

SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (II)

Chapter 6 - Deadlocks

2. The system of... generally ran one job at a time. These were called single stream batch processing.

Chapter 6. Deadlocks

Resource Sharing & Management

Operating Systems Structure

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

System Software Assignment 8 Deadlocks

Last Class: Synchronization Problems. Need to hold multiple resources to perform task. CS377: Operating Systems. Real-world Examples

Outline. Deadlock. Examples, Conditions, Strategies. Deadlock Prevention. Deadlock Avoidance. Banker s algorithm

Lecture 9: Midterm Review

SSC - Concurrency and Multi-threading Advanced topics about liveness

Chapter seven: Deadlock and Postponement

CSE 153 Design of Operating Systems

Deadlock. Concurrency: Deadlock and Starvation. Reusable Resources

CS 261 Fall Mike Lam, Professor. Threads

OS 1 st Exam Name Solution St # (Q1) (19 points) True/False. Circle the appropriate choice (there are no trick questions).

CME 213 S PRING Eric Darve

Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - XI Deadlocks - II. University at Buffalo. Deadlocks. October 6 th, 2011

!! What is a deadlock? !! What causes a deadlock? !! How do you deal with (potential) deadlocks? Maria Hybinette, UGA

System Model. Types of resources Reusable Resources Consumable Resources

Deadlock Prevention. Deadlock can be prevented if 1 of the 4 conditions cannot hold

CS370 Operating Systems

Deadlock. Operating Systems. Autumn CS4023

Deadlock 1 Chapter 6

Last Class: Deadlocks. Today

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

Concurrency: Deadlock and Starvation. Chapter 6

(b) External fragmentation can happen in a virtual memory paging system.

CS420: Operating Systems. Deadlocks & Deadlock Prevention

Chapter 8: Deadlocks. Bridge Crossing Example. The Deadlock Problem

Operating Systems. Deadlock. User OS. Kernel & Device Drivers. Interface Programs. Brian Mitchell - Operating Systems

COMPUTER SCIENCE 4500 OPERATING SYSTEMS

System Model. Deadlocks. Deadlocks. For example: Semaphores. Four Conditions for Deadlock. Resource Allocation Graph

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

Computer Science 4500 Operating Systems. In This Module. Deadlock Definition. Module 7 Deadlocks

Computer Science 4500 Operating Systems

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

Shared Memory Programming with OpenMP (3)

Transcription:

OpenMP and more Deadlock 2/16/18

Administrivia HW due Tuesday Cache simulator (direct-mapped and FIFO)

Steps to using threads for parallelism Move code for thread into a function Create a struct to hold arguments Make threads and pass appropriate structs Cast arguments from void* Join threads Cast return values from void*

Parallelizing Mandelbrot program using OpenMP

Parallelizing Mandelbrot program using OpenMP Add pragma before outer loop #pragma omp parallel for Compile with -fopenmp

Other OpenMP features create threads assigned different tasks mark critical sections barrier (threads wait at a certain point until all have reached it)

Strategy 2: Detect and recover Periodically run a deadlock detection algorithm and kill an involved process if one is found

Strategy 3: Deadlock prevention Deny one of the conditions needed for deadlock: Mutual exclusion: Resources assigned to <= 1 process at a time Hold and wait: Process can hold resources while waiting for more No preemption: System can t take resources back Circular wait: There can be a circular chain of processes waiting for each other s resources

Which of the conditions is prevented by the scheme below? Two-phase locking: Acquire all locks at once; release and backoff if you can t. Then perform critical section and release everything A. Mutual exclusion (Resources assigned to <= 1 process at a time) B. Hold and wait (Process can hold resources while waiting) C. No preemption (System can t take resources back) D. Circular waiting (Can be circular chain of processes waiting) E. None of the above; deadlock can still occur

Which of the conditions is prevented by the scheme below? Two-phase locking: Acquire all locks at once; release and backoff if you can t. Then perform critical section and release everything A. Mutual exclusion (Resources assigned to <= 1 process at a time) B. Hold and wait (Process can hold resources while waiting) C. No preemption (System can t take resources back) D. Circular waiting (Can be circular chain of processes waiting) E. None of the above; deadlock can still occur

Which of the conditions is prevented by the scheme below? Assign a number to every resource and require that processes request resources in order A. Mutual exclusion (Resources assigned to <= 1 process at a time) B. Hold and wait (Process can hold resources while waiting) C. No preemption (System can t take resources back) D. Circular waiting (Can be circular chain of processes waiting) E. None of the above; deadlock can still occur

Which of the conditions is prevented by the scheme below? Assign a number to every resource and require that processes request resources in order A. Mutual exclusion (Resources assigned to <= 1 process at a time) B. Hold and wait (Process can hold resources while waiting) C. No preemption (System can t take resources back) D. Circular waiting (Can be circular chain of processes waiting) E. None of the above; deadlock can still occur

Which of the conditions is prevented by the scheme below? Spooling: Instead of blocking for a resource such as a printer, write the operation to a buffer which the OS handles when possible A. Mutual exclusion (Resources assigned to <= 1 process at a time) B. Hold and wait (Process can hold resources while waiting) C. No preemption (System can t take resources back) D. Circular waiting (Can be circular chain of processes waiting) E. None of the above; deadlock can still occur

Which of the conditions is prevented by the scheme below? Spooling: Instead of blocking for a resource such as a printer, write the operation to a buffer which the OS handles when possible A. Mutual exclusion (Resources assigned to <= 1 process at a time) B. Hold and wait (Process can hold resources while waiting) C. No preemption (System can t take resources back) D. Circular waiting (Can be circular chain of processes waiting) E. None of the above; deadlock can still occur

Which of the conditions is prevented by the scheme below? Require processes to request all needed resources when they ask to start and only start processes whose needs can be met (more appropriate for hardware resources than locks...) A. Mutual exclusion (Resources assigned to <= 1 process at a time) B. Hold and wait (Process can hold resources while waiting) C. No preemption (System can t take resources back) D. Circular waiting (Can be circular chain of processes waiting) E. None of the above; deadlock can still occur

Which of the conditions is prevented by the scheme below? Require processes to request all needed resources when they ask to start and only start processes whose needs can be met (more appropriate for hardware resources than locks...) A. Mutual exclusion (Resources assigned to <= 1 process at a time) B. Hold and wait (Process can hold resources while waiting) C. No preemption (System can t take resources back) D. Circular waiting (Can be circular chain of processes waiting) E. None of the above; deadlock can still occur