You are on page 1of 34

RTOS

Design & Implementation

Swetanka Kumar Mishra & Kirti Chawla


Introduction
• Introduction
• Structure of RTOS
 A variant of OS that operates in
• Components of RTOS constrained environment in which
• RTOS Kernel computer memory and processing
• Tasks power is limited. Moreover they often
• Memory
• Timers
need to provide their services in
• I/O
definite amount of time.
• IPCs  Hard, Soft & Firm RTOS
• Device Drivers
• Expectations
 Example RTOS: VxWorks, pSOS,
• Examples Nucleus, RTLinux…
Structure of a RTOS
• Introduction
• Structure of RTOS
• Components of RTOS Applications
• RTOS Kernel
• Tasks
• Memory
• Timers
• I/O
• IPCs RTOS-kernel
• Device Drivers BSP
• Expectations
• Examples

Custom-Hardware
Components of RTOS
• Introduction
• Structure of RTOS  The most important
• Components of RTOS
• RTOS Kernel
component of RTOS is its
• Tasks kernel (Monolithic & Microkernel).
• Memory
• Timers  BSP or Board Support
• I/O
Package makes an RTOS
• IPCs
• Device Drivers target-specific (It’s a processor specific
• Expectations code onto (processor) which we like to have our
• Examples RTOS running ).
RTOS KERNEL
• Introduction
• Structure of RTOS
• Components of RTOS
• RTOS Kernel
• Tasks
• Memory
• Timers
• I/O
• IPCs
• Device Drivers
• Expectations
• Examples
RTOS KERNEL: Tasks(1)
• Introduction
• Structure of RTOS  A task is basic unit of
• Components of RTOS
• RTOS Kernel
execution in RTOS.
• Tasks
 RTOS scheduler needs to be
• Memory
• Timers deterministic ~ O(1) or O(n).
• I/O
• IPCs
Scheduling policies that are
• Device Drivers available in a RTOS are:
• Expectations
• Examples  Clock driven
 Priority driven (RMS & EDF)
RTOS KERNEL: Tasks(2)
• Introduction
TID
• Structure of RTOS
• Components of RTOS
SAVED_TASK_STATE
• RTOS Kernel
• Tasks
Resource 1 (signals)
• Memory
• Timers Resource 2 (events)
• I/O
• IPCs Resource 3 (shared memory)
• Device Drivers
• Expectations .
• Examples .

System Variables

Task Control Block


RTOS KERNEL: Tasks(3)
• Introduction
• Structure of RTOS
• Components of RTOS
• RTOS Kernel
• Tasks
• Memory
• Timers
• I/O
• IPCs
• Device Drivers
• Expectations
• Examples
RTOS KERNEL: Tasks(4)
• Introduction
• Structure of RTOS
• Components of RTOS
• RTOS Kernel
• Tasks
• Memory
• Timers
• I/O
• IPCs
• Device Drivers
• Expectations
• Examples
RTOS KERNEL: Tasks(5)
• Introduction
• Structure of RTOS
• Components of RTOS
• RTOS Kernel
• Tasks
RMS, EDF
• Memory
• Timers
• I/O
• IPCs
• Device Drivers
• Expectations
• Examples
RTOS KERNEL: Tasks(6)
• Introduction
• Structure of RTOS  XXX_CreateTask
• Components of RTOS
• RTOS Kernel  XXX_AddtoProcessQueue
• Tasks
• Memory
 XXX_ChangePriority
• Timers
 XXX_KillTask
• I/O
• IPCs  XXX_CreateTaskQueues
• Device Drivers
• Expectations …
• Examples
RTOS KERNEL: Memory(1)
• Introduction
• Structure of RTOS  Memory is premium in
• Components of RTOS
• RTOS Kernel
environments where RTOS
• Tasks work.
• Memory
• Timers  Supports Virtual Memory
• I/O
(MMU) and Memory
• IPCs
• Device Drivers Protection (MPU) models.
• Expectations
• Examples
 User space and Kernel space
