Laboratory for Perceptual Robotics – Department of Computer Science Embedded Systems Introduction to Real-Time Systems.

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.
Introduction to Embedded Systems Resource Management - III Lecture 19.
Priority INHERITANCE PROTOCOLS
CPE555A: Real-Time Embedded Systems
Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
CSE 522 Real-Time Scheduling (4)
Multiprocessor and Real-Time Scheduling Chapter 10.
Ceng Operating Systems Chapter 2.1 : Processes Process concept Process scheduling Interprocess communication Deadlocks Threads.
Chapter 11 Operating Systems
Real-Time Kernels and Operating Systems. Operating System: Software that coordinates multiple tasks in processor, including peripheral interfacing Types.
By Group: Ghassan Abdo Rayyashi Anas to’meh Supervised by Dr. Lo’ai Tawalbeh.
CprE 458/558: Real-Time Systems
Spring 2002Real-Time Systems (Shin) Rate Monotonic Analysis Assumptions – A1. No nonpreemptible parts in a task, and negligible preemption cost –
Misconceptions About Real-time Computing : A Serious Problem for Next-generation Systems J. A. Stankovic, Misconceptions about Real-Time Computing: A Serious.
Real-Time Operating System Chapter – 8 Embedded System: An integrated approach.
Chapter 19: Real-Time Systems Silberschatz, Galvin and Gagne ©2005 AE4B33OSS Chapter 19: Real-Time Systems System Characteristics Features of Real-Time.
Introduction to Embedded Systems
OPERATING SYSTEMS CPU SCHEDULING.  Introduction to CPU scheduling Introduction to CPU scheduling  Dispatcher Dispatcher  Terms used in CPU scheduling.
More Scheduling cs550 Operating Systems David Monismith.
MM Process Management Karrie Karahalios Spring 2007 (based off slides created by Brian Bailey)
Introduction to Embedded Systems Rabie A. Ramadan 6.
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.
Multiprocessor and Real-Time Scheduling Chapter 10.
Chapter 101 Multiprocessor and Real- Time Scheduling Chapter 10.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Reference: Ian Sommerville, Chap 15  Systems which monitor and control their environment.  Sometimes associated with hardware devices ◦ Sensors: Collect.
1 Chapter 2.1 : Processes Process concept Process concept Process scheduling Process scheduling Interprocess communication Interprocess communication Threads.
Real-Time Scheduling CS4730 Fall 2010 Dr. José M. Garrido Department of Computer Science and Information Systems Kennesaw State University.
Real-Time Scheduling CS 3204 – Operating Systems Lecture 20 3/3/2006 Shahrooz Feizabadi.
Prepare by : Ihab shahtout.  Overview  To give an overview of fixed priority schedule  Scheduling and Fixed Priority Scheduling.
2.5 Scheduling Given a multiprogramming system. Given a multiprogramming system. Many times when more than 1 process is waiting for the CPU (in the ready.
CompSci 143A1 5. Process and thread scheduling 5.1 Organization of Schedulers – Embedded and Autonomous Schedulers – Priority Scheduling 5.2 Scheduling.
Undergraduate course on Real-time Systems Linköping 1 of 45 Autumn 2009 TDDC47: Real-time and Concurrent Programming Lecture 5: Real-time Scheduling (I)
Java Thread and Memory Model
Special Class on Real-Time Systems
Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.
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.
2.5 Scheduling. Given a multiprogramming system, there are many times when more than 1 process is waiting for the CPU (in the ready queue). Given a multiprogramming.
Introduction to Embedded Systems Rabie A. Ramadan 5.
CSCI1600: Embedded and Real Time Software Lecture 23: Real Time Scheduling I Steven Reiss, Fall 2015.
19.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 19: Real-Time Systems.
Chapter 19: Real-Time Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 19: Real-Time Systems System Characteristics.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
For a good summary, visit:
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.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Unit - I Real Time Operating System. Content : Operating System Concepts Real-Time Tasks Real-Time Systems Types of Real-Time Tasks Real-Time Operating.
Chapter 3 RTOS Concepts And Definitions Department of Computer Science Hsu Hao Chen Professor Hsung-Pin Chang.
Lecture 6: Real-Time Scheduling
Distributed Process Scheduling- Real Time Scheduling Csc8320(Fall 2013)
Real-Time Operating Systems RTOS For Embedded systems.
CPU Scheduling Scheduling processes (or kernel-level threads) onto the cpu is one of the most important OS functions. The cpu is an expensive resource.
Embedded System Scheduling
REAL-TIME OPERATING SYSTEMS
Chapter 19: Real-Time Systems
EEE Embedded Systems Design Process in Operating Systems 서강대학교 전자공학과
EEE 6494 Embedded Systems Design
Chapter 2 Scheduling.
Real-time Software Design
Chapter 6: CPU Scheduling
Embedded Systems Introduction to Real-Time Systems
Multiprocessor and Real-Time Scheduling
Chapter 19: Real-Time Systems
Processes and operating systems
Operating System , Fall 2000 EA101 W 9:00-10:00 F 9:00-11:00
Presentation transcript:

Laboratory for Perceptual Robotics – Department of Computer Science Embedded Systems Introduction to Real-Time Systems

2 Laboratory for Perceptual Robotics – Department of Computer Science Real-Time Systems Definition: Real-time systems are those in which the correctness of the system depends not only on the logical results of the computation but also on the time at which the results are produced. Hard real-time systems: time critical - it is imperative that the system respond within a specified time period. Soft real-time systems: the system will function correctly, although at a lower overall utility if deadline are occasionally missed.

3 Laboratory for Perceptual Robotics – Department of Computer Science Real-Time Systems timing constraints: periodic --- once per period T, precisely T units apart aperiodic --- start time, finish time, or both

4 Laboratory for Perceptual Robotics – Department of Computer Science Real-Time Programming Concurrent, task-based approach multi-tasking RTOS (VxWorks) scheduling theory industrial state-of-the-art Synchronous approach reactive kernel represented as an automata formal properties special-purpose programming languages - Esterel Discrete-Event Dynamic Systems

5 Laboratory for Perceptual Robotics – Department of Computer Science Logical Concurrency A concurrent program can be viewed as a collection of autonomous sequential processes executing (logically) in parallel. Each process has a single thread of control. multiplex on a single processor; multiplex on a multi-processor with shared memory; or multiplex on several processors without share memory (distributed systems)

6 Laboratory for Perceptual Robotics – Department of Computer Science Processes A process (task) can be in one of the following process states: Ready: Processes that are ready to execute. Stored in a ReadyQueue (a linked list) Running: The currently executing process (the first process in the ReadyQueue) Blocked: Processes waiting for an event, e.g., an external event (Temp < T min ) The switch from one running process to another is called a context switch The process state consists of: program counter, process status information (priority, enabled interrupts), and the contents of the programmable registers. Process administration is handled by the RT kernel

7 Laboratory for Perceptual Robotics – Department of Computer Science Interactive C - Multitasking process - a function with a unique pid, local program stack (256 bytes default) for return addresses, local variables, arguments, etc, and a processor allocation in milliseconds--- processes communicate via global variables process table - a set of processes that are logically concurrent

8 Laboratory for Perceptual Robotics – Department of Computer Science HandyBoard Process Control int start_process(function-call(…), [TICKS],[STACK-SIZE]) returns the process id int kill_process(int pid) returns 0 if successfully killed, 1 otherwise (process not found) kill_all() stops all running processes ps processor status void hog_processor() allocates an additional 256 msec to the function currently running-called repeatedly, system will wedge requiring reset void defer() Forces a context shift

9 Laboratory for Perceptual Robotics – Department of Computer Science Example: Multitasking void check_sensor(int n) { while(1) printf(“sensor %d is %d\n”, n, digital(n)); } void main() { int pid; pid = start_process(check_sensor(2)); sleep(1.0); kill_process(pid); } starts check_sensor() and then kills it 1 second later Q: how often does check_sensor() actually run?

10 Laboratory for Perceptual Robotics – Department of Computer Science Example: Multitasking void check_sensor(int n) { while(1) printf(“sensor %d is %d\n”, n, digital(n)); } void main() { int pid; pid = start_process(check_sensor(2)); sleep(1.0); kill_process(pid); } starts check_sensor() and then kills it 1 second later Q: how often does check_sensor() actually run? A: assuming nothing else is in the process table, this process runs ~continuously in about 200 consecutive 5 msec chunks.

11 Laboratory for Perceptual Robotics – Department of Computer Science Scheduling...to ensure that the run-time scheduler dispatches the runnable processes in an order that will result in all deadlines being met… orders the ReadyQueue allocates priorities BOTH STATIC AND DYNAMIC PRIORITY ALLOCATIONS ARE POSSIBLE

12 Laboratory for Perceptual Robotics – Department of Computer Science Scheduling Operations Research job shop scheduling and shop-flow problems schedule physical devices and processes - machines, workcells, maintenance, orders, batches, projects mostly (not exclusively) static schedules Computer Science schedule tasks in a uni- or multiprocessor environment mostly (not exclusively) dynamic schedules

13 Laboratory for Perceptual Robotics – Department of Computer Science Scheduling-Problem Formulation Events - anything that requires a response in the system---computation, work, communication periodic, aperiodic, sporadic, and stochastic events interrupts Time - execution times for event handling---how much time will it take to handle an event? How much CPU time does a periodic process require? How much time will it take to change a bearing on the milling machine? Deadline upper bound on the time required to service an event Scheduling reflects decisions about which event to process at a given time

14 Laboratory for Perceptual Robotics – Department of Computer Science Priority-Based Preemptive Scheduling How should processes be scheduled in order to maximize the utilization of the system while guaranteeing deadlines? priority reflects the severity of the time demands high low The ReadyQueue is sorted by priority: A blocked process that becomes ready and has higher priority than the currently running process causes a context shift. This task preempts the running task.

15 Laboratory for Perceptual Robotics – Department of Computer Science Priorities and Scheduling Priority Inversion Consider tasks T 1, T 2, and T 3 with corresponding priorities P 1 >P 2 >P 3 (that is, task T 1 has the highest priority). If task T 1 depends on task T 3, it may be suspended in order to wait for a result from T 3. However, a priority-based preemptive scheduler will choose to run task T 2, thus further blocking task T 1 indirectly by way of task T 3 even though P 1 >P 2.

16 Laboratory for Perceptual Robotics – Department of Computer Science Priorities and Scheduling Priority Inheritance The priority of a process is the max of its priority and the priorities of all other processes that depend on it. therefore: task T 3 inherits priority P 1 while T 1 is waiting for a T 3 event T 3 will run in preference to T 2. For example, a synchronous communication protocol (rendezvous) requires the sender to wait until contact is established and the receiver is verified before the message is sent. In ADA, the priority of the rendezvous itself is the highest priority of the two participating processes.

17 Laboratory for Perceptual Robotics – Department of Computer Science Schedulability Given a single processor, a set of n-independent, periodic processes with only execution time deadlines (no start/stop constraints) are schedulable if the overall processor utilization is less than n(2 1/n -1) For large n this function approaches a utilization of This is a very conservative estimate, based on worst-case relationships between the periods of the processes. Liu and Layland (1973)

18 Laboratory for Perceptual Robotics – Department of Computer Science Schedulability Given a single processor, a set of n-independent, periodic processes with only execution time deadlines (no start/stop constraints) are schedulable if the overall processor utilization is less than n(2 1/n -1) For large n this function approaches a utilization of This is a very conservative estimate, based on worst-case relationships between the periods of the processes. Liu and Layland (1973) non-repeating prime # periods in n processes

19 Laboratory for Perceptual Robotics – Department of Computer Science Consider two tasks, T 1 and T 2, with P 1 >P 2 (T 1 is more “important”). T 1 has a period of 50 units of time and requires 10 units of time to run. Task T 2 has a period of 10 units of time and requires 2 units of time to run. Under a priority-based preemptive schedule, T 1 will execute first and when it completes, T 2 will have already missed its first deadline! The problem is related to the use of “preference” priorities. Schedulability

20 Laboratory for Perceptual Robotics – Department of Computer Science Consider two tasks, T 1 and T 2, with P 1 >P 2 (T 1 is more “important”). T 1 has a period of 50 units of time and requires 10 units of time to run. Task T 2 has a period of 10 units of time and requires 2 units of time to run. Under a priority-based preemptive schedule, T 1 will execute first and when it completes, T 2 will have already missed its first deadline! The problem is related to the use of “preference” priorities. Schedulability schedulability n(2 1/n -1) 2(2 1/n -1) = 0.818

21 Laboratory for Perceptual Robotics – Department of Computer Science Consider two tasks, T 1 and T 2, with P 1 >P 2 (T 1 is more “important”). T 1 has a period of 50 units of time and requires 10 units of time to run. Task T 2 has a period of 10 units of time and requires 2 units of time to run. Under a priority-based preemptive schedule, T 1 will execute first and when it completes, T 2 will have already missed its first deadline! The problem is related to the use of “preference” priorities. Schedulability schedulability n(2 1/n -1) 2(2 1/n -1) = utilization P1 P (5x2) 50 =40%

22 Laboratory for Perceptual Robotics – Department of Computer Science Consider two tasks, T 1 and T 2, with P 1 >P 2 (T 1 is more “important”). T 1 has a period of 50 units of time and requires 10 units of time to run. Task T 2 has a period of 10 units of time and requires 2 units of time to run. Schedulability schedulability n(2 1/n -1) 2(2 1/n -1) = utilization P1 P (5x2) 50 =40% Threshold utilization for worst case schedulability > 0.40 actual utilization …so we know it’s schedulable…

23 Laboratory for Perceptual Robotics – Department of Computer Science Rate Monotonic Scheduling Assign fixed priorities inversely proportional to the period for the tasks P i ~  , so that the shorter the period, the higher the priority. optimal static schedule for independent periodic processes: if a process can be scheduled by any static scheduling algorithm, then it can also be scheduled by the rate monotonic algorithm.

24 Laboratory for Perceptual Robotics – Department of Computer Science Extensions to Rate Monotonic Scheduling Soft RT Systems - if all deadlines cannot be met, the most “important” processes must be run first. If the ReadyQueue is schedulable, then the process with the shortest period should be first. “Specification Aliases” - transforming specifications for the most important tasks. If T 1 (  =50, and execution time=10) were respecified e.g., T 1 '(  =5, and execution time=1), then relative preference is consistent with its rate-based priority. …the details are non-trivial… Periodic Servers - incorporate aperiodic, interupts, and important soft-deadline tasks into the rate monotonic schedule. reserve time in the periodic server to handle worst-case arrival rates global schedule---even for tasks with random arrival rates! at the expense of utilization

25 Laboratory for Perceptual Robotics – Department of Computer Science Other Scheduling Algorithms Earliest Deadline - need to know about deadlines Least Slack Time - need deadlines and complete times when deadlines can be met, ED and LST are equivalent to Rate Monotonic

26 Laboratory for Perceptual Robotics – Department of Computer Science Other Scheduling Algorithms Earliest Deadline --- need to know about deadlines Least Slack Time --- needs deadlines and the amount of execution time needed to complete......scheduler allocates resources to the task with the least “free time” When all deadlines can be met, Earliest Deadline and Least Slack Time are equivalent to Rate Monotonic --- every periodic task load schedulable by one is schedulable by all. These alternatives are designed to do the best they can with instantaneous and aperiodic task loads.

27 Laboratory for Perceptual Robotics – Department of Computer Science Periodic Tasks Revisited A feedback control process is the canonical periodic task with a fixed period---the sampling rate. between sampling intervals, the system is ballistic

28 Laboratory for Perceptual Robotics – Department of Computer Science Periodic Tasks Revisited in practice, the control delay is not constant--- variations are due to: preemptions from higher priority tasks variation in the execution times (branching, data dependencies) communication delays in distributed controllers jitter can result from: preemptions from higher priority tasks improper useage of timing primitives in the RT kernel