Real Time Operating System
(RTOS)
Unit – I
Introduction
Real Time Operating System
(RTOS)
OS Services
Process Management
Timer Functions
Event Functions
Memory Management
Device, File and IO Systems Management
Interrupt Routines in RTOS Environment
Handling of Interrupt Source Calls
Real-Time Operating Systems
Basic Design Using an RTOS
RTOS Task Scheduling Models
Interrupt Latency and Response of the Tasks as Performance Metrics
OS Security Issues
Operating System Services in
RTOS
Definition, Importance, and Types of
Services
Definition of Operating System
Services
• OS services provide essential functionalities to
manage hardware and software resources.
• They serve as an interface between
applications and the hardware.
• Enable efficient, secure, and reliable operation
of computing systems.
Importance in Real-Time Systems
• Ensures timely and predictable responses to
external events.
• Facilitates task synchronization and resource
sharing.
• Supports task prioritization and deadline
enforcement.
• Critical for real-time applications like robotics
and industrial control.
Types of Services Provided
• Process/Task Management
• Timer Services
• Memory Management
• Device and I/O Management
• Inter-Process Communication (IPC)
• Interrupt Handling
What is Operating System ?
An operating system is a program that acts as an interface between
the user and the computer hardware and controls the execution of
all kinds of programs.
Structure of Operating System:
Application Programs
System Programs
Software (Operating
System)
HARDWARE
Structure of Operating System:
The structure of OS consists of 4 layers:
1.Hardware
Hardware consists of CPU, Main memory, I/O Devices, etc,
2.Software (Operating System)
Software includes process management routines,
memory management routines, I/O control routines,
file management routines.
3.System programs
This layer consists of compilers, Assemblers, linker etc.
4.Application programs
This is dependent on users need.
Ex. Railway reservation system, Bank database management etc.,
Goals / Function of Operating system
Following are some of important functions of an operating
System.
Execute user programs and make solving user problems easier.
Make the computer system convenient to use.
Use the computer hardware in an efficient manner.
Memory Management
Processor Management
Device Management
File Management
Security
Control over system performance
Job accounting
Error detecting aids
Why Operating system is
needed?
To run one single program is easy
To run Two, or three program is called fine handling,
but more than five would be difficult
you need to take care
memory areas
Program counters
Scheduling, run one instruction each?
....
Communication/synchronization
Device drivers
OS is nothing but a program offering the functions needed in
all applications
Operating System handles
• Memory Addressing & Management
• Interrupt & Exception Handling
• Process & Task Management
• File System
• Timing
• Process Scheduling & Synchronization
Examples of Operating Systems
• RTOS – Real-Time Operating System
• Single-user, Single-task: example PalmOS
• Single-user, Multi-task: MS Windows and MacOS
• Multi-user, Multi-task: UNIX
What OS provides?
Kernel with Hardware Abstraction Application developers need
Hardware Abstraction not know about the underlying hardware.
Layer & I/O
Management
Scheduling Proper Scheduling ensures an efficient usage
of
resources
Process User Programs can be protected from each other
Management
Inter Application can communicate with each other
Process with
Communication ease
File Management Faster Storage and Retrieval of Data
POSIX and Portability
other
compliance
Subsystem
"Portable Operating System Interface for uni-
What OS provides?
Types of Services Provided
Process/Task Management
Timer Services
Memory Management
Device and I/O Management
Inter-Process Communication (IPC)
Interrupt Handling
Process/Task Management
Handles creation, deletion, and management
of processes or tasks.
Enables scheduling and switching between
tasks.
Ensures real-time constraints are met with
task prioritization.
Timer Services
Provides delay functions, timeouts, and
periodic task execution.
Essential for real-time task scheduling and
system clocks.
Helps in generating accurate time-based
events.
Memory Management
Manages allocation and deallocation of
memory.
Prevents fragmentation and ensures memory
protection.
Provides deterministic memory usage in real-
time systems.
Device and I/O Management
Manages communication with hardware
devices.
Supports buffering, polling, and interrupt-
driven I/O.
Ensures reliable and efficient device handling
in real-time.
Inter-Process Communication (IPC)
Mechanisms for data exchange between
tasks/processes.
Includes message queues, semaphores,
shared memory.
Ensures synchronization and mutual
exclusion.
Interrupt Handling
Detects and responds to hardware/software
interrupt signals.
Ensures minimal latency and quick response
to events.
Supports nested interrupts and priority-based
handling.
Memory Management
Memory management refers to management of Primary Memory or
Main Memory. Main memory is a large array of words or bytes
where each word or byte has its own address. Main memory
provides a fast storage that can be access directly by the CPU. So for
a program to be executed, it must in the main memory.
Operating System does the following activities for memory
management.
Keeps tracks of primary memory i.e. what part of it are in use by
whom, what part are not in use.
In multiprogramming, OS decides which process will get
memory when and how much.
Allocates the memory when the process requests it to do so.
De-allocates the memory when the process no longer needs it or
has been terminated.
Processor Management
In multiprogramming environment, OS decides which process gets
the processor when and how much time. This function is called
process scheduling.
Operating System does the following activities for processor
management.
Keeps tracks of processor and status of process.
Program responsible for this task is known as traffic controller.
Allocates the processor (CPU) to a process.
De-allocates processor when processor is no longer required.
Device Management
OS manages device communication via their respective drivers.
Operating System does the following activities for device
management.
Keeps tracks of all devices.
Program responsible for this task is known as the I/O controller.
Decides which process gets the device when and for how much time.
Allocates the device in the efficient way.
De-allocates devices.
File Management
A file system is normally organized into directories for easy
navigation and usage. These directories may contain files and other
directions.
Operating System does the following activities for file management.
Keeps track of information, location, uses, status etc. The collective
facilities are often known as file system.
Decides who gets the resources.
Allocates the resources.
De-allocates the resources.
Other Important Activities
Following are some of the important activities that Operating
System does:
Security: By means of password and similar other techniques,
preventing unauthorized access to programs and data.
Control over system performance: Recording delays between request
for a service and response from the system.
Job accounting: Keeping track of time and resources used by various
jobs and users.
Error detecting aids: Production of dumps, traces, error messages and
other debugging and error detecting aids.
Coordination between other software and users: Coordination and
assignment of compilers, interpreters, assemblers and other software to the
various users of the computer systems.
1. Batch operating system
2. Time-sharing operating systems
3. Distributed operating System
4. Network operating System
5. Real Time operating System
Batch operating system
1. The users of batch operating system do not interact with the
computer directly.
2. Each user prepares his job on an off-line device like punch cards
and submits it to the computer operator.
3. To speed up processing, jobs with similar needs are batched
together and run as a group. Thus, the programmers left their
programs with the operator.
4. The operator then sorts programs into batches with similar
requirements.
The problems with Batch Systems are following
1. Lack of interaction between the user and job.
2. CPU is often idle, because the speeds of the mechanical I/O
devices are slower than CPU.
3. Difficult to provide the desired priority.
Time-sharing operating systems
1. Time sharing is a technique which enables many people, located at
various terminals, to use a particular computer system at the same
time.
2. Time-sharing or multitasking is a logical extension of
multiprogramming.
3. Processor's time which is shared among multiple users
simultaneously is termed as time-sharing.
4. The main difference between Multiprogrammed Batch Systems
and Time-Sharing Systems is :
in case of multiprogrammed batch systems, objective is to
maximize processor use, whereas
in Time- Sharing Systems objective is to minimize
response time.
1. Multiple jobs are executed by the CPU by switching between them,
but the switches occur so frequently. Thus, the user can receive
an immediate response.
2. For example, in a transaction processing, processor execute each
user program in a short burst or quantum of computation.
3. That is if n users are present, each user can get time quantum.
When the user submits the command, the response time is in few
seconds at most.
4. Operating system uses CPU scheduling and multiprogramming to
provide each user with a small portion of a time.
5. Computer systems that were designed primarily as batch systems
have been modified to time-sharing systems.
Advantages of Timesharing operating systems
1. Provide advantage of quick response.
2. Avoids duplication of software.
3. Reduces CPU idle time.
Disadvantages of Timesharing operating systems
1. Problem of reliability.
2. Question of security and integrity of user programs and data.
3. Problem of data communication.
Distributed operating System
1. Distributed systems use multiple central processors to serve
multiple real time application and multiple users.
2. Data processing jobs are distributed among the processors
accordingly to which one can perform each job most efficiently.
3. The processors communicate with one another through various
communication lines (such as high-speed buses or telephone lines).
4. These are referred as loosely coupled systems or distributed
systems.
5. Processors in a distributed system may vary in size and function.
6. These processors are referred as sites, nodes, and computers and
so on.
The advantages of distributed systems
1.With resource sharing facility user at one site may be able to use the
resources available at another.
2.Speedup the exchange of data with one another via electronic mail.
3.If one site fails in a distributed system, the remaining sites can
potentially continue operating.
4.Better service to the customers.
5.Reduction of the load on the host computer.
6.Reduction of delays in data processing.
Network operating System
1. Network Operating System runs on a server and and provides
server the capability to manage data, users, groups, security,
applications, and other networking functions.
2. The primary purpose of the network operating system is to allow
shared file and printer access among multiple computers in
a network, typically a local area network (LAN), a private
network or to other networks.
Examples of network operating systems are
1. Microsoft Windows Server 2003
2. Microsoft Windows Server 2008
3. UNIX
4. Linux
5. Mac OS X
6. Novell NetWare, and BSD.
The advantages of network operating systems
1. Centralized servers are highly stable.
2. Security is server managed.
3. Upgrades to new technologies hardware can be easily
integrated into the system.
and
4. Remote access to serversis possible from different
locations and types of systems.
The disadvantages of network operating systems
1.High cost of buying and running a server.
2.Dependency on a central location for most operations.
3.Regular maintenance and updates are required.
Real Time operating System
Those systems in which the correctness of the system depends not only on the
logical result of computation, but also on the time at which the results are
produced.
A real time system is a system/that ensures the exact time requirements for a
job.
1.Real time system is defines as a data processing system in which the time
interval required to process and respond to inputs is so small that it controls the
environment.
2.Real time processing is always on line whereas on line system need not be real
time.
3.The time taken by the system to respond to an input and display of required
updated information is termed as response time. So in this method response time
is very less as compared to the online processing.
Uses of Real Time operating System
Real-time systems are used
1. when there are rigid time requirements on the operation of a
processor or the flow of data and real-time systems can be used as a
control device in a dedicated application.
2. Real-time operating system has well-defined, fixed
timeconstraints otherwise system will
fail.
1. For
Scientific
example Experiments
2. Medical Imaging Systems FAX
3. Industrial Control Systems machines
4. Weapon Systems Copiers
5. Robots
Printers
6. Home-appliance Controllers
7. Air Traffic Control System Scanners
Etc. Routers
8. Industrial control systems Robots
10. Engine
9. Food processing
Controls
Compare Desktop and Real Time operating System
Operating systems come in two flavors
real-time versus non real-time
The difference between the two is characterized by the
consequences which result if functional correctness and timing
parameters are not met in the case of real-time operating systems
1.The main difference between them is the task manager, which is composed by
the Dispatcher and the Scheduler.
2.Like a non-RTOS, a RTOS provides support for multi-tasking with multiple
threads and inter-task communication and synchronization mechanisms such as
semaphores, shared memory, pipes, mailboxes, etc…
3.In RTOS synchronization is of an even greater importance in order to avoid
blocking of shared resources and to guarantee that the tasks are preformed in the
correct order when necessary.
Characteristics of a Embedded Real Time
system:
Deadline driven.
Process the events in a deterministic time.
Have limited resources.
Soft versus Hard Real-
Time
In a soft real-time system, tasks are completed as fast as possible
without having to be completed within a specified timeframe.
In a hard real-time operating system however, not only must
tasks be completed within the specified timeframe, but they must
also be completed correctly.
Hard real time
1. Hard real time means strict about adherence to each task
deadline.
2. When an event occurs, it should be serviced within the
predictable time at all times in a given hard real time system.
3. The preemption period for the hard real time task in worst
case should be less than a Few micro seconds.
4. A hard RT RTOS is one, which has predictable performance
with no deadline miss, even in case of sporadic tasks
(sudden bursts of occurrence of events requiring attention).
5. Automobile engine control system and antilock brake are the
examples of hard real time systems
Hard real time system design
1. Disabling of all other interrupts of lower priority when running
the hard real time tasks
2. Preemption of higher priority task by lower priority tasks
3. Some critical code in assembly to meet the real time constraint
(deadline) fast
4. Task running in kernel space, [This saves the time required to
first check whether access is outside the memory space
allocated to the kernel functions.]
5. Provision of asynchronous iOS (iPhone OS)
6. Provision of locks or spin locks
1. Predictions of interrupt latencies and context switching latencies
of the tasks
2. Predictability is achieved by writing all functions which execute
always take the same predefined time intervals in case of varying
rates of occurrences of the events.
3. Response in all the time slots for the given events in the system
and thus providing the guaranteed task deadlines even in case
of sporadic and aperiodic tasks.
4. Sporadic tasks means tasks executed on the sudden-bursts of
the corresponding events at high rates, and
5. Aperiodic tasks mean task having no definite period of event
occurrence.
Video transmission, each picture frame and audio must
be transferred at fixed rate
Example of hard real time system
Soft real time system
1. One in which deadlines are mostly met.
2. Soft real time means that only the precedence and sequence for
the task operations are defined, interrupt latencies and context
switching latencies are small but there can be few deviations
between expected latencies of the tasks and observed time
constraints and a few deadline misses are accepted
Soft real time task
1. The preemption period for the soft real time task in worst case
may be about a few ms.
2. Mobile phone, digital cameras and orchestra playing robots
are
OPEN SOURCE RTOS / Embedded OS
NAME DESRIPTION
RTOS
Linux This is the primary site for the Linux kernel source
eCos eCos is provided as an open source runtime system supported by the GNU open
source development tools. Currently eCos supports ten different target
architectures (ARM, Hitachi H8300, Intel x86, MIPS, Matsushita AM3x,
Motorola 68k, PowerPC, SuperH, SPARC and NEC V8xx) including many of the
popular variants of these architectures and evaluation boards.
uClinux MMU Less version of Linux. Support ARM, Coldfire etc processor.
FreeRTOS FreeRTOS.org TM is a portable, open source, mini Real Time Kernel - a free to
download and royalty free RTOS that can be used in commercial applications
Support 17 architectures. ARM, AVR32, MSP430 etc.
RTAI The RealTime Application Interface for Linux. It support following architecture
… x86, PowerPC, ARM
coscox An embedded real-time multi-task OS specially for ARM Cortex M4, M3 and M0
chipset.
PROPERITARY RTOS / Embedded OS
NAME DESRIPTION
RTOS
QNX is real time RTOS, which support ARM, MIPS, PowerPC, SH and X86
QNX
Processor family.
Vxworks is also real time rtos, it support wide range of processor architectures
VxWorks
like ARM, PowerPC, ColdFire, MIPS etc.
INTEGRIT INTEGRITY is hard real time rtos. It support ARM, PowerPC, Coldfire,x86 etc
Y processor architectures.
ThreadX is Express Logic's advanced Real-Time Operating System (RTOS)
ThreadX designed specifically for deeply embedded applications. It support ARM,
PowerPC,X86 etc.
µC/OS-II, The Real-Time Kernel is a highly portable, ROMable, very scalable,
MicroC/OS2 preemptive real-time, multitasking kernel (RTOS) for microprocessors and
microcontrollers. It support ARM, PowerPC,X86 etc.
embOS is a priority-controlled multitasking system, designed to be used as an
embOS embedded operating system for the development of real time applications for a
variety of microcontrollers.
Real Time OS for mission critical applications based on the FreeRTOS
SafeRTOS
scheduling algorithm, certified for IEC61508 SIL3, FDA 510K or DO-178B.
RTOS Kernel
RTOS Kernel provides an Abstraction layer that hides from application software the hardware
details of the processor / set of processors upon which the application software shall run.
1. The central component of most Operating systems is
called Kernel.
Application Software 2. The kernel manages system's resources and the
communication
3. The kernel provides the most basic interface between
the computer itself and the rest of the operating
RTO system.
S 4. The kernel is responsible for the management of
the central processor.
5. The kernel includes the dispatcher to allocate the
Hardware central processor, to determine the cause of an
interrupt and initiate its processing, and some
provision for communication among the various
system and user tasks currently active in the system.
6. Kernel is the core of an operating system.
Basic functions of RTOS kernel
1. Task management
2. Task synchronization
• Avoid priority inversion
3. Task scheduling
4. Interrupt handling
5. Memory management
• no virtual memory for hard RT
tasks
6. Exception handling (important)