Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 12: Real-Time Scheduling

Similar presentations


Presentation on theme: "Lecture 12: Real-Time Scheduling"— Presentation transcript:

1 Lecture 12: Real-Time Scheduling
Nov. 22, 2016 Kyu Ho Park 1

2 Issues Timing requirements of real-time systems
Hard and Soft real-time systems Characteristics of real-time systems Scheduling algorithms for hard real-time systems Linux Scheduler( CFS )

3 Overview of Real-Time Systems
A real-time system requires that results be produced within a specified deadline period. An embedded system is a computing device that is part of a larger system (I.e. automobile, airliner.) A safety-critical system is a real-time system with catastrophic results in case of failure. A hard real-time system guarantees that real-time tasks be completed within their required deadlines. A soft real-time system provides priority of real-time tasks over non real-time tasks.

4 Features of Real-Time Kernels
Most real-time systems do not provide the features found in a standard desktop system. Reasons include Real-time systems are typically single-purpose. Real-time systems often do not require interfacing with a user. Features found in a desktop PC require more substantial hardware that what is typically available in a real-time system.

5 Virtual Memory in Real-Time Systems
Address translation may occur via: (1) Real-addressing mode where programs generate actual addresses. (2) Relocation register mode. (3) Implementing full virtual memory.

6 Address Translation

7 Implementing Real-Time Operating Systems
In general, real-time operating systems must provide: (1) Preemptive, priority-based scheduling (2) Preemptive kernels (3) Latency must be minimized

8 Minimizing Latency Event latency is the amount of time from when an event occurs to when it is serviced.

9 Interrupt Latency Interrupt latency is the period of time from when an interrupt arrives at the CPU to when it is serviced.

10 Classification of RT Schedulers

11 Real-Time CPU Scheduling
Periodic processes require the CPU at specified intervals (periods) p is the duration of the period d is the deadline by when the process must be serviced t is the processing time

12 Scheduling of tasks Scheduling of tasks when P2 has a higher priority than P1

13 Rate Montonic Scheduling
A priority is assigned based on the inverse of its period Shorter periods = higher priority; Longer periods = lower priority P1 is assigned a higher priority than P2.

14 Scheduling of tasks Missed Deadlines with Rate Monotonic Scheduling

15 Earliest Deadline First Scheduling
Priorities are assigned according to deadlines: The earlier the deadline, the higher the priority; the later the deadline, the lower the priority.

16 EDF EDF scheduling EDF scheduling is theoretically optimal. Example:
It does not require periodic processes. It only requires the deadlines of processes. EDF scheduling is theoretically optimal. Example: arrival duration deadline P1 10 33 P2 4 3 28 P3 5 29

17 Delayed Locking Technique[JPLee&KPARK,2008]
NP RT P preemptible section OS Latency NP non-preemptible section (critical section) urgent interrupt RT real-time process section P RT NP urgent interrupt “Entering a critical section is allowed only if the operation does not disturb the future execution of the real-time application” OS Latency is significantly reduced at the expense of delaying execution of NP section

18 Locking Decision (a) Locking is prohibited (delayed) enter ith section P RT NP tlock,i > tintr,j ? Y N tintr,j tlock,i decision point urgent timer interrupt Locking is prohibited Locking is allowed (b) Locking is allowed enter wait queue P NP P RT tlock,i tintr,j tintr,j : time remaining until the next j-th urgent interrupt tlock,i : time taken to execute an i-th non-preemptible section (lock hold time) decision point urgent timer interrupt

19 OS Latency w/o delayed locking w/ delayed locking minimum 24 us 22 us
maximum 847 us 192 us average us 63 us Computer Engineering Research Laboratory, EECS, KAIST

20 Media Delivery Multimedia data is stored in the file system like other ordinary data. However, multimedia data must be accessed with specific timing requirements. For example, video must be displayed at frames per second. Multimedia video data must be delivered at a rate which guarantees frames/second. Continuous-media data is data with specific rate requirements.

21 Streaming Streaming is delivering a multimedia file from a server to a client - typically the deliver occurs over a network connection. There are two different types of streaming: 1. Progressive download - the client begins playback of the multimedia file as it is delivered. The file is ultimately stored on the client computer. 2. Real-time streaming - the multimedia file is delivered to - but not stored on - the client’s computer.

22 Real-time Streaming There are two types of real-time streaming:
(1) Live streaming - used to deliver a live event while it is occurring. (2) On-demand streaming - used to deliver media streams such as movies, archived lectures, etc. The events are not delivered in real-time.

23 Linux Scheduler History
Linux 1.0 Simple linked list of Runnable Processes. Linux 2.0 SMP support Linux 2.5 O(1) Scheduler : Priority sorted array of lists Linux CFS :Completely Fair Scheduler O(1) Scheduler RT Priority 99 .. RT Priority 1 Nice -20 Nice +19

24 CFS Scheduler Separate Scheduler Classes rt_sched_class
O(1) priority array fair_sched_class Red and Black Tree(O(log(N)) idle_sched_class Handles idle tasks

25 CFS Scheduler Decision
Sstart with rt_sched_class runnable task available pick next sched_class Spick next task of sched_class

26 CFS It maintains a virtual run time(VRT) for each process:
The VRT represents how long each process has run on the CPU. The smaller the VRT value, the higher priority. All ready processes are maintained in a red-black tree ordered by increasing virtual run times. O(logN) insertion time complexity and O(1) look up for next process to run.

27 CFS

28 Red-Black Tree

29 Homework #4 Task: Make your program to construct the red-black tree based on the virtual run time of each process. Assume that int pid; int vrt[pid]={27,19,34,65,37,7,49,2,98}; Remove the leftmost node and restructure the red-black tree until all vrt[] nodes are removed from the tree. Submission Due Date : Dec.2, PM 23:59 Delay Penalty 10%/day Kim Woo Joong [EE516 Home4] student_number.zip

30 Project 5 Related: Project 5 will be issued on Nov. 29,2016.
The number of Beagle board black(BBB) is limited so that a BBB kit will be allocated to each team which consists of 2 students. Please decide your team mate until Nov. 29 and send the names to Mr. Kim, Woo Joong,


Download ppt "Lecture 12: Real-Time Scheduling"

Similar presentations


Ads by Google