Rtos

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 63

Characteristics of Real-

Time Operating Systems

 Deterministic
 Operations are performed at fixed,
predetermined times or within predetermined
time intervals
 Concerned with how long the operating
system delays before acknowledging an
interrupt

© 2000 Morgan Overheads for Computers as


Kaufman Components
Characteristics of Real-
Time Operating Systems

 Responsiveness
 How long, after acknowledgment, it takes the
operating system to service the interrupt
 Includes amount of time to begin execution
of the interrupt
 Includes the amount of time to perform the
interrupt

© 2000 Morgan Overheads for Computers as


Kaufman Components
Characteristics of Real-
Time Operating Systems

 User control
 User specifies priority
 Specify paging
 What processes must always reside in main
memory
 Disks algorithms to use
 Rights of processes

© 2000 Morgan Overheads for Computers as


Kaufman Components
Characteristics of Real-
Time Operating Systems

 Reliability
 Degradation of performance may have
catastrophic consequences
 Attempt either to correct the problem or
minimize its effects while continuing to run
 Most critical, high priority tasks execute

© 2000 Morgan Overheads for Computers as


Kaufman Components
Characteristics of Real-
Time Operating Systems
 Fail-soft operation
 ability of a system to fail in such a way as to preserve
as much capability and data as possible;
 the RTOS tries to correct the problem or minimize its
effects while continuing to run;
 RTOS is stable, i.e. it will meet the deadlines of its
most critical, highest-priority tasks, even if some less
critical task deadlines are not always met.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Features of Real-Time
Operating Systems

 Fast context switch


 Small size
 Ability to respond to external interrupts
quickly
 Multitasking with interprocess
communication tools such as semaphores,
signals, and events

© 2000 Morgan Overheads for Computers as


Kaufman Components
Features of Real-Time
Operating Systems

 Use of special sequential files that can


accumulate data at a fast rate
 Preemptive scheduling based on priority
 Minimization of intervals during which
interrupts are disabled
 Delay tasks for fixed amount of time
 Special alarms and timeouts
© 2000 Morgan Overheads for Computers as
Kaufman Components
Embedded vs. general-
purpose scheduling

 Workstations try to avoid starving


processes of CPU access.
 Fairness = access to CPU.
 Embedded systems must meet deadlines.
 Low-priority processes may not run for a long
time.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Priority-driven scheduling

 Each process has a priority.


 CPU goes to highest-priority process that
is ready.
 Priorities determine scheduling policy:
 fixed priority;
 time-varying priorities.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Priority-driven scheduling
example

 Rules:
 each process has a fixed priority (1 highest);
 highest-priority ready process gets CPU;
 process continues until done.
 Processes
 P1: priority 1, execution time 10
 P2: priority 2, execution time 30
 P3: priority 3, execution time 20
© 2000 Morgan Overheads for Computers as
Kaufman Components
Priority-driven scheduling
example

P3 ready t=18
P2 ready t=0 P1 ready t=15

P2 P1 P2 P3

0 10 20 30 40 50 60
time
© 2000 Morgan Overheads for Computers as
Kaufman Components
The scheduling problem

 Can we meet all deadlines?


 Must be able to meet deadlines in all cases.
 How much CPU horsepower do we need
to meet our deadlines?

© 2000 Morgan Overheads for Computers as


Kaufman Components
Process initiation
disciplines

 Periodic process: executes on (almost)


every period.
 Aperiodic process: executes on demand.
 Analyzing aperiodic process sets is
harder---must consider worst-case
combinations of process activations.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Timing requirements on
processes

 Period: interval between process


activations.
 Initiation interval: reciprocal of period.
 Initiation time: time at which process
becomes ready.
 Deadline: time at which process must
finish.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Timing violations

 What happens if a process doesn’t finish


by its deadline?
 Hard deadline: system fails if missed.
 Soft deadline: user may notice, but system
doesn’t necessarily fail.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Example: Space Shuttle
software error

 Space Shuttle’s first launch was delayed


by a software timing error:
 Primary control system PASS and backup
system BFS.
 BFS failed to synchronize with PASS.
 Change to one routine added delay that
threw off start time calculation.
 1 in 67 chance of timing problem.
© 2000 Morgan Overheads for Computers as
Kaufman Components
Scheduling of a
Real-Time Process

© 2000 Morgan Overheads for Computers as


Kaufman Components
Scheduling of a
Real-Time Process

© 2000 Morgan Overheads for Computers as


