Real Time Operating System
Real Time Operating System
B R K SINGH
1
Generation Era O/S used Feature
3
Operating systems market share
S.No Operating Market share
system
1 Windows XP 81.94%
2 Windows Vista 4.52%
3 Windows 2000 4.00%
4 Mac OS 3.52%
5 MacIntel 2.48%
6 Windows 98 1.14%
7 Linux 0.71%
8 Windows NT 0.66%
9 Windows Me 0.59%
10 Ninendo Wii 0.17%
11 Other 0.20% 4
The primary functions of an
operating system
• Multiplexing the processor(s)
• Scheduling the processes
• Coordinating interaction among rocesses,interprocess
communication and Synchronization.
• Managing the system resources(I/O, memory,data files)
• Enforcing access control and protection
• Maintaining the system integrity and performing error
recovery
• Providing an interface to the users
5
Examples of computing devices
which use OS
• Computers
• Mobile phones
• 3d televisions
• Video game
• ATM
• Ticket Wending Machine
Examples of computing devices
which use don’t OS
• Speed meters.
• Digital Watches.
• Micro ovens.
• Washing machines.
• Calculators.
Components of OS
Process Management
Memory management
I/O Device management
File system
Protection
Network management
Network services
User Interface
TYPES OF OPERATING SYSTEMS
9
Stand-Alone Operating system
10
Desktop Operating System
Network Operating systems
• It is an operating system that provides extensive
support for computer networks. A network
operating system typically resides on a server.
Examples :
❑ Windows 2000 server
❑ Unix
❑ Linux
❑ Solaris
12
Embedded Operating system
13
• Commercial RTOSes
• LynxOS,
• VxWorks,
• pSoS,
• Spring,
• ARTS,
• MARS(Maintainable Real-Time System)
14
Other RTOS’s
• 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
15
RTLinux
• This OS was developed by FSM
Labs(www.fsmlabs.com) and available in two
versions RTLinux Pro and RTLinuxFree.
• The RTLinux Pro is the priced edition and
RTLinux Free is the free open source release.
• RTLinux is a hard real-time operating system
with support for many processors such as
x86,Pentium,PowerPC,ARM,Fujitsu,MIPS and
Alpha
• It does not support priority inheritance.
16
• LynxOS is mostly used in real-time
embedded systems, in applications for
avionics, aerospace, the military, industrial
process control and telecommunications.
• Enea OSE is one of the most widely used
RTOSes in the world. According to mobile
analyst firm, VisionMobile, OSE has been
deployed in over 1.75 billion mobile
handsets, as of the end of June 2010. Enea
OSE is shipped in hundreds of millions of
mobile phones each year and over half of
the worlds 3G base stations
17
MicroC/OS-II
• Microcontroller operating system version –II
is developed by Jean
J.Labrosse(www.ucos-II.com)is a preemptive
real-time operating system which is popular
in academic institutions for teaching RTOS
concepts.
• It can support only 64 tasks out of which
eight are system tasks
• Round-robin scheduling algorithm is not
supported by this OS
18
Other RTOS’s
• VxWorks
– Monolithic Architecture
– Real Time Posix compliant
– Cross development System
• pSOS
– Object Oriented OS
19
Real Time System
20
How RTOS is different from OS
• The key difference between
general-computing operating systems and
real-time operating systems is the need for "
deterministic " timing behaviour,
general-computing non-real-time operating
systems are often quite non-deterministicII.
21
• Real-time operating systems are often uses
in embedded solutions, that is, computing
platforms that are within another device.
While real-time operating systems are
typically designed for and used with
embedded systems.
22
Hard and Soft Real Time Systems
• Hard Real Time System
– Failure to meet deadlines is fatal
– example : Flight Control System
• Soft Real Time System
– Late completion of jobs is undesirable but not fatal.
– System performance degrades as more & more jobs
miss deadlines
– Online Databases
23
Classification of RTOS Kernels
• RT kernels vs modified kernels of standard OS
– Fast proprietary kernels: may be inadequate for
complex systems, because they are designed to
be fast rather than to be predictable in every
respect, e.g., QNX, PDOS, VCOS, VTRX32,
VxWORKS
– RT extensions to standard OS: RT-kernel runs
all RT-tasks and standard-OS executed as one
task on it
• General RTOS vs RTOS for specific domains
• Standard APIs vs proprietary APIs
24
– e.g. POSIX RT-Extension of Unix,Source:
ITRON, OSEK)
R. Gupta, UCSD
INTRODUCTION TO RTOS
• Tasks and Task States
• A task – a simple subroutine
• ES application makes calls to the RTOS functions to start tasks,
passing to the OS, start address, stack pointers, etc. of the tasks
• Task States:
– Running
– Ready (possibly: suspended, pended)
– Blocked (possibly: waiting, dormant, delayed)
– [Exit]
– Scheduler – schedules/shuffles tasks between Running and Ready
states
– Blocking is self-blocking by tasks, and moved to Running state via
other tasks’ interrupt signaling (when block-factor is
removed/satisfied)
– When a task is unblocked with a higher priority over the ‘running’
task, the scheduler ‘switches’ context immediately (for all
pre-emptive RTOSs) 25
A Sample Real Time System (1)
26
Features of RTOS’s
• Scheduling.
• Resource Allocation.
• Interrupt Handling.
kernel
29
Characteristics of Embedded OS
• Real-time capability
– Many embedded systems are real-time (RT)
systems and, hence, the OS used in these
systems must be real-time operating systems
(RTOSs)
• Features of a RTOS:
– Allows multi-tasking
– Scheduling of the tasks with priorities
– Synchronization of the resource access
– Inter-task communication
– Time predictable
– Interrupt handling 30
Requirements for RTOS
• Predictability of timing
– The timing behavior of the OS must be
predictable
– For all services of the OS, there is an upper
bound on the execution time
– Scheduling policy must be deterministic
– The period during which interrupts are disabled
must be short (to avoid unpredictable delays in
the processing of critical events)
31
Requirements for RTOS
• OS should manage timing and scheduling
– OS possibly has to be aware of task deadlines;
(unless scheduling is done off-line).
– Frequently, the OS should provide precise time
services with high resolution.
• Important if internal processing of the embedded
system is linked to an absolute time in the physical
environment
• Speed:
– The OS must be fast 32
Programming languages Used
• C is most widely used in RTOS programming
• C++ and Ada are the next more popular for large
projects.
33
Which is the Best?
• It is always very difficult to judge which
RTOS is the best and which is the worst. It
depends on the application and interests of
the user. Among the above, Linux is royalty
free but it has serious drawbacks if it comes
to real-time behavior. The VxWorks is a
very old and stable RTOS. Similarly
Windows CE 5.0 version RTOS is a robust
and stable regarding the real-time behavior.
34
Functionality of RTOS Kernel
• Processor management resource management
• Memory management
• Timer management
• Task management (resume, wait etc)
• Inter-task communication and
synchronization
35
RTOS Kernel Functions
36
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.
Application
Software
RTOS
Hardware
37
• Type of RTOS kernel
38
What is MQX?
• Multi-threaded, priority-based RTOS
provides
– Task scheduling
– Task management
– Interrupt handling
– Task synchronization: mutexes, semaphores,
events, messages
– Memory management
– IO subsystems
– Kernel logging
39
MQX Facilities
Required
Optional
40
Message passing in RTOS
• In RTOS, the OS copies a pointer to the message,
delivers the pointer to the message-receiver task, and
then deletes the copy of the pointer with
message-sender task.
42
43
Task Scheduling
• Non Real -time systems usually use Non-preemptive
Scheduling
– Once a task starts executing, it completes its full execution
44
Scheduling in RTOS
• Running (executing on the CPU);
• Ready (ready to be executed);
• Blocked (waiting for an event, I/O for
example)
45
Scheduling Algorithms in RTOS
46
• Fixed priority pre-emptive scheduling, an
implementation of preemptive time slicing
• Fixed-Priority Scheduling with Deferred
Preemption
• Fixed-Priority Non-preemptive Scheduling
• Critical section preemptive scheduling
• Static time scheduling
• Earliest Deadline First approach
• Stochastic digraphs with multi-threaded
graph traversal
47
Scheduling Algorithms in RTOS
• 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.
48
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
49
Dynamic Memory Allocation in RTOS
50
Process & Program
• A process invokes or initiates a program. It
is an instance of a program that can be
multiple and running the same application.
• Example:- Notepad is one program and can
be opened twice.
51