Unit 3 and Unit 4
Unit 3 and Unit 4
Unit 3 and Unit 4
Static Scheduling:
All scheduling decisions at compile time.
Temporal task structure fixed.
Precedence and mutual exclusion satisfied by
the schedule (implicit synchronization).
One solution is sufficient.
Any solution is a sufficient schedulability test.
Benefits
Simplicity
Scheduling Algorithm
Static vs. Dynamic
Dynamic Scheduling:
All scheduling decisions at run time.
Based upon set of ready tasks.
Mutual exclusion and synchronization enforced by
explicit synchronization constructs.
Benefits
Flexibility.
Only actually used resources are claimed.
Disadvantages
Guarantees difficult to support
Computational resources required for scheduling
Scheduling Algorithm
Preemptive vs. Nonpreemptive
Preemptive Scheduling:
Event driven.
Each event causes interruption of running tasks.
Choice of running tasks reconsidered after each
interruption.
Benefits:
Can minimize response time to events.
Disadvantages:
Requires considerable computational resources
for scheduling
Rate Monotonic scheduling
Simplest type of real time scheduling
- Tasks are periodic, with hard deadlines
- Tasks are completely independent and do not
communicate with each other
- Tasks are scheduled according to priority and
task priorities are fixed
- Computation time is known and constant
Rate Monotonic scheduling
Priority assignment based on rates of tasks
Higher rate task assigned higher priority
Schedulable utilization = 0.693
P1 1 8
P2 2 5
P3 2 10
The utilization will be:
Arrives 0 20 40 …
Execution Time 10 10 10 …
End by 20 40 60 …
Process B
Arrives 0 50 100 …
Execution Time 25 25 25 …
End by 50 100 150 …
Question: Is there enough time for the execution of two periodic
tasks?
Exercise :Five Periodic Tasks
Execution profile of five periodic tasks
Least Laxity First
It assigns priority based on the slack
time of a process.
Slack time is the amount of
time left after a job if the job was
started now.
Its most common use is in embedded
systems, especially those with multiple
processors
Scheduling Algorithms in RTOS
Priority Scheduling
(Greedy / List / Event Driven)
Scheduling Algorithms in RTOS (contd)
Clock Driven
All parameters about jobs (release time/
execution time/deadline) known in
advance.
Schedule can be computed offline or at
some regular time instances.
Minimal runtime overhead.
Not suitable for many applications.
Scheduling Algorithms in RTOS (contd)
Priority Scheduling
(Greedy/List/Event Driven)
Processor never left idle when there are
ready tasks
Processor allocated to processes according
to priorities
Priorities
static - at design time
Dynamic - at runtime
Priority Scheduling
LynxOS
Microkernel Architecture
Kernel provides scheduling/interrupt handling
Additional features through Kernel Plug Ins(KPIs)
TCP/IP stack , Filesystem
KPI’s are multithreaded
Memory Protection/ Demand Paging Optional
Development and Deployment on the same host
OS support for compilers/debuggers
Other RTOS’s (contd)
VxWorks
Monolithic Architecture
Real Time Posix compliant
Cross development System
pSOS
Object Oriented OS
Peripheral devices and protocols
• Interfacing
Serial/parallel ports, USB, I2C, PCMCIA, IDE
• Communication
Serial, Ethernet, Low bandwidth radio, IrDA,
802.11b based devices
• User Interface
LCD, Keyboard, Touch sensors, Sound, Digital
pads, Webcams
• Sensors
A variety of sensors using fire, temperature,
pressure, water level, seismic, sound, vision
TASK WITH RTOS – WORKING EXAMPLE TO DO
Execution Time
Hard Real-Time Systems
Controllers in planes, cars, plants, … are expected to finish their tasks within
reliable time bounds.
Why may we care about the WCET?
Worst case executime time
• benchmark hardware
• assess code quality
• assess resource needs for non/soft real-time
systems
• ensure meeting livelines (new starting points)
Measuring WCET/BCET
Execution time may depend on program inputs
• In this case, quality of measurements depends on judicious
choice of
inputs
• Execution time may depend on execution context
(cache content, state of pipeline, ...)
• Typically need to add safety margin to best/worst result
measured
• Extensive testing/measurement still common
practice
Analysing WCET/BCET
Instead of measuring execution times, compute
them
• Advantages
• Can ensure safety of result
• Saves testing effort
• Disadvantages
• Try to be as tight as possible—may not always
succeed
• Typically requires extensive analysis effort
• Accuracy depends on
• Complexity of hardware
• Program structure
• Quality of hardware model
Flow Analysis
Analyse dynamic behaviour of program
• Number of loop iterations, Recursion depth, Input
dependences, Infeasible paths, Function instances, ...
• Analysis level
Object code
•Source code (may need non-trivial mapping to object code)
Flow analysis
Cont….
The set of structurally possible flows for a program, i.e. those given by the
structure of the program, is usually infinite, since e.g. loops can be taken an
arbitrary number of times
• The executions are made finite by bounding all loops with some upper limit
on the number of executions (basic finiteness)
• Adding even more information, e. g. about the input data, allows the set of
executions to be narrowed down further, to a set of statically allowed paths.
This is the “optimal” outcome of the flow analysis.
Loop bounds: Easy to find in this example; in general, very
difficult to
determine
• Infeasible paths: Can we exclude a path, based on data
analysis?
A-B-C-E-F-G is infeasible—since if x>5, it is not possible that x *
2 < 0.
Well, really? What about integer overflows? Must be sure that
these do not
happen in the example...
Mapping !!!
Flow Info Graph
Mapping Problem exists!!!
Embedded compilers often do a lot of code optimizations
Solutions:
- Use special compiler also mapping flow info (not common)
- Use compiler debug info for mapping (only works with little/no
optimizations)
- Perform flow analysis on binaries (most common)
Provides bounds on the number of times different program parts may be
executed