0% found this document useful (0 votes)
222 views

Real Time Operating System

Uploaded by

warp_zone
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
222 views

Real Time Operating System

Uploaded by

warp_zone
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 30

REAL TIME

OPERATING SYSTEMS
REAL TIME OPERATING
SYSTEM
 Timeliness is the single most important aspect of a real-time
system. These systems respond to a series of external inputs,
which arrive in an unpredictable fashion.
 The real-time systems process these inputs, take appropriate
decisions and also generate output necessary to control the
peripherals connected to them.
 As defined by Donald Gillies "A real-time system is one in
which the correctness of the computations not only depends
upon the logical correctness of the computation but also upon
the time in which the result is produced. If the timing
constraints are not met, system failure is said to have
occurred."
TYPES OF RTOS
 HARD REAL TIME OS - A late response is
incorrect and implies a system failure. Hard real-time
systems are used when it is imperative that an event is
reacted to within a strict deadline.
 Eg- A car engine control system is a hard real-time
system because a delayed signal may cause engine
failure or damage. Other examples of hard real-time
embedded systems include medical systems such as
heart pacemakers and industrial process controllers. 
TYPES OF RTOS (CONTD.)
 SOFT REAL TIME OS - Timeliness requirements are
defined by using an average response time. If a single
computation is late, it is not usually significant, although
repeated late computation can result in system failures. Soft
real-time systems are typically used where there is some
issue of concurrent access and the need to keep a number
of connected systems up to date with changing situations.
 Eg - for example software that maintains and updates the
flight plans for commercial airlines. The flight plans must
be kept reasonably current but can operate to a latency of
seconds. Live audio-video systems are also usually soft
real-time; violation of constraints results in degraded
quality, but the system can continue to operate.
TYPES OF RTOS (CONTD.)
 FIRM - This is a combination of both hard
and soft timeliness requirements. The
computation has a shorter soft requirement and
a longer hard requirement.
 For example, a patient ventilator must
mechanically ventilate the patient a certain
amount in a given time period. A few seconds'
delay in the initiation of breath is allowed,
but not more than that.
The following table compares some of the key features of real -time
software systems with other conventional software systems.
Feature Sequential Concurrent Real-Time
Programming Programming Programming
Execution Predetermined Multiple Usually
order sequential composed
programs of concurrent
executing in programs
parallel
Numeric Independent Generally Dependent on
Results of program dependent on program
execution program execution
speed execution speed
speed
Examples Accounting, UNIX operating Airflight
payroll system controller
CHARACTERISTICS OF RTOS
 Determinism
 Responsiveness
 User control
 Reliability
 Fail-soft operation
 Determinism
- It performs operations at fixed, predetermined times or within
predetermined time intervals.
- When multiple processes are competing for resources and processor
time, no system will be fully deterministic.
- In a real-time operating system, process requests for service are
dictated by external events and timings.
- The extent to which an operating system can deterministically satisfy
requests depends on
1. The speed with which it can respond to interrupts
2. On whether the system has sufficient capacity to handle all
requests within the required time.
 Responsiveness
- A related but distinct characteristic is responsiveness.
- Determinism is concerned with how long an operating system delays
before acknowledging an interrupt.
- Responsiveness is concerned with how long, after acknowledgment, it
takes an operating system to service the interrupt
 User control
> Non real time – user has no control over scheduling function.
> Real time – user must be able to distinguish between hard and soft real
time tasks to specify relative priorities within each class. A real-time
system may also allow the user to specify such characteristics as the use of
paging or process swapping, what processes must always be resident in
main memory, what disk transfer algorithms are to be used, what rights the
processes in various priority bands have, and so on.
 Reliability
RTOS involves time constraints. Hence critical tasks must be performed on
time or system would fail. It is said to be reliable.
 Fail soft operation
Even a real-time system must be designed to respond to various failure
modes. Fail-soft operation is a characteristic that refers to the ability of a
system to fail in such a way as to preserve as much capability and data as
possible.
Implementing RTOS
 Preemptive, priority-based scheduling
 Preemptive kernel
 Minimized latency
Priority-Based Scheduling
 The most important feature of a real-time operating
system is to respond immediately to a real-time
process as soon as that process requires the CPU.
 As a result, the scheduler for a real-time operating
system must support a priority-based algorithm with
preemption.
 If the scheduler also supports preemption, a process
currently running on the CPU will be preempted if a
higher-priority process becomes available to run.
 Real-time processes are assigned highest priority.
Preemptive Kernels
 Nonpreemptive kernels – do not allow preemption of a
process running in kernel mode.
 In contrast, a preemptive kernel allows the preemption of a
task running in kernel mode.
 Preemptive kernels are difficult to design.
 2 approaches
 Preemptive points – checks if there are any higher priority
process. If yes performs context switch. Inserted at the safe
points in kernel where data structures cannot be modified.
 Synchronization - With this method, the kernel can always be
preemptible, because any kernel data being updated are
protected from modification by the high-priority process.
Minimizing Latency
 Consider the event-driven nature of a real-time
system: The system is typically waiting for an event
in real time to occur. Events may arise either in
software—as when a timer expires—or in hardware
—as when a remote-controlled vehicle detects that it
is approaching an obstruction.
 When an event occurs, the system must respond to
and service it as quickly as possible.
 We refer to event latency as the amount of time that
elapses from when an event occurs to when it is
serviced.
Minimizing Latency (Contd…)
 2 types of latency
Interrupt Latency
Dispatch Latency

Interrupt Latency –
> Period of time from arrival of interrupt to start of ISR.
> OS must complete process that was running + save the status
of the current process before switching.
> Total time for the above tasks = interrupt latency
> For RTOS it is min to ensure all critical tasks be completed on
time.
> For hard real time : interrupt latency must be minimized and
bounded to guarantee the deterministic behavior required of
hard real-time kernels.
Minimizing Latency (Contd…)
Minimizing Latency (Contd….)
 Dispatch Latency
> The amount of time required for the scheduling
dispatcher to stop one process and start another.
> It must be minimum.
> The conflict phase of dispatch latency has two
components:
1. Pre-emption of any process running in the kernel
2. Release by low-priority processes of resources
needed by a high-priority process
Minimizing Latency (Contd….)
 Dispatch Latency issues :
When a higher priority process (H) needs the
resources being used by a lower priority process (L).
Higher priority process must wait for the lower
priority process to finish execution.
Situation becomes even more complicated when the
lower priority process is preempted by another
process (M).
Priority order - L < M < H
The higher priority process goes into infinite waiting.
This is known as PRIORITY INVERSION.
Minimizing Latency (Contd….)
 Solution to Priority inversion
PRIORITY INHERITENCE PROTOCOL
All processes that are accessing resources
needed by a higher-priority process inherit the
higher priority until they are finished with the
resources in question. When they are finished,
their priorities revert to their original values.
L inherits priority of H finishes execution
L gets back its original priority resources
available for H H executes before M
SCHEDULING
 Rate – monotonic scheduling
 Earliest deadline first scheduling
 Proportional share scheduling
 Pthread Scheduling
Periodic and Aperiodic process
 Periodic – In the case of a periodic task, the
requirement may be stated as “once per period
T” or “exactly T units apart.”
 Aperiodic - has a deadline by which it must
finish or start, or it may have a constraint on
both start and finish time.
 Period – Time after which the process repeats
 CPU utilization – Burst / Period
Rate – Monotonic Scheduling
 The rate-monotonic scheduling algorithm
schedules periodic tasks using a static priority
policy with pre-emption.
 Simple to understand and implement:
Processes with shorter period given
higher priority
 E.g. Period Priority
10 1 (highest)
12 2
15 3
20 4 (lowest)
RMS (Contd…)
 Key metric is processor utilization: sum of compute
time divided by period for each process:
U =  ci / pi

 No schedule can possibly exist if U > 1


 No processor can be running 110% of the time

 Fundamental result:
 RMS schedule always exists if U < n (2 1/n – 1)
RMS (Contd….)
 Consider 2 processes
Process 1 - Burst = 20 , Period = 50
Process 2 – Burst = 35 , Period = 100
 Total CPU utilization = 20 / 50 + 35 / 100 = 0.75 =
75%
 Suppose we assign P2 higher priority than P1

P1
P1,P2

0 10 20 30 40 50 60 70 80 90 100 110
RMS (Contd…)
P1 P1,P2 P1,P2

P1 P2 P1 P2 P1 P2
......

0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150


160
 Suppose we use RMS, P1 is given higher priority than
P2.
 P1 starts first and completes its CPU burst at time 20,
thereby meeting its first deadline. P2 starts running at
this point and runs until time 50. At this time, it is
preempted by P1, although it still has 5 milliseconds
remaining in its CPU burst. P1 completes its CPU
burst at time 70, at which point the scheduler resumes
P2. P2 completes its CPU burst at time 75. The system
is idle until time 100, when Pi is scheduled again.
Earliest Deadline First (EDF)
 Earliest-deadline-first (EDF) scheduling
dynamically assigns priorities according to
deadline.
 The earlier the deadline, the higher the
priority; the later the deadline, the lower the
priority.
 E.g. – Consider 3 processes
1 = (1, 4), 2 = (2, 6), 4 = (3, 8).
Burst Period
EDF (Contd…)
Deadline
Proportional Share Scheduling
 Proportional Share Scheduling is a type of scheduling which
preallocates certain amount of CPU time to each of the processes. In
a proportional share algorithm every job has a weight, and jobs
receive a share of the available resources proportional to the weight
of every job.
 An application can receive N shares of time, thus ensuring that the
application will have N/T of the total processor time.
 As an example, assume that there is a total of T = 100 shares to be
divided among three processes, A, B, and C.
 A is assigned 50 shares, B is assigned 15 shares, and C is assigned 20
shares. This scheme ensures that A will have 50 percent of total
processor time, B will have 15 percent, and C will have 20 percent.
Total = 75%
 Proportional share schedulers must work in conjunction with an
admission control policy to guarantee that an application receives its
allocated shares of time.
 An admission control policy will only admit a client requesting a
particular number of shares if there are sufficient shares available.
Pthread Scheduling
 Pthreads defines two scheduling classes for real-time
threads:
 SCHED.FIFO - schedules threads according to a first-
come, first-served policy. The highest-priority real-
time thread at the front of the FIFO queue will be
granted the CPU until it terminates
or blocks.
 SCHEDJRR - (for round-robin) is similar to
SCHED_FIFO except that it provides time slicing
among threads of equal priority.
Examples of RTOS
 Some examples of real-time operating systems
are Chimera, Lynx, MTOS, QNX, RTMX,
RTX, and VxWorks.
THE END

You might also like