Course Information TDDB47 Real Time Systems Lecture 1: Introduction & cyclic scheduling

advertisement
Course Information
TDDB47 Real Time Systems
•
Website: www.ida.liu.se/~TDDB47
– Check it regularly
– Main communication tool
• Feedback tool
•
Examiner
– Calin Curescu, calcu@ida.lu.se
Course assistant
– Mikael Asplund, mikas@ida.liu.se
Course secretary
– Anne Moe, annes@ida.liu.se
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
Real-Time Systems Laboratory
Department of Computer and Information Science
Linköping University, Sweden
•
•
The lecture notes are partly based on lecture notes by Simin Nadjm-Tehrani, Jörgen Hansson, Anders Törne.
They also loosely follow Burns’ and Welling book “Real-Time Systems and Programming Languages”. These
lecture notes should only be used for internal teaching purposes at Linköping University.
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
35 pages
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
Aim and Prerequisites
•
•
Aims
– To understand the methods and structuring mechanisms
involved in the design and implementation of real-time
systems.
Course Coverage
•
•
•
•
•
•
•
•
Prerequisites
– Process Programming and Operating Systems
(TDDB68/72)
– Some Java knowledge for the labs
• Introductory lesson
•
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
3 of 35
2 of 35
Introduction to Real-time and Embedded Systems
Scheduling
– Static, dynamic, distributed
Deadlocks and implications for scheduling algorithms
Design of real-time systems
Dependable Systems, design for fault tolerance
Distributed real-time systems
Real-time operating systems
Real-time applications
– Real-Time Database Systems
– Quality of Service in Communication Networks
Research Issues
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
Reading
•
•
4 of 35
Laboratory
Course Book
– A. Burns and A. Wellings: Real-Time Systems and their
Programming Languages, Addison-Wesley,
– NOT covered/followed chapter by chapter
•
Apply the scheduling theory you learned in the course in a
pseudo-realistic setting of the RoboCup game
•
Lab environment (still) under development
Additional material posted on the web
– Get copies from assistant on material that is not
available on the course Literature page
•
Please make sure that you
– Read the compendium
– Observe the instructions
– Keep the deadlines
•
Compendium is available for download
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
5 of 35
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
6 of 35
Lessons
•
Java tutorial
– For students with no/very limited Java experience
– Friday v. 43
– Slides will be put on the web before
•
Laboratory presentation
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
7 of 35
Computer systems
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
Definitions of an RT System
•
•
Oxford Computing Dictionary
– ”Any system in which the time at which output is
produced is significant. This is usually because the input
corresponds to some movement in the physical world,
and the output has to relate to that same movement. The
lag from input time to output time must be sufficiently
small for acceptable timeliness.”
• Timeliness: milliseconds, seconds, hours
Randell et. al 1995
– ”A real-time system is a system that is required to react
to stimuli from the environment (including the passage
of physical time) within time intervals dictated by the
environment.”
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
9 of 35
What is a real-time system?
•
Correctness depends not only on the logical result but also
the time it was delivered
•
Failure to respond is as bad as the wrong response
– Predictability
•
Usually a component in a larger engineering system
– Embedded computer system
•
Usually a critical system
– Safety-critical
– Dependable
– Fault-tolerant
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
What is an embedded system?
•
•
A computer system that
– is part of a larger system
– is tailor-made for a specific application
– is characterised by restricted programmability by the user
– has tight interaction with a physical environment
Real-time vs. embedded
– Usually an rt-system is embedded
– RT and not embedded?
– Embedded and not RT?
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
11 of 35
8 of 35
10 of 35
Application areas
•
•
•
Manufacturing and process control
Command and control and communication
Generalised embedded system
•
Examples
– Fly-by-wire, brake-by wire
– Atomic power plant control
– Garden sprinkle system
– Computer games
– Robot vision processing
– Communication equipment
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
12 of 35
Really good example
Predictability and Criticality
•
Hard RT
– Not meeting a deadline leads to system failure
– Critical systems
•
Soft RT
– Deadlines should be met, but still functions correctly if
they are occasionally missed.
• How often?
• By how much?
Firm RT
– OK for deadlines to be occasionally missed, but
– after the deadline the result is of no use
•
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
13 of 35
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
Cost function
Characteristics of a RTS
•
•
•
•
•
•
Hard real-time is hard, but soft real-time is harder!
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
15 of 35
14 of 35
Large and complex
– Vary from a few hundred lines of assembler or C to 20 million
lines of Ada estimated for the Space Station.
Concurrent control of separate system components
– Devices operate in parallel in the real-world, need concurrent
entities in the program.
Facilities to interact with special purpose hardware
– Need to be able to program devices in a reliable and abstract
way.
Extreme reliability and safety
– Embedded systems typically control their environment; failure
to control can result in loss of life, damage to environment or
economic loss.
Guaranteed response times
– We need to be able to predict with confidence the worst case
response times for systems; efficiency is important but
predictability is essential.
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
Misconceptions about RT systems
•
Real-time computing is equivalent to fast computing.
•
Advances in hardware will solve real-time problem.
•
There is no science in real-time system design.
•
Real-time systems research is about performance tuning.
•
All above are FALSE!
• Why?
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
16 of 35
Part II
Scheduling
17 of 35
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
18 of 35
Scheduling
•
•
Allocating resources, especially the CPU time, among all
computational processes such that the timeliness
requirements are met.
The scheduler decides which process is to be executed
next.
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
19 of 35
Process as an abstraction
•
For different computational processes in the OS
•
For parallel developments within the physical environment
and in the control system
•
For nodes in a network, with interaction and communication
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
Non Real-Time Scheduling
•
•
•
•
Real-Time Scheduling
•
Primary goal
– Maximize interactive performance
Secondary goal
– Ensure fairness
• Prevent deadlock, starvation
Typical metrics and goals:
– Minimize response time
– Maximize throughput
•
21 of 35
Typical metrics and goals:
– Guarantee ratio (hard real-time)
– Maximize completion ratio / minimize miss ratio (hard / firm)
– Minimize overall tardiness (soft real-time)
•
Examples
– Cyclic Scheduling
– EDF (Earliest Deadline First)
– LS (Least Slack)
– RM (Rate-Monotonic)
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
Some parameters
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
23 of 35
Primary goal:
– Ensure predictability !!!
Secondary goals
– All the others
•
Examples
– FCFS (First-Come-First-Served)
– RR (Round-Robin)
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
20 of 35
22 of 35
Scheduling: Problem Space
•
Uniprocessor / multiprocessor / distributed system
•
Periodic / sporadic / aperiodic
•
Independent / interdependent
•
Preemptive / non-preemptive
•
Handle transient overloads
•
Support fault tolerance
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
24 of 35
Simple Process Model
•
Fixed set of processes, uniprocessor system
•
Processes are periodic, with known periods
•
Processes are independent of each other critical instant
•
System overheads, context switches etc, are ignored (zero cost)
•
Processes have a deadline equal to their period
•
Each process must complete before its next release
•
Worst-case execution time is known
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
Performance Metrics
•
Completion ratio / miss ratio
•
Maximize total value (weighted sum)
•
Maximize value of task
•
Minimize lateness
•
Minimize error (imprecise tasks)
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
25 of 35
Types of Scheduling
•
•
•
Different Approaches
Static vs. dynamic
– Static (off-line)
• complete a priori knowledge of the task set and its
constraints is available
• hard/safety-critical systems
– Dynamic (on-line)
• partial taskset knowledge, runtime predictions
• firm/soft/best-effort systems, hybrid systems
Preemptive vs. non-preemptive
Off-line vs. on-line scheduling analysis
• off-line analysis can be used with dynamic scheduling
• off-line analysis very important for hard-rt systems
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
26 of 35
•
Cyclic executives
•
Fixed priority scheduling
– RM - Rate Monotonic
– DM - Deadline Monotonic Scheduling
•
Dynamic priority scheduling
– EDF - Earliest Deadline First
– LSF - Least Slack First
•
OBS!
– Don’t confuse dynamic scheduling with dynamic priority
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
27 of 35
Cyclic Executive
General Procedure
•
•
•
•
•
What happens if the periods are not harmonic?
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
29 of 35
28 of 35
Calculate Major cycle
– Least common multiplier of task periods
Calculate Minor Cycle
– Greatest common divisor of task periods
Populate all the minor cycles of a first major cycle with tasks
– If a task cannot fit (its w.c.e.t.) in a minor cycle it needs to be split
• Over several minor cycles
• If the programming technique allows it
– Every task should run to completion once per period
• Period might span several minor cycles
• A new task instance cannot be scheduled before its natural release
How is schedulability analysis done?
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
30 of 35
Schedulability analysis
•
•
Schedulability analysis?
– See if a taskset is schedulable.
Scheduling analysis?
– Analyse the particular scheduling.
•
Is a taskset schedulable using cyclic scheduling?
– Construct the schedule and find out.
•
Sum (Ci/Ti) <= 1 ?
– YES: The taskset is schedulable using cyclic scheduling.
– NO: If we assume a simple task model, and that tasks can
be split in arbitrarily small pieces, then taskset is not
schedulable using cyclic scheduling.
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
31 of 35
Task dependencies & cyclic
•
Dependences due to
• Sharing resources
• Computation precedence requirements
•
Make sure the running order of the tasks is respected
•
A taskset that is schedulable if tasks are independent might
not be schedulable if dependencies are introduced
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
Cyclic executives observations
•
No actual processes exist at run-time
– Each minor cycle is just a sequence of procedure calls
•
The procedures share a common address space
– Can thus pass data between themselves.
•
This data does not need to be protected
– Via a semaphore, for example
– Because concurrent access is not possible.
•
All process' periods must be a multiple of the minor cycle
– Why?
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
33 of 35
Reading
•
Burns & Wellings, Ch 1. and Ch. 13
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
35 of 35
32 of 35
Disadvantages of cyclic
•
Difficult to incorporate sporadic processes
•
Incorporate processes with long periods
•
Cumbersome for tasks with dependencies
– Think about an OS without synchronisation primitives
•
Construct the cyclic executive
– Or adding a new task to the taskset
•
Handle processes with sizeable computation times.
– How do you split them?
– Can you split them?
Lecture 1: Introduction & cyclic scheduling
Calin Curescu
34 of 35
Download