Kaufman Components
Scheduling of a
Real-Time Process

© 2000 Morgan Overheads for Computers as


Kaufman Components
Scheduling of a
Real-Time Process

© 2000 Morgan Overheads for Computers as


Kaufman Components
Real-Time Scheduling

 Scheduling policies:
 RMS;
 EDF.
 Scheduling modeling assumptions.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Metrics

 How do we evaluate a scheduling policy:


 Ability to satisfy all deadlines.
 CPU utilization---percentage of time devoted
to useful work.
 Scheduling overhead---time required to make
scheduling decision.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Rate monotonic scheduling

 RMS (Liu and Layland): widely-used,


analyzable scheduling policy.
 Analysis is known as Rate Monotonic
Analysis (RMA).

© 2000 Morgan Overheads for Computers as


Kaufman Components
RMA model

 All process run on single CPU.


 Zero context switch time.
 No data dependencies between processes.
 Process execution time is constant.
 Deadline is at end of period.
 Highest-priority ready process runs.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Process parameters

 Ti is computation time of process i; i is


period of process i.

period i

Pi

computation time Ti

© 2000 Morgan Overheads for Computers as


Kaufman Components
Rate-monotonic analysis

 Response time: time required to finish


process.
 Critical instant: scheduling state that gives
worst response time.
 Critical instant occurs when all higher-
priority processes are ready to execute.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Critical instant
interfering processes

P1 P1 P1 P1 P1

P2 P2 P2

P3 P3
critical
instant
P4

© 2000 Morgan Overheads for Computers as


Kaufman Components
RMS priorities

 Optimal (fixed) priority assignment:


 shortest-period process gets highest priority;
 priority inversely proportional to period;
 break ties arbitrarily.
 No fixed-priority scheme does better.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Rate Monotonic
Scheduling

 Assigns priorities to tasks on the basis of


their periods
 Highest-priority task is the one with the
shortest period

© 2000 Morgan Overheads for Computers as


Kaufman Components
Periodic Task Timing
Diagram

© 2000 Morgan Overheads for Computers as


Kaufman Components
RMS example

P2 period

P2
P1 period

P1 P1 P1

0 5 10
time
© 2000 Morgan Overheads for Computers as
Kaufman Components
RMS CPU utilization
 Collective utilization of processor by i tasks
(where 1<= i <= n) is i Ti / i
 Upper bound of utilization for RMS = n(2exp(1/n) - 1)
where n is number of tasks;
 As number of tasks approaches infinity, maximum
utilization approaches 69%.
 Set of tasks is schedulable of if their collective
processor utilization does not exceed the upper bound.

© 2000 Morgan Overheads for Computers as


Kaufman Components
RMS CPU utilization,
cont’d.

 RMS cannot use 100% of CPU, even with


zero context switch overhead.
 Must keep idle cycles available to handle
worst-case scenario.
 However, RMS guarantees all processes
will always meet their deadlines.

© 2000 Morgan Overheads for Computers as


Kaufman Components
RMS implementation

 Efficient implementation:
 scan processes;
 choose highest-priority active process.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Deadline Scheduling

 Real-time applications are not concerned


with speed but with completing tasks
 Scheduling tasks with the earliest deadline
minimizes the fraction of tasks that miss
their deadlines

© 2000 Morgan Overheads for Computers as


Kaufman Components
Deadline Scheduling

 Information used
 Ready time
 Starting deadline
 Completion deadline
 Processing time
 Resource requirements
 Priority
 Subtask structure
© 2000 Morgan Overheads for Computers as
Kaufman Components
Two Tasks

© 2000 Morgan Overheads for Computers as


Kaufman Components
Earliest-deadline-first
scheduling

 EDF: dynamic priority scheduling scheme.


 Process closest to its deadline has the
highest priority.
 Requires recalculating process’ priorities
at every timer interrupt.

© 2000 Morgan Overheads for Computers as


Kaufman Components
EDF analysis

 Upper bound of processor utilization for


EDF is 1, so
 EDF can use up to 100% of CPU.
 But EDF may still miss a deadline.

© 2000 Morgan Overheads for Computers as


Kaufman Components
EDF implementation

 On each timer interrupt:


 compute time to deadline;
 choose process closest to deadline.
 Generally considered too expensive to use
in practice.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Fixing scheduling
problems

 What if your set of processes is


unschedulable?
 Change deadlines in requirements.
 Reduce execution times of processes.
 Get a faster CPU.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Priority inversion

 Priority inversion: low-priority process