memory.
RTOS KERNEL: Memory(2)
• Introduction
Physical Address M Virtual Address
• Structure of RTOS
• Components of RTOS
• RTOS Kernel PHY1 VIRT1
• Tasks
PHY2 VIRT2
• Memory
• Timers
PHY3 VIRT3
• I/O PHY4 VIRT4
• IPCs .
• Device Drivers .
• Expectations
.
.
• Examples
.

Virtual Memory Concept


RTOS KERNEL: Memory(3)
• Introduction
• Structure of RTOS
• Components of RTOS
• RTOS Kernel
• Tasks
• Memory
• Timers
• I/O
• IPCs
• Device Drivers
• Expectations
• Examples

Virtual Memory Concept


RTOS KERNEL: Memory(4)
• Introduction Participation of User space programs with kernel for
• Structure of RTOS services and as a central pool of memory for
specialized applications.
• Components of RTOS
• RTOS Kernel
• Tasks
• Memory User Space memory
• Timers P1 P2
• I/O
• IPCs
• Device Drivers
• Expectations
• Examples M1 M2
Kernel Space Memory
RTOS KERNEL: Memory(5)
• Introduction
• Structure of RTOS
 XXX_Kmap
• Components of RTOS
 XXX_PassToUserSpace
• RTOS Kernel
• Tasks
 XXX_Mmap
• Memory
• Timers  XXX_PurgeMemory/Kfree
• I/O
• IPCs  XXX_Kmalloc
• Device Drivers
• Expectations …
• Examples
RTOS KERNEL: Timer(1)
• Introduction
• Structure of RTOS  Timer is software entity
• Components of RTOS
• RTOS Kernel
derived from hardware clock.
• Tasks
 Timer provides mechanism to
• Memory
• Timers introduce task-delays and/or to
• I/O
help synchronize and provide
• IPCs
• Device Drivers time off-course.
• Expectations
• Examples
 Watchdog Timers,
Programmable Timers
RTOS KERNEL: Timer(2)
• Introduction
• Structure of RTOS
• Components of RTOS
• RTOS Kernel
• Tasks
• Memory
• Timers
• I/O
• IPCs
• Device Drivers
• Expectations
• Examples
RTOS KERNEL: Timer(3)
• Introduction
• Structure of RTOS  Based upon these hardware-
• Components of RTOS
• RTOS Kernel
programmable timers, RTOS
• Tasks kernel can use to create
• Memory
• Timers
software structures of timers
• I/O associated with tasks.
• IPCs
• Device Drivers  Scheduling, Synchronization,
• Expectations
• Examples
time-stamping…
RTOS KERNEL: Timer(4)
• Introduction
• Structure of RTOS  XXX_SetTimer
• Components of RTOS
• RTOS Kernel  XXX_AddtoTimerQueue
• Tasks
• Memory
 XXX_isExpired
• Timers
 XXX_RunAtExpiry
• I/O
• IPCs  XXX_PurgeTimerQueue
• Device Drivers
• Expectations …
• Examples
RTOS KERNEL: I/O(1)
• Introduction
• Structure of RTOS  I/O is slow as compared to
• Components of RTOS
• RTOS Kernel
CPU.
• Tasks
 I/O: Interrupt-driven, Polling,
• Memory
• Timers DMA.
• I/O
• IPCs
 I/O map: Memory Space & IO
• Device Drivers Space.
• Expectations
• Examples
RTOS KERNEL: I/O(2)
• Introduction
• Structure of RTOS
• Components of RTOS
• RTOS Kernel
• Tasks
• Memory
• Timers
• I/O
• IPCs
• Device Drivers
• Expectations
• Examples
RTOS KERNEL: I/O(3)
• Introduction
• Structure of RTOS
• Components of RTOS
• RTOS Kernel
• Tasks
• Memory
• Timers
• I/O
• IPCs
• Device Drivers
• Expectations
• Examples
RTOS KERNEL: I/O(4)
• Introduction DMA driven I/O
• Structure of RTOS
• Components of RTOS
• RTOS Kernel
• Tasks
• Memory
• Timers
• I/O
• IPCs
• Device Drivers
• Expectations
• Examples
RTOS KERNEL: I/O(5)
• Introduction
• Structure of RTOS
 XXX_IORead/IOWrite
