Copyright © 2000, Daniel W. Lewis. All Rights Reserved. CHAPTER 8 SCHEDULING.

Slides:



Advertisements
Similar presentations
Washington WASHINGTON UNIVERSITY IN ST LOUIS Real-Time: Periodic Tasks Fred Kuhns Applied Research Laboratory Computer Science Washington University.
Advertisements

Real Time Scheduling.
Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.
Priority Inheritance and Priority Ceiling Protocols
Washington WASHINGTON UNIVERSITY IN ST LOUIS Resource and Resource Access Control Fred Kuhns Applied Research Laboratory Computer Science and Engineering.
Outline Introduction Assumptions and notations
Introduction to Embedded Systems Resource Management - III Lecture 19.
Priority Inversion BAE5030 Advanced Embedded Systems 9/13/04.
Priority INHERITANCE PROTOCOLS
1 EE5900 Advanced Embedded System For Smart Infrastructure RMS and EDF Scheduling.
CS 149: Operating Systems February 3 Class Meeting
Resource management and Synchronization Akos Ledeczi EECE 354, Fall 2010 Vanderbilt University.
0 Synchronization Problem Resource sharing –Requires mutual exclusion –Critical section A code section that should be executed mutually exclusively by.
CS5270 Lecture 31 Uppaal, and Scheduling, and Resource Access Protocols CS 5270 Lecture 3.
Resource Access Protocols
CprE 458/558: Real-Time Systems (G. Manimaran)1 CprE 458/558: Real-Time Systems Resource Access Control Protocols.
CSE 522 Real-Time Scheduling (3)
Mutual Exclusion.
CS 3013 & CS 502 Summer 2006 Scheduling1 The art and science of allocating the CPU and other resources to processes.
UCDavis, ecs150 Fall /23/2007ecs150, fall Operating System ecs150 Fall 2007 : Operating System #3: Priority Inversion (a paper on the class.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
UCDavis, ecs150 Spring /21/2006ecs150, spring Operating System ecs150 Spring 2006 : Operating System #3: Priority Inversion (paper) Dr. S.
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
Spring 2002Real-Time Systems (Shin) Rate Monotonic Analysis Assumptions – A1. No nonpreemptible parts in a task, and negligible preemption cost –
UCDavis, ecs251 Fall /23/2007ecs251, fall Operating System Models ecs251 Fall 2007 : Operating System Models #3: Priority Inversion Dr. S.
Introduction to Embedded Systems
Introduction to Embedded Systems Rabie A. Ramadan 6.
Chapter 101 Multiprocessor and Real- Time Scheduling Chapter 10.
Deadlocks Silberschatz Ch. 7 and Priority Inversion Problems.
Deadlock Detection and Recovery
RTOS task scheduling models
1 Review of Process Mechanisms. 2 Scheduling: Policy and Mechanism Scheduling policy answers the question: Which process/thread, among all those ready.
Cpr E 308 Spring 2005 Process Scheduling Basic Question: Which process goes next? Personal Computers –Few processes, interactive, low response time Batch.
- 1 -  P. Marwedel, Univ. Dortmund, Informatik 12, 2006 Universität Dortmund Periodic scheduling For periodic scheduling, the best that we can do is to.
1 Real-Time Scheduling. 2Today Operating System task scheduling –Traditional (non-real-time) scheduling –Real-time scheduling.
CSCI1600: Embedded and Real Time Software Lecture 24: Real Time Scheduling II Steven Reiss, Fall 2015.
Introduction to Embedded Systems Rabie A. Ramadan 5.
A presentation for Brian Evans’ Embedded Software Class By Nate Forman Liaison Technology Inc. 3/30/2000 For Real-Time Scheduling.
CHAPTER 7 CONCURRENT SOFTWARE Copyright © 2000, Daniel W. Lewis. All Rights Reserved.
1.  System Characteristics  Features of Real-Time Systems  Implementing Real-Time Operating Systems  Real-Time CPU Scheduling  An Example: VxWorks5.x.
Undergraduate course on Real-time Systems Linköping University TDDD07 Real-time Systems Lecture 2: Scheduling II Simin Nadjm-Tehrani Real-time Systems.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Process Scheduling. Scheduling Strategies Scheduling strategies can broadly fall into two categories  Co-operative scheduling is where the currently.
REAL-TIME OPERATING SYSTEMS
CPU SCHEDULING.
Scheduling and Resource Access Protocols: Basic Aspects
Networks and Operating Systems: Exercise Session 2
EEE 6494 Embedded Systems Design
Chapter 2 Scheduling.
Chapter 6: CPU Scheduling
Rate Monotonic Analysis For Real-Time Scheduling A presentation for
Chapter 6: CPU Scheduling
OverView of Scheduling
Chapter 2: The Linux System Part 3
TDC 311 Process Scheduling.
CSCI1600: Embedded and Real Time Software
Outline Scheduling algorithms Multi-processor scheduling
Lecture 2 Part 2 Process Synchronization
COT 4600 Operating Systems Fall 2009
Multiprocessor and Real-Time Scheduling
CSCI1600: Embedded and Real Time Software
Chapter 10 Multiprocessor and Real-Time Scheduling
CHAPTER 8 Resources and Resource Access Control
Shortest-Job-First (SJR) Scheduling
CPU SCHEDULING CPU SCHEDULING.
Real-Time Process Scheduling Concepts, Design and Implementations
Uniprocessor Scheduling
Real-Time Process Scheduling Concepts, Design and Implementations
CPU Scheduling CSE 2431: Introduction to Operating Systems
Presentation transcript:

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. CHAPTER 8 SCHEDULING

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Objective: Selecting Thread to Run Scheduler selects a thread to run Processor relinquished Context Switch

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Thread States: Initial View Ready Inactive Running Thread unknown to scheduler. Thread waiting for scheduler to give it a turn.

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Time-Sliced Scheduling Each thread runs for a fixed amount of time. Threads are run in a round-robin sequence. Appropriate for regular multi-programming environments. Poor response time performance. Need better strategy for real-time systems.

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Pending Threads Threads must often wait for an event to occur or some shared resource to become available. Simply moving the task back to the ready state isn't appropriate because it may run again later only to discover that it must continue to wait, thus adding unnecessary task switching overhead.

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Thread States: Revised View Running Pending Inactive Ready Thread waiting for an external event or shared resource. Thread waiting for scheduler to give it control.

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. State of Thread A Interrupt Routine Run-Time Kernel State of Thread B Context Switch Pending Running Ready Non-Preemptive Context Switch Running Yield Call Interrupted Post Ready

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Non-Preemptive Thread States Running Inactive Ready Pending Yielding Interrupted

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. State of Thread A Interrupt Routine Run-Time Kernel State of Thread B Pending Running Ready Preemptive Context Switch Interrupted Ready Interrupted Post Context Switch

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Preemptive Thread States Running Inactive Ready Pending Interrupted

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Priority-Based Scheduling Each thread is assigned a priority number. Static priorities never change. Dynamic priorities can vary during execution. –Required to avoid Priority Inversion Problem.

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Priority Inversion Resource Owned by High-Priority Thread State Run-Time Kernel Low-Priority Thread State Running Pending RunningReady Low-Priority ThreadHigh-Priority Thread Request resource Release Resource

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Priority Inversion Bounded Priority Inversion –Duration is no longer than that of the critical section where the lower-priority thread owns the resource. Unbounded Priority Inversion –Occurs when a third (medium-priority) thread preempts the low-priority thread during the inversion for an indefinite amount of time.

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Mars Pathfinder Suffered Unbounded Priority Inversion Low-priority meteorological thread Acquired the (shared) bus. Medium-priority, long-running, communications thread Woke up and preempted the meteorological thread. High-priority bus management thread Woke up and was blocked because it couldn't acquire the bus; when it couldn't meet its deadline it reinitialized the computer via a hardware reset.

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Limiting the Duration of an Unbounded Priority Inversion Objective: –To prevent low-priority thread from being preempted by medium-priority thread during the priority inversion. Strategies: –Priority Inheritance Protocol –Priority Ceiling Protocol Technique: –Manipulate thread priorities at run-time.

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Priority Inheritance Protocol When a high-priority thread attempts to lock a mutex already locked by a lower-priority thread, the Priority Inheritance Protocol (PIP) temporarily raises the priority of the low-priority thread to match that of the blocked thread until the low- priority thread unlocks the mutex. Advantage: It is transparent to the application. Disadvantage: Adds complexity to the kernel.

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Priority Ceiling Protocol Priority of the low-priority thread is raised immediately when it locks the mutex rather than waiting for a subsequent lock attempt by a higher- priority thread. Advantage: Easy to implement. Disadvantage: The priority ceiling value must be predetermined for use with the mutex; this value must be the highest among all the threads that attempt to lock the same mutex.

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Assigning Priorities Scheduling: Threads with higher priority are scheduled to run first. Objective: Assign priorities in such a way that all outputs are computed before their deadlines.

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Assignment Strategies Deadline-Driven Assignment –Assign highest priorities to threads with shortest deadlines. Rate Monotonic Assignment –Assign highest priorities to threads that run most frequently without regard to deadlines.

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Deadlock

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Deadlock Definition: Two or more threads are blocked waiting on each other's resources. Necessary Condition: Threads require exclusive access to two or more shared resources simultaneously.

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Entering Deadlock Thread T1: Mutex M1: Mutex M2: Thread T2: Pending on M2 Ready Running Locked by T1 Pending on M1RunningReady Locked by T2

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. Preventing Deadlock 1.Require all threads to acquire resources in the same order. Often locks resources longer than necessary. Occasionally there is no order that is convenient for all threads. 2.Require threads to release all resources and start over if any one resource can't be acquired.