RTOS task scheduling models

Slides:



Advertisements
Similar presentations
1 EE5900 Advanced Embedded System For Smart Infrastructure RMS and EDF Scheduling.
Advertisements

Scheduling Criteria CPU utilization – keep the CPU as busy as possible (from 0% to 100%) Throughput – # of processes that complete their execution per.
CS 149: Operating Systems February 3 Class Meeting
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 17 Scheduling III.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 16 Scheduling II.
Operating Systems Chapter 6
Chapter 5 CPU Scheduling. CPU Scheduling Topics: Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Project 2 – solution code
CS 3013 & CS 502 Summer 2006 Scheduling1 The art and science of allocating the CPU and other resources to processes.
Chapter 5: CPU Scheduling
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
OPERATING SYSTEMS CPU SCHEDULING.  Introduction to CPU scheduling Introduction to CPU scheduling  Dispatcher Dispatcher  Terms used in CPU scheduling.
Chapter 6 CPU SCHEDULING.
More Scheduling cs550 Operating Systems David Monismith.
MM Process Management Karrie Karahalios Spring 2007 (based off slides created by Brian Bailey)
Chapter 6 Scheduling. Basic concepts Goal is maximum utilization –what does this mean? –cpu pegged at 100% ?? Most programs are I/O bound Thus some other.
Real-Time Scheduling CS4730 Fall 2010 Dr. José M. Garrido Department of Computer Science and Information Systems Kennesaw State University.
Scheduling policies for real- time embedded systems.
Real-Time Scheduling CS4730 Fall 2010 Dr. José M. Garrido Department of Computer Science and Information Systems Kennesaw State University.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
1 Real-Time Scheduling. 2Today Operating System task scheduling –Traditional (non-real-time) scheduling –Real-time scheduling.
Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.
CS333 Intro to Operating Systems Jonathan Walpole.
Undergraduate course on Real-time Systems Linköping University TDDD07 Real-time Systems Lecture 2: Scheduling II Simin Nadjm-Tehrani Real-time Systems.
CPU Scheduling Operating Systems CS 550. Last Time Deadlock Detection and Recovery Methods to handle deadlock – Ignore it! – Detect and Recover – Avoidance.
Chapter 4 CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
Basic Concepts Maximum CPU utilization obtained with multiprogramming
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
CPU Scheduling Algorithms CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
Lecture 6: Real-Time Scheduling
CPU SCHEDULING.
EEE Embedded Systems Design Process in Operating Systems 서강대학교 전자공학과
Chapter 5a: CPU Scheduling
Networks and Operating Systems: Exercise Session 2
Scheduling (Priority Based)
CPU Scheduling.
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Process Scheduling B.Ramamurthy 11/18/2018.
CPU Scheduling Basic Concepts Scheduling Criteria
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Operating System Concepts
Real Time Scheduling Mrs. K.M. Sanghavi.
3: CPU Scheduling Basic Concepts Scheduling Criteria
Chapter5: CPU Scheduling
TDC 311 Process Scheduling.
Chapter 6: CPU Scheduling
CPU SCHEDULING.
Outline Scheduling algorithms Multi-processor scheduling
Chapter 5: CPU Scheduling
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 4/11/2019.
Process Scheduling B.Ramamurthy 4/7/2019.
Scheduling.
Operating System , Fall 2000 EA101 W 9:00-10:00 F 9:00-11:00
Uniprocessor Process Management & Process Scheduling
Shortest-Job-First (SJR) Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
CPU SCHEDULING CPU SCHEDULING.
Scheduling 21 May 2019.
Chapter 6: CPU Scheduling
Uniprocessor Scheduling
Chapter 6: CPU Scheduling
Uniprocessor Process Management & Process Scheduling
CPU Scheduling: Basic Concepts
Module 5: CPU Scheduling
Presentation transcript:

RTOS task scheduling models

