Applied Operating System Concepts -

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

Chapter 5 CPU Scheduling. CPU Scheduling Topics: Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
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.
Chapter 7: Deadlocks. 7.2 Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks.
02/19/2008CSCI 315 Operating Systems Design1 Deadlock Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 7: Deadlocks.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Bridge Crossing Example Traffic only in one direction. Each section.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Deadlocks.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 8: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks.
SWE202 Review. Processes Process State As a process executes, it changes state – new: The process is being created – running: Instructions are being.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks Modified.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
Review for Quiz-2 Applied Operating System Concepts Chap.s 1,2,6,7 - ECE3055b, Spring 2005.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks The Deadlock.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 7 Operating Systems.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 6 Deadlocks Slide 1 Chapter 6 Deadlocks.
Deadlock. Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock.
Silberschatz, Galvin and Gagne ©2009 Edited by Khoury, 2015 Operating System Concepts – 9 th Edition, Chapter 7: Deadlocks.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
Lecture 6 Deadlock 1. Deadlock and Starvation Let S and Q be two semaphores initialized to 1 P 0 P 1 wait (S); wait (Q); wait (Q); wait (S);. signal (S);
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
Synchronization Deadlocks and prevention
Chapter 7: Deadlocks.
lecture 5: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 5a: CPU Scheduling
G.Anuradha Ref:- Galvin
Chapter 7: Deadlocks Source & Copyright: Operating System Concepts, Silberschatz, Galvin and Gagne.
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Operating System: DEADLOCKS
Chapter 5: CPU Scheduling
Chapter 7 Deadlocks.
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Process Deadlocks.
Chapter 5: CPU Scheduling
3: CPU Scheduling Basic Concepts Scheduling Criteria
Chapter5: CPU Scheduling
Chapter 7: Deadlocks.
Chapter 6: CPU Scheduling
Deadlock B.Ramamurthy CSE421 1/11/2019 B.Ramamurthy.
G.Anuradha Ref:- Galvin
Chapter 5: CPU Scheduling
Chapter 5: CPU Scheduling
Deadlock B.Ramamurthy CSE421 2/23/2019 B.Ramamurthy.
Deadlocks Session - 13.
Operating System , Fall 2000 EA101 W 9:00-10:00 F 9:00-11:00
Deadlock B.Ramamurthy CSE421 4/23/2019 B.Ramamurthy.
Chapter 6: CPU Scheduling
Deadlock B.Ramamurthy CSE421 5/1/2019 B.Ramamurthy.
Chapter 5: CPU Scheduling
Module 5: CPU Scheduling
CSCI 315 Operating Systems Design
CENG334 Introduction to Operating Systems
Chapter 6: CPU Scheduling
Chapter 7: Deadlocks.
CPU Scheduling.
Chapter 8: Deadlocks Deadlock Characterization
Deadlock B.Ramamurthy CSE421 8/28/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 9/3/2019 B.Ramamurthy.
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Presentation transcript:

Applied Operating System Concepts - Review of Chap.s 6-8 Applied Operating System Concepts - Scheduling, Synchronization, Deadlocks ECE3055a, Spring 3055

Module 5: Threads Thread Management Done by User-Level Threads Library Examples - POSIX Pthreads - Mach C-threads - Solaris threads Supported by the Kernel Examples - Windows 95/98/NT - Solaris - Digital UNIX 2

Solaris 2 Threads 3

Java Thread Management suspend() – suspends execution of the currently running thread. sleep() – puts the currently running thread to sleep for a specified amount of time. resume() – resumes execution of a suspended thread. stop() – stops execution of a thread. 4

UNIX (POSIX) THREAD MANAGEMENT MAIN() thread ptread_create() I/O block I/O block pthread_join() pthread_exit() thread-1 terminates 5

Classical Problems Producer-Consumer (Bounded-Buffer) Readers-Writers Dining Philosophers Resource Allocation Mutual Exclusion Critical Sections 6

Module 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation Maximum CPU utilization obtained with multiprogramming CPU–I/O Burst Cycle – Process execution consists of a cycle of CPU execution and I/O wait. CPU burst distribution 7

Histogram of CPU-burst Times 8

CPU Scheduler Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them. CPU scheduling decisions may take place when a process: 1. Switches from running to waiting state. 2. Switches from running to ready state. 3. Switches from waiting to ready. 4. Terminates. Scheduling under 1 and 4 is nonpreemptive. All other scheduling is preemptive. 9

Find the order of processing and the run times for P1 (3 ticks), P2 (5 ticks), P3 (4 ticks), and P4 (1 tick) using (delta = 2 ticks, *where applicable) First-Come, First-Served (FCFS) Scheduling Shortest-Job-First (SJR) Scheduling Preemptive* Non-preemptive Round Robin* ========================================= Find the exponential average T of the last 5 burst lengths (67, 89, 13, 56, 45) using a factor a =0.8 (67 is most recent) T = a*67 + a^2*89 + a^3*13 + a^4 * 56 + a^5 * 45 = a * ( 67 + a*( 89 + a*( 13 + a*(56 + a*(45 + ...))))) Find the next value if t=76 using one * and one + operation. T = a * ( 76 + <old value>) 10

Thread Scheduling Local Scheduling – How the threads library decides which thread to put onto an available LWP. Global Scheduling – How the kernel decides which kernel thread to run next. JAVA JVM Uses a Preemptive, Priority-Based Scheduling Algorithm FIFO Queue is Used if There Are Multiple Threads With the Same Priority. JVM Schedules a Thread to Run When: The Currently Running Thread Exits the Runnable State. A Higher Priority Thread Enters the Runnable State JVM Does Not Specify Whether Threads are Time-Sliced or Not. 11

Deadlock Characterization Methods for Handling Deadlocks Module 8: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Combined Approach to Deadlock Handling 12

Deadlock can arise if four conditions hold simultaneously. Mutual exclusion: only one process at a time can use a resource. Hold and wait: a process holding at least one resource is waiting to acquire additional resources held by other processes. No preemption: a resource can be released only voluntarily by the process holding it, after that process has completed its task. Circular wait: there exists a set {P0,P1, ...,Pn} of waiting processes such that P0 is waiting for a resource that is held by P1, P1 is waiting for a resource that is held by P2, ... 13

Resource Allocation Graph 14

Example of a Graph With Cycle 15

Methods for Handling Deadlocks Ensure that the system will never enter a deadlock state. Allow the system to enter a deadlock state and then recover. Ignore the problem and pretend that deadlocks never occur in the system; used by most operating systems, including UNIX. 16

Requires that the system has some additional a priori information Deadlock Avoidance Requires that the system has some additional a priori information available. Simplest and most useful model requires that each process declare the maximum number of resources of each type that it may need. The deadlock-avoidance algorithm dynamically examines the resource-allocation state to ensure that there can never be a circular-wait condition. Resource-allocation state is defined by the number of available and allocated resources, and the maximum demands of the processes. 17

Example of Banker’s Algorithm Which Order can P’s Run? (P1, P3, P4, P2, P0) What resources are available after P3 runs? ( 7 4 3) 18

Deadlock Detection Security Must be considered in: Allow system to enter deadlock state Detection algorithm Recovery scheme Security Must be considered in: Computer Hardware design Operating System Design Application Software Design All of the Above 19