• Components of RTOS
 XXX_IOMap/Unmap
• RTOS Kernel
• Tasks
 XXX_BindInterrupt
• Memory
• Timers …
• I/O
• IPCs
• Device Drivers
• Expectations
• Examples
RTOS KERNEL:
Inter-process Communication(1)
• Introduction
• Structure of RTOS  Most of the time tasks cannot
• Components of RTOS
• RTOS Kernel
run in isolation. They require
• Tasks to talk to each other.
• Memory
• Timers  Synchronization, Protection
• I/O
and Sharing are goals of IPC.
• IPCs
• Device Drivers
• Expectations
• Examples
RTOS KERNEL:
Inter-process Communication(2)
• Introduction
• Structure of RTOS
• Components of RTOS
• RTOS Kernel  Semaphores
• Tasks (Binary, Mutual)
• Memory  Message Queues
• Timers
 Pipes/Named
• I/O
Pipes
• IPCs
• Device Drivers  Shared Memory
• Expectations  Signals/Slots
• Examples  Mail slots
 Sockets/XTI …
RTOS KERNEL:
Inter-process Communication(3)
• Introduction
• Structure of RTOS  A common
• Components of RTOS
• RTOS Kernel
shared data-
• Tasks structure
• Memory residing in
• Timers
• I/O
kernel or user
• IPCs space.
• Device Drivers
• Expectations
 Mechanism to
• Examples access it.
RTOS KERNEL:
Device Drivers(1)
• Introduction
• Structure of RTOS  A piece of software that enables
• Components of RTOS devices connected to particular
• RTOS Kernel
• Tasks
processor, via various
• Memory interfaces.
• Timers
 Controls, manages and
• I/O
• IPCs
configures devices connected to
• Device Drivers system.
• Expectations
• Examples
RTOS KERNEL:
Device Drivers(2)
• Introduction
• Structure of RTOS
• Components of RTOS Client Drivers
• RTOS Kernel
• Tasks
• Memory
• Timers Protocol Layers
• I/O
• IPCs
• Device Drivers
• Expectations Host Controller Drivers
• Examples

Hardware
RTOS KERNEL:
Device Drivers(3)
• Introduction
• Structure of RTOS  A host controller driver enables
• Components of RTOS system to accept a particular type of
• RTOS Kernel
• Tasks
device.
• Memory  Client drivers are device specific.
• Timers
• I/O
 Protocol layer converts device
• IPCs request to form that is understood
• Device Drivers
by corresponding host controllers
• Expectations
• Examples
through their drivers.
Expectations from RTOS
• Introduction
• Structure of RTOS  Deadline-driven
• Components of RTOS
• RTOS Kernel  Work with Dearth of Resources
• Tasks
• Memory
 Intricate I/O interfaces (Touch
• Timers panels, Push buttons …)
• I/O
• IPCs  Fail-safe and Robust
• Device Drivers
• Expectations  Availability
• Examples
An Example RTOS
• Introduction
• Structure of RTOS
• Components of RTOS
• RTOS Kernel
• Tasks
• Memory
• Timers
• I/O
• IPCs
• Device Drivers
• Expectations
• Examples

EMERALDS architecture
Relevant books and
websites
 http://www.intelinfo.com/it_training_materials_and_books/free_real_time_o
perating_systems_training_materials.html
 Linux Device Drivers – Alexander Rubini, Oreilly publications
 http://www.ddjembedded.com : Dr. Dobb’s Journal
 http://www.embedded.com

Some RTOS based Embedded Systems


 http://www.ll.mit.edu/HPEC/agendas/proc02/abstracts/ahlander.pdf
 http://www.cs.berkeley.edu/~culler/cs294-f03/papers/emeralds.pdf

You might also like