keeps high-priority process from running.
 Improper use of system resources can
cause scheduling problems:
 Low-priority process grabs I/O device.
 High-priority device needs I/O device, but
can’t get it until low-priority process is done.
 Can cause deadlock.
© 2000 Morgan Overheads for Computers as
Kaufman Components
Solving priority inversion

 Give priorities to system resources.


 Have process inherit the priority of a
resource that it requests.
 Low-priority process inherits priority of device
if higher.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Data dependencies
 Data dependencies
allow us to improve
P1
utilization.
 Restrict combination
of processes that can
run simultaneously. P2
 P1 and P2 can’t run
simultaneously.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Context-switching time

 Non-zero context switch time can push


limits of a tight schedule.
 Hard to calculate effects---depends on
order of context switches.
 In practice, OS context switch overhead is
small.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Evaluating performance

 You may want to test:


 context switch time assumptions;
 interrupt response time,
 effects of caching
 You can use OS simulator to exercise
process set, trace system behavior.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Processes and caches
 The assumption of no cache present results in extremely
overdesigned hardware, which has more computational
power than is necessary;
 Even if individual processes are well-behaved, processes
may interfere with each other.
 Well-designed cache provides significant performance
benefits not only for a single process but can allow a
microprocessor to run a set of processes much more
quickly
 Worst-case execution time with bad behavior is usually
much worse than execution time with good cache
behavior.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Power optimization

 Power management: determining how


system resources should be
scheduled/used to control power
consumption.
 OS can manage power just as it manages
time.
 OS reduces power by shutting down units.
 May have partial shutdown modes.
© 2000 Morgan Overheads for Computers as
Kaufman Components
Power management and
performance

 Power management and performance are


often at odds.
 Entering power-down mode consumes
 energy,
 time.
 Leaving power-down mode consumes
 energy,
 time.
© 2000 Morgan Overheads for Computers as
Kaufman Components
Simple power management
policies

 Request-driven: power up once request is


received. Adds delay to response.
 Predictive shutdown: try to predict how
long you have before next request.
 May start up in advance of request in
anticipation of a new request.
 If you predict wrong, you will incur additional
delay while starting up.
© 2000 Morgan Overheads for Computers as
Kaufman Components
Probabilistic shutdown

 Assume service requests are probabilistic.


 Optimize expected values of:
 power consumption;
 response time.
 Simple probabilistic: shut down after time
Ton, turn back on after waiting for Toff.

© 2000 Morgan Overheads for Computers as


Kaufman Components
Power Management (1)

Power consumption of various parts of a laptop


© 2000 Morgan
computer
Overheads for Computers as
Kaufman Components
Power management (2)

The use of zones for backlighting the


display
© 2000 Morgan Overheads for Computers as
Kaufman Components
Power Management (3)

 Hard disk – spin – off, using disk cache in


RAM
 CPU – cutting voltage, lowering clock
speed

© 2000 Morgan Overheads for Computers as


Kaufman Components
Power Management (4)

 Running at full clock speed


 Cutting voltage by two
 cuts clock speed by two,
 cuts power by four
© 2000 Morgan Overheads for Computers as
Kaufman Components
Power Management (5)

 Memory
– cache can be flushed and
switched off – write the
memory to the disk and switch it off;
 Wireless communications - turn the radio
off if not in use

© 2000 Morgan Overheads for Computers as


Kaufman Components
Power Management (6)

 Thermal management
 Battery magement
 Driver management

© 2000 Morgan Overheads for Computers as


Kaufman Components
Power Management (7)
 Telling the programs to use less energy
 may mean poorer user experience

 Examples
 change from color output to black and
white
 speech recognition reduces vocabulary
 less resolution or detail in an image

© 2000 Morgan Overheads for Computers as


Kaufman Components
Advanced Configuration
and Power Interface

 ACPI: open standard for power


management services.
applications
power
OS kernel management
device
drivers
ACPI BIOS

Hardware platform
© 2000 Morgan Overheads for Computers as
Kaufman Components
ACPI global power states

 G3: mechanical off


 G2: soft off
 S1: low wake-up latency with no loss of context
 S2: low latency with loss of CPU/cache state
 S3: low latency with loss of all state except memory
 S4: lowest-power state with all devices off
 G1: sleeping state
 G0: working state
© 2000 Morgan Overheads for Computers as
Kaufman Components

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy