01 SB 072010004900064
01 SB 072010004900064
Topic – 1
Introduction to RTOS
Real Time Operating System - RTOS
A real time is the time which continuously increments at regular intervals after
the start of the system and time for all the activities at different instances take
that time as a reference in the system.
An RTOS is multitasking OS for the applications which needs to meet timely
deadlines and functioning in real time constraints.
Real time constraint means a time interval between occurrence of an event and
system expected response to the event.
An RTOS is an OS for response time-controlled and event-controlled processes
and these processes has predictable latencies.
RTOS has many OS services, these enables design of software for a large
number of embedded systems.
Real Time Operating System - RTOS
An RTOS, is a system installed within our embedded system product or
operating environment to gather and synthesize information as it comes in.
It connects related terminals or points of entry to create a network or a central
point where all your operations can be monitored.
With this information and data, decision making is significantly simplified and
made more accurate.
Real Time Operating System - RTOS
RTOS Srtucture :
Characteristics of RTOS
Deterministic:
Operations are performed at fixed, predetermined times or within
predetermined time intervals.
Concerned with how long the OS delays before acknowledging an interrupt.
Responsive:
How long, after acknowledgement, it takes the operating system to service the
interrupt.
Includes amount of time to begin execution of the interrupt.
Includes the amount of to perform the interrupt.
Characteristics of RTOS
User Control:
User specifies the priority.
Specify Paging.
What and which processes must always reside in main memory.
Disks algorithms to use.
Rights of processes.
Reliability:
Degradation of performance may have unfortunate consequences.
Attempt either to correct the problem or minimize its effects while continuing
to run.
Most critical, high priority task execute.
Characteristics of RTOS
Fail – Soft Operation:
Ability of a system to fail in such a way as to preserve as much capability and
data as possible.
RTOS tries to correct the problem or minimize its effects while continuing to
run.
Stable RTOS.
Fast context switch.
Small size.
Ability to respond to external interrupts quickly.
Multitasking with Interprocess communication tools such as semaphores,
signals and events.
Special alarms and timeouts.
Characteristics of RTOS
Fail – Soft Operation:
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.
RTOS - Services
1. Basic OS Functions – Performs activities like, Process Management, Resource
Management, Device Management, I/O and Network Management.
2. Process Priorities Management (Priority Allocation) – User level priorities
allocation , called static or real time priorities. The real time priorities are
higher than dynamically allocated priorities to the OS functions.
3. Process Priorities Management (Priority Inheritance) – Priorities
inheritance enables a shared resource in low priority task. E.g. LCD display,
be used by high priority task first. An intermediate priority task will not
preempt the low priority task.
RTOS - Services
4. Process Management (Preemption) – The RTOS kernel preempt a lower
priority process by a message or event for which it is waiting to run as soon
as higher priority process takes place.
5. Process Predictability – A predictable timing behavior of the system and a
predictable task synchronization with minimum jitter (ie. Difference
between best case and worst case latencies).
6. Memory Management (Protection) – In RTOS threads of application program
can run in kernel space. So provides protection against memory
management.
7. Memory Management (MMU) – Memory management is done by either
disabling the use of MMU and Virtual Memory or by using memory locks.
Locking stops the page swapping between physical memory and disk.
RTOS - Services
8. Memory Allocation – In RTOS, the memory allocation is fast when there are
fixed length memory blocks allocations happens.
9. RTOS Scheduling and Interrupt latency control functions – Real time task
scheduling and interrupt latency control and use of timers and system
clocks.
10. Timer Functions and Time Management – Provides for timer functions.
There is a time allocation and de-allocation to attain efficiency in given
timing constraints.
11. Asynchronous IO Functions – Permits asynchronous IOs, which mean IOs
without blocking a task.
RTOS - Services
12. IPC Synchronization Functions – Synchronization of tasks with IPCs are
provided. (Semaphores, Mailboxes, Message Queues, Pipes, Sockets and
RPCs).
13. Spin Locks – Spin locks for critical section handling activities.
14. Time Slicing – Time slicing of the execution of processes which have equal
priority.
15. Hard and Soft Real Time Operability – Ability to work with the activity
which would be Hard real time or Soft real time operations.
Basic Design Using an RTOS
An embedded system with a single CPU can run only one process at a time.
An RTOS is used in embedded systems to facilitates the following.
1. An RTOS provides running the user threads in kernel space so that they
execute fast.
2. An RTOS provides effective handling of the ISRs (Interrupt Service Routine),
device drivers, ISTs (Interrupt Service Thread), tasks or threads and the
disabling and enabling of interrupts in the user mode critical section codes.
RTOS provides effective handling of such a situation.
3. An RTOS provides memory allocation and de-allocation functions in fixed
time and blocks of memory and restricting the memory accesses only for
the stack and other critical memory blocks.
Basic Design Using an RTOS
4. An RTOS provides for effectively scheduling and running and blocking of the
tasks in cases of many tasks.
5. I/O management with devices , files, mailboxes, pipes, and sockets becomes
simple using an RTOS.
6. Effective management of the multiple states of the CPU and internal and
external physical or virtual devices.
Classification of RTOS
A real time operating system specifies the maximum time that is known /
needed for every operation that is performed.
On the basis of tolerance degree, RTOS is classified into 3 categories,
1. Hard Real Time Operating System
2. Soft Real Time Operating System
3. Firm Real Time Operating System
It is used for Desktop PCs and Laptops. It is only applied to the Embedded
Applications.
Process-Based Scheduling. Time-Based Scheduling used like
Round Robin Scheduling.
Interrupt latency is not considered as Interrupt lag in minimal, which is
important as in RTOS. measured in few microseconds.
No priority inversion mechanism is The priority inversion mechanism is
present in the system. current. So it can not modify by the
system.
Kernel’s operation may or may not be Kernel’s operation can be preempted.
preempted.
Predictability guarantees with some No predictability guarantees.
delay.
Advantages of RTOS
1. Optimizes the System.
2. Links all system and subsystems together.
3. Shows activeness of processes and procedures.
4. Reduces Errors.
5. A memory slot from RTOS makes easier to track changes or activities.
6. Scalable.
7. User-Friendly.
8. Computing environment responds to rapid inputs in a given period of time.
9. Real-time Scheduling
10. Responsive and instantaneous.
11. Reactive.
Disadvantages of RTOS
1. RTOS can run minimal tasks together, and it concentrates only on those
applications which contain an errors so that it can avoid them.
2. RTOS is the system that concentrates on a few tasks. Therefore, it is really
hard for system to do multi-tasking.
3. Specific drivers are required for the RTOS so that it can offer fast response
time to interrupt signals, which helps to maintain its speed.
4. Plenty of resources are used by RTOS, which makes this system expensive.
5. The task which have a low priority need to wait for a long time as the RTOS
maintain the accuracy of the program, which are under execution.
6. Minimum switching of tasks is done in RTOS.
7. It uses complex algorithms which is difficult to understand.
8. RTOS uses lot of resources, which sometimes not suitable for the system.
Applications of RTOS
Airlines Reservation System.
Air Traffic Control System.
Systems that provide immediate updating.
Used in any systems that provides up to date and minute information on stock
prices.
Defense application systems like Radar.
Networked Multimedia Systems.
Command Control Systems.
Internet Telephony.
Anti-Lock Brake System, Air Bag System, Power Windows, etc.
Heart Pacemakers.
Applications of RTOS
In case of devices that are used to save lives, such as automatic opening of a
parachute .
Live TV broadcast systems.
RTOS is a program that was designed for CPU usability management for
microcontrollers.
It helps in enhancing the CPU efficiency in the management of processes or
tasks.
Applications of RTOS
Avionics VoIP Phones, PDA’s
Data Acquisition Set-top Boxes
Digital Controllers Automotive Systems
Defense Systems
Industrial Process Control
Cell Phones
MP3 Players
Game Console
Network Boxes
On Demand Servers
Embedded Devices
Unit – IV
Real Time Operating
System – RTOS
Topic – 2
Introduction to RTS
Real Time Systems
RTS (Real Time Systems) are those which must produce correct responses
within a definite time limit.
RTS is any information processing system that has to respond to externally
generated signals within a finite and specified period.
A RTS is a computer system where the correct functioning of the system
depends on the results produced and the time at which they are produced.
A system, where correct timing behavior is strongly related to functionality,
performance and reliability.
A computer system is a real-time one if it explicitly manages resources in order
to meet timing constraints.
A RTS is a system where correctness depends not only on the logical result of
computation but also on the time at which the results are produced.
Real Time Systems
In real time systems,
Timing of actions is essential: Compare with table tennis, air bag, engine
control and music.
Age of data is essential: Compare with a weather report, sample data, compute,
actuate.
Different consequences depending on context.
Different types of timing requirements needed and delay need not be
controlled.
Real Time Systems
Requirements on a Real Time Systems
Sufficiently fast processing, communication, etc.
Predictable resource sharing and timing.
Real Time systems span several domains of computer science.
They are defense and space systems, networked multimedia systems,
embedded automotive electronics etc.
In a real time system the correctness of the system behaviour depends not only
on the logical results of the computations, but also on the physical instant at
which these results are produced.
A real time system changes its state as a function of physical time.
Based on this real time system can be decomposed into a set of subsystems, i.e.,
the controlled object, the real-time computer system and the human operator.
Requirements on a Real Time Systems
A real-time computer system must react to stimuli from the controlled object
within time intervals dictated by its environment.
The instant at which a result is produced is called a deadline.
If the result has utility even after the deadline has passed, the deadline is
classified as soft, otherwise it is firm.
If a catastrophe could result if a firm deadline is missed, the deadline is hard.
Characteristics of Real Time Systems
Characteristics distinguish Real-Time Systems from Non Real-Time Systems.
These characteristics may or may not be applicable to every RTS.
Time Constraints: Every real time task is associated with some time
constraints, and set a deadlines are associated with tasks. Timing constraints like
delay and duration are also to be considered while designing the system.
Safety Criticality: In non real time systems safety and reliability are
independent issues. But in many RTS these two issues are intricately bound
together making them safety critical.
Concurrency: The RTS must process data from all the sensors concurrently,
otherwise signals may be lost and the system may malfunction. As different
sensors can get different input parameters for a system, so they work to be a
concurrent system.
Characteristics of Real Time Systems
Task Criticality: Task criticality is a measure of the cost of failure of a task.
Task criticality is determined by examining how critical are the results produced
by the task to the proper functioning of the system.
Reactive: RTS are often reactive. A reactive system is one in which an on-going
interaction between the computer and the environment is maintained.
Characteristics of Real Time Systems
Stability: Under overload conditions, RTS need to continue to meet the
deadlines of the most critical tasks, though the deadlines of the non-critical tasks
may not be met.
The release time may not be exactly known, only the range may be known [ri-
ri+].
When only the range of ri is known then this range is called release time.
Indeed, some models assume that only the range of ri is known and call this
range the jitter in ri, or release- time jitter.
If the jitter is negligible, then the actual release time of the job is given by either
earliest or the latest release time.
This release time of the job is called fixed release time.
Almost every real-time system is required to respond to external events which
occur at random instants of time.
When such an event occurs, the system executes a set of jobs in response.
Fixed, Jittered, and Sporadic Release Times
The release times of these jobs are not known until the event triggering them
occurs.
These jobs are called sporadic jobs or aperiodic jobs because they are released
at random time Instants.
Execution Time:
Another temporal parameter of a job, Ji , is its execution time, ei.
ei is the amount of time required to complete the execution of Ji when it
executes alone and has all the resources it requires.
The execution time depends on the complexity of the job, speed of processor
but not on how the job is scheduled.
The execution time may vary. It can be known in terms of maximum and
minimum value of time required to compute each job.
Other Types of Dependencies for Real Time
Tasks
These extensions include temporal distance, OR jobs, conditional branches, and
pipeline.
Temporal Dependency:
Some jobs may be constrained to complete within a certain amount of time
relative to one another.
We call the difference in the completion times of two jobs the temporal
distance between them.
AND/OR Precedence Constraints:
Classical model for a job precedence would not always works properly.
So it is necessary to be specific, we call such jobs AND jobs and dependencies
among them AND precedence constraints.
Other Types of Dependencies for Real Time
Tasks
In contrast, an OR job is one which can begin execution at or after its release
time provided one or some of its immediate predecessors has been completed.
Conditional Branches:
In the classical model, all the immediate successors of a job must be executed,
an outgoing edge from every vertex expresses an AND constraints.
This convention makes it inconvenient to represent conditional execution of
jobs.
Functional Parameters
Functional parameters are preemptivity, criticality, optional interval, and laxity
type.
Preemptivity of Jobs:
A job is preemptable if its execution can be suspended at any time to allow the
execution of other jobs and later on, can be resumed from the point of
suspension.
A job is nonpreemtable if it must be executed from start to completion without
interruption.
Criticality of Jobs:
In any system, jobs are not equally important.
The importance of a job is a positive number that indicates how critical the job
is with respect to other jobs.
Functional Parameters
The more the critical job is, the larger is the importance.
The term priority and weight are often used to refer to importance, the more
importance a job, the higher its priority or the larger it weight.
Optional Executions:
It is often possible to structure an application so that some jobs or portions of
jobs are optional.
If an optional job or a portion of a job completes late or is not executed at all,
the system performance may degrade but nevertheless function satisfactorily.
In contrast, jobs and portions of jobs that are not optional are mandatory.
Functional Parameters
Resource Graph:
The configuration of the resources using a resource graph.
In a resource graph, there is a vertex Ri for every processor or resource Ri in
the system.
While edges in task graphs represent different types of dependencies among
jobs, edges in a resource graph represent the relationship among resources.
Resource Parameters
Scheduling Hierarchy:
The application system is represented by a task graph f, exemplified by the
graph on the top of the diagram.
This graph gives the processor time and resource requirements of jobs, the
timing constraints of each job, and the dependencies of jobs.
Topic – 3
Real Time Tasks
Real Time Task and Task States
Real Time Task and Task States
Real Time Task and Task States
Real Time Task and Task States
Real Time Task and Task States
Types of Real Time Tasks
A real time task for which quantitative expressions of time are needed to
describe its behavior.
The quantitative expression of time usually appears in the form of a constraint
on the time at which the task produces results.
The most frequently occurring time constraint is a deadline constraint which is
used to express that a task is required to complete its results within some
deadline.
Real time tasks can be classified into the following three broad categories.
Real time task classified into either hard, soft, or firm real time task depending
on the consequences of the task missing its deadline.
Types of Real Time Tasks
It is not necessary that all task of a real time application belongs to the same
category.
It is possible that different task of real time system can belong to different
categories.
Hard Real Time Tasks
A hard real time task that is constrained to produce its results within certain
predefined time bounds.
The system is considered to have failed whenever any of it's hard real time
tasks does not produce its required result before the specified time bound.
Example 1: The robot continuously carries out a number of activities including
communication with the host system, logging all completed activities, sensing
the environment to detect any obstacle present, tracking the object of interest,
path planning, effecting next move etc.
Example 2: An Anti Missile system consists of following critical activities. It
must first detect all incoming missiles, properly position the anti missile gun,
and then fire to destroy the incoming missile before the incoming missile can do
any damage.
Hard Real Time Tasks
All these tasks are hard real time in nature and the anti Missile system would
be considered to have failed, if any of its tasks fails to complete before the
corresponding deadlines.
Applications having hard real time tasks are typically safety-critical.
Any failure of the real time task including its failure to meet the associated
deadlines would result in severe consequences.
This makes hard real time tasks extremely critical.
For hard real time tasks in practical system, the time bounds usually range
from several microseconds to a few milliseconds.
A hard real time task need to be completed within the shortest time possible,
but it is really required that the task must complete within the specified time
bound.
Firm Real Time Tasks
Every firm real time task is associated with some predefined deadline before
which it is required to produce its results.
Unlike hard real time task, even when a firm real time task does not complete
within its deadline, the system does not fail.
The late results are merely discarded.
The utility of these results computed by a firm real time task becomes zero
after the deadline.
Firm real time task typically found in multimedia applications.
Example 1: Video Conferencing – Video and audio are converted into packets,
these packets may travel from same or separate route through the network, and
also some of these packets may get delayed. These late incoming packets are
simply discarded and no processing would be done during live streaming.
Firm Real Time Tasks
Soft real time tasks also have time bounds associated with them.
Unlike hard and firm real time tasks, the timing constraints on soft real time
tasks are not expressed as absolute values.
Instead, the constraints are expressed either in terms of average response
times required.
Example 1: Web Browsing – Normally after an URL is clicked, the
corresponding webpage is fetched and displayed within a couple of seconds on
the average. When it takes several minutes to display a requested page, we still
do not consider the system to have failed, but merely express that the
performance of the system has degraded.
Soft Real Time Tasks
By analyzing the impact of the failure of a soft real time task to meet its
deadline.
Missed deadlines of soft real time tasks do not result in system failure.
The utility of the results produced by soft real time task falls continuously with
time after expiry of the deadline.
The utility of the results produced are 100% if produced before the deadlines.
After the deadline is passed the utility of the results slowly falls off with time.
For soft real time tasks that typically occur in practical applications, the time
bounds usually range from a fraction of a second to a few seconds.
Unit – IV
Real Time Operating
System – RTOS
Topic – 4
Real Time Scheduling
Precedence Constraints and Data Dependency
Data and control dependencies among jobs may constrain the order in which
they can execute.
In classical scheduling theory, the jobs are said to have precedence constraints
if they are constrained to execute in some order.
Otherwise, if the jobs can execute in any order, they are said to be independent.
Example, we consider queries to an information server. Suppose that before
each query is processed and the requested information retrieved, its
authorization to access the requested information is first checked. The retrieval
job cannot begin execution until the authentication job completes. The
communication job that forwards the information to the requester cannot begin
until the retrieval job completes.
Precedence Constraints and Data Dependency
Scheduling is the method by which tasks are given access to system resources
and the need for a scheduling algorithms arises from the requirement for most
modern systems to perform multitasking.
Scheduling is the heart of any computer system since it contain decision of
giving resources between possible tasks.
Sharing of computer resources between multiple tasks is also called as
scheduling.
Optimum resource sharing depends on the efficient scheduling of competing
users and system tasks for the processor, which renders task scheduling, an
important aspect of a multiprogramming operating system.
Criterion for Comparing CPU Scheduling
Algorithms
CPU Utilization: Percent of time that the CPU is busy executing a task.
Throughput: Number of tasks that are completed per unit time.
Response Time: Amount of time it takes from when a request was submitted
until the first response occurs.
Waiting Time: The amount of time before a task starts after first entering the
ready queue.
Turnaround Time: Amount of time to execute a particular task from the time
of submission through the time of completion.
Fairness: Make sure each process gets a fair share of the CPU. It is desirable to
Maximize CPU utilization, Maximize throughput, Minimize turnaround time,
Minimize waiting time, Minimize response time.
Types of Scheduling
A hard real time system must execute a set of concurrent real time tasks in a
such a way that all time critical tasks meet their specified deadlines.
Every task needs computational and data resources to complete the job.
The scheduling problem is concerned with the allocation of the resources to
satisfy the timing constraints.
Real Time Scheduling
Jobs that are ready for execution are placed in a priority queue common to all
processors.
When a processor is available, the job at the head of the queue executes on the
processor.
A multiprocessor system is a dynamic system, because jobs are dynamically
dispatched to processors.
Another approach to scheduling in multiprocessor and distributed systems is
to partition the jobs in the subsystem and assign and bind the subsystem
statically to the processors.
Jobs are moved among processors only when the system must be reconfigured,
when the operation mode of the system changes or processor fails.
Dynamic v/s Static System
If the scheduler makes each scheduling decision without knowledge about the
jobs that will be released in the future is called as online scheduling algorithm.
The parameter of each job become known to the online scheduler only after
the job is released.
Online scheduling is the only option in a system whose future workload is
unpredictable.
Online scheduler can accommodate dynamic variation in user demands and
resource availability.
Scheduling Sporadic Jobs in Priority Driven Systems
Sporadic jobs may arrive at any instant.
Their execution times may vary widely, and their deadlines are arbitrary.
It is impossible for some sporadic jobs to meet their deadlines no matter what
algorithm use to schedule them.
The only alternatives are,
1. To reject the sporadic jobs that cannot complete in time.
2. To accept all sporadic jobs and allow some of them to complete late.
The ready periodic jobs are placed in the periodic task queue, ordered by their
priorities.
Each accepted sporadic job is assigned a priority and is placed in a priority
queue.
Each newly arrived a periodic job is placed in the periodic job queue.
Scheduling Sporadic Jobs in Priority Driven Systems
Newly arrived sporadic jobs are inserted into a waiting queue.
The periodic job and sporadic job scheduling algorithms are solutions to the
following problems,
1. Based on the execution time and deadline of each newly arrived sporadic
job, the scheduler decides whether to accept or reject the job. If it accepts
the job, it schedules the job so that the job completes in time without
causing periodic tasks and previously accepted sporadic jobs to miss their
deadlines. The problem are how to do the acceptance test and how to
schedule the accepted sporadic jobs.
2. The scheduler tries to complete each periodic job as soon as possible. The
problem is how to do so without causing periodic tasks and accepted
sporadic jobs to miss their deadlines.