Scheduling Definition: It is the method by which threads, processes or data flows are given access to system resources (e.g. processor time, communications bandwidth). By use of Proper algorithm of scheduling, we can perform multiple task in a given time. The scheduler is concerned mainly with: Throughput - The total number of processes that complete their execution per time unit. Response time - amount of time it takes from when a request was submitted until the first response is produced. Waiting Time - Equal CPU time to each process (or more generally appropriate times according to each process' priority). It is the time for which the process remains in the ready queue.

Preemptive vs. Non-Preemptive A scheduling algorithm is: Preemptive: if the active process or task or thread can be temporarily suspended to execute a more important process or task or thread . Non-Preemptive: if the active process or task or thread cannot be suspended, i.e., always runs to completion.

RTOS task scheduling models Cooperative Scheduling of ready tasks in a queue. Cyclic and round robin (time slicing) Scheduling. Preemptive Scheduling. Rate-Monotonic Scheduling (RMS). Scheduling using “Earliest deadline first” (EDF).

Cooperative Scheduling of ready tasks in a queue. Dis-advantages:  Longer execution time of a low priority task makes a higher priority task wait until it finishes.

Cyclic and round robin (time slicing) Scheduling. Cyclic Scheduling

Round Robin (time slicing) Scheduling Round robin means that each ready task runs turn by turn only in a cyclic queue for a limited time slice Where 𝑻 𝒔𝒍𝒊𝒄𝒆 =𝑳𝒊𝒎𝒊𝒕𝒆𝒅 𝒕𝒊𝒎𝒆 𝒔𝒍𝒊𝒄𝒆 𝑻 𝒄𝒚𝒄𝒍𝒆 =𝑻𝒊𝒎𝒆 𝒄𝒚𝒄𝒍𝒆 𝑵=𝑵𝒖𝒎𝒃𝒆𝒓 𝒐𝒇 𝒕𝒂𝒔𝒌𝒔 Round robin is a hybrid model of clock-driven model (for example cyclic model) as well as event driven (for example, pre-emptive) A real time system responds to the event within a bound time limit and within an explicit time. 𝑻 𝒔𝒍𝒊𝒄𝒆 = 𝑻 𝒄𝒚𝒄𝒍𝒆 𝑵

Example So we 𝑻 𝒄𝒚𝒄𝒍𝒆 =20msec & 𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑇𝑎𝑠𝑘𝑠=𝟓 Supposed after every 20ms, there is a stream of coded messages reaching at port A of an embedded system, it is then decrypted and retransmitted to the port after encoding each decrypted message. The multiple processes consist of five tasks: C1, C2, C3, C4 and C5 as follow: Task 1 C1: Check for a message at port A every 20ms Task 2 C2: Read port A and put the message in a message queue. Task 3 C3: Decrypt the message from the message queue. Task 4 C4: Encode the message from the queue. Task 5 C5: Transmit the encoded message from the queue to port B So we 𝑻 𝒄𝒚𝒄𝒍𝒆 =20msec & 𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑇𝑎𝑠𝑘𝑠=𝟓 𝑻 𝒔𝒍𝒊𝒄𝒆 = 𝑻 𝒄𝒚𝒄𝒍𝒆 𝑵 = 𝟐𝟎𝒎𝒔𝒆𝒄 𝟓 =𝟒𝒎𝒔𝒆𝒄

So we have five tasks , C1 to C5 that are to be scheduled So we have five tasks , C1 to C5 that are to be scheduled. Now Five time schedules between 0 and 4 ms, 4 ms and 8 ms , 8 and 12 ms, 12 and 16ms & 16 and 20ms respectively. ( 𝐓 𝐬𝐥𝐢𝐜𝐞 =𝟒𝐦𝐬) Tasks programs contexts at the five instances in the Time Scheduling Scheduler for C1 to C5

Priority-based Scheduling Typical RTOS based on fixed-priority preemptive scheduler Assign each process a priority At any time, scheduler runs highest priority process ready to run Process runs to completion unless preempted

Typical RTOS Task Model Each task a triplet: (execution time, period, deadline) Usually, deadline = period Can be initiated any time during the period Execution time Period Deadline Time Initiation

Priority-based Preemptive Scheduling Always run the highest-priority runnable process Priorities Initiation Deadline 1 P1 P1 P1 P1 2 P2 P2 P2 3 P3 P3 P3 t t Scheduling After completing other high priority process, switch to next interrupted low priority process

RMS Scheduling

Rate-Monotonic Scheduling Common way to assign priorities Result from Liu & Lay-land, 1973 (JACM) Processes with shorter period given higher priority a set of n independent tasks scheduled by the rate monotonic algorithm. will always meet its deadlines, for all task phasings, if Where 𝑪 𝒊 = deterministic computation time of each task Ti = period of particular task 𝑼 𝒏 = Scheduling bound, the maximum fraction of processor utilization allowable for n tasks: 𝑪 𝟏 𝑻 𝟏 + 𝑪 𝟐 𝑻 𝟐 + …………… 𝑪 𝒏 𝑻 𝒏 ≤𝑼 𝒏 𝑼 𝒏 = 𝟏 or 100%

The utilization bound (UB) test allows schedulability analysis by comparing the calculated utilization for a set of tasks and comparing that total to the theoretical utilization for that number of tasks: If this equality is satisfied, all of the tasks will always meet their deadlines. If the total utilization calculates to greater than 100%, the system will have scheduling problems. 𝑪 𝟏 𝑻 𝟏 + 𝑪 𝟐 𝑻 𝟐 + …………… 𝑪 𝒏 𝑻 𝒏 ≤𝑼 𝒏 =𝟏

Utilization Bound Test Assumes rate monotonic priority assignment Task with smaller period is assigned higher priority Guaranteed to be schedulable if test succeeds. 𝐔 𝐧 ≡ 𝐢=𝟏 𝐧 𝐂 𝐢 𝐓 𝐢 ≤𝟏

Utilization Bound Test Example No. Tasks Utilization Bound (in % ) 1 100% 2 82.8% 3 78.0% 4 75.7% 5 74.3% 10 71.8%

Computation/ Execution Time (Ci) Example: Checking for Schedulability using of RMS. And Time period P1 process = 4 secs. Means P1 repeat after every 4 secs Solution: Golden Rule : Shortest test period = Highest Priority Check for Schedulability Processes Computation/ Execution Time (Ci) Time Period (Ti) P1 1 4 P2 2 6 P3 3 12

Deciding Priority Level Processes Computation/ Execution Time Time Period Priority P1 1 4 High(1) P2 2 6 Medium(2) P3 3 12 Low(3) Checking for Schedulability 𝐔 𝐧 ≡ 𝐢=𝟏 𝐧 𝐂 𝐢 𝐓 𝐢 ≤𝟏 𝐔 𝐧 = 𝐢=𝟏 𝟑 𝐂 𝐢 𝐓 𝐢 = 𝐂 𝟏 𝐓 𝟏 + 𝐂 𝟐 𝐓 𝟐 + 𝐂 𝟑 𝐓 𝟑 = 𝟏 𝟒 + 𝟐 𝟔 + 𝟑 𝟏𝟐 =𝟎.𝟖𝟑≤𝟏 Here U(n) < 1, so we can schedule the process by using RMS scheduling algorithm

Computation/ Execution Time Scheduling Timing Diagram Total time = take LCM of Period of Process = 12 Processes Computation/ Execution Time Time Period P1 1 4 P2 2 6 P3 3 12 Processes 1st period continue 1 2 3 4 5 6 7 8 9 10 11 12 P3 P3 P3 P3 Next period P2 P2 P2 Next period Next period P1 P1 P1 P1 Time----->

Computation/ Execution Time (Ci) Example: Checking for Schedulability using of RMS. Solution Here clearly the CPU Utilization is more than 1 (i.e. 1.25). So these is not Scheduled. Processes Computation/ Execution Time (Ci) Time Period (Ti) P1 2 4 P2 3 6 P3 12

Earliest deadline first Scheduling RMS assumes fixed priorities First check for Schedulability by using Utilization formulae Earliest deadline first: Processes with soonest deadline given highest priority

Computation/ Execution Time (Ci) Example: Checking for Schedulability using of EDF. Solution Step 1: Check for Schedulability U = 1/3 + 1/4 + 2/5 = 0.98 which is less than 1 So we can schedule the given task Processes Computation/ Execution Time (Ci) Time Period (Ti) P1 1 3 P2 4 P3 2 5

Computation/ Execution Time (Ci) Processes Computation/ Execution Time (Ci) Time Period (Ti) P1 1 3 P2 4 P3 2 5 Solutions Period (UPTO 60) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 d(1) d(2) d(3) P1 P2 P3 Scheduled Process according to their Execution time

OS SECURITY ISSUES SELF STUDY!!!!