Unit-Iv: Real-Time Operating Systems Based Embedded System Design
Unit-Iv: Real-Time Operating Systems Based Embedded System Design
Unit-Iv: Real-Time Operating Systems Based Embedded System Design
REAL-TIME OPERATING
SYSTEMS BASED
EMBEDDED SYSTEM
DESIGN
veera
CONTENTS
4.1. Operating systems basics
veera
4.1. Operating systems basics
The operating system acts as a bridge
between the user applications/tasks and
underlying the system resources through a set of
system functionalities and services.
The OS manages the system resources and
makes them available to the user
applications/tasks on a need basis.
A normal computing system is a collection of
different I/O subsystems, working and storage
memory.
veera
The primary functions of an operating system is
veera
OS components or Architecture
USER APPLICATIONS
MEMORY MANAGEMENT
PROCESS MANAGEMENT
TIME MANAGEMENT
HARDWAREveera
KERNEL
• Kernel is the core of the operating system and
is responsible for managing the system
resources and the communication among the
hardware and other system services
• Kernel acts as a abstraction layer between
system resources and user applications
• Kernel contains a set of system libraries and
services.
veera
For a GPOS, the kernel contain different services
for handling the following
Process management
Memory (primary and
secondary)management
File system management
I/O system(Device) management
Protection systems
Interrupt handler
veera
Process management(PM):
It deals with managing the process/tasks
PM includes setting up the memory space for
the process, loading the process’s code into
the memory, allocating system resources,
scheduling and the managing the execution of
the process, setting up and managing the
process control block(PCB), IPC and
synchronisation, Process termination/
detection etc.
veera
Primary memory management:
The term primary refers to the volatile
memory (RAM) where processes are loaded
and variables and shared data associated with
each process are stored.
The memory management unit(MMU) of the
kernel is responsible for
a) Keeping track of which part of the memory
area is currently used by which process
b) Allocating and de-allocating memory space
on a need base(Dynamic memory Allocation)
veera
File system management:
veera
The file system management service of kernel is
responsible for
The creation, deletion and alteration of files
Creation, deletion and alteration of directories
Saving of files in the secondary storage
memory
Providing automatic allocation of file space
based on the amount of free space available.
Providing a flexible naming convention for the
files
veera
I/O system management:
• Kernel is responsible for routing the I/O
request coming from different user
applications to the appropriate I/O devices of
the system.
• In a well-structured OS, the direct accessing of
I/O devices are not allowed and the access to
them are provided through a set of
Application Programming Interfaces(API)
exposed by the kernel
veera
The kernel maintains a list of all the I/O
devices of the system.
veera
The secondary storage management service of
kernel deals with
Disk scheduling
veera
Kernel space and user space
Applications/services
veera
Kernel types
Based on kernel design, kernels can be classified
into
A) monolithic kernel
B) microkernel
veera
Monolithic Kernel
In Monolithic kernel architecture, all kernel
services run in the kernel space.
Here all kernel modules run within the same
memory space under a single kernel thread
the major drawback of monolithic kernel is
that any error or failure in any one of the
kernel modules leads to the crashing of the
entire kernel application.
Ex: LINUX, SOLARIS,MS-DOS
veera
APPLICATIONS
veera
MICROKERNEL
the microkernel design incorporates only the
essential set of operating system services into the
kernel.
The rest of the operating system services are
implemented in programs known as ‘servers’
which runs in user space.
Memory management, process management,
timer systems and interrupt handlers are the
essential services. Which forms the part of
microkernel.
veera
servers(kernel services
running in the user Applications
space)
veera
4.2. Types operating systems
veera
4.2(i) GPOS
• The operating systems, which are deployed in
general computing systems, are referred as
GPOS
• The kernel of such an OS is more generalised
and it contains all kinds of services required
for executing generic applications
• GPOS are often quite non-deterministic in
behaviour
veera
• Their services can inject random delays into
application software and may cause slow
responsiveness of an application at
unexpected times
a) Real-time kernel
b) Hard real-time
c) Soft real-time
veera
a) Real-time kernel
• The kernel of a RTOS is referred as Real-time kernel.
• it is highly specialised and it contains only the minimal
set of services required for running the user
applications/tasks
i) Task/Process management
ii) Task/Process scheduling
iii) Task/Process synchronisation
iv) Error/Exception handling
v) Memory management
vi) Interrupt handling
vii) Time management
veera
Task/Process management
• Deals with setting up the memory space for
the tasks, loading the task’s code into the
memory space, allocating system resources,
setting up a task control block(TCB) for the
task and task/process termination/deletion.
veera
• TCB usually contains the following set of
information
TASK ID: task identifier number
TASK STATE: the current state of the task
TASK TYPE: task type. Indicates what is the
type for this task. the task can be a hard real
time or soft real time or background task
TASK PRIORITY: task priority( EX: Task
priority=1 for task with priority=1)
TASK CONTEXT POINTER: context pointer.
Pointer of context saving.
veera
• TASK MEMORY POINTER: pointers to the code
memory, data memory and stack memory for
the task.
veera
• Task management service utilises the TCB of a
task in the following way
Creates a TCB for a task on creating task
Delete/Remove the TCB of a task when the
task is terminated or deleted.
Reads the TCB to get the state of task
Update the TCB with updated parameters on
need basis
Modify the TCB to change the priority of the
task dynamically
veera
Task/Process Scheduling
• Deals with sharing the CPU among various
tasks/processes
veera
Task/Process synchronisation
veera
Error/Exception handling
• Deals with registering and handling the errors
occurred/exceptions raised during execution
of tasks
veera
Memory management
• Compared to GPOS, the memory management
function of a n RTOS kernel is slightly different.
veera
• Errors/Exceptions can happen at the kernel level
services or at a task level.
veera
Interrupt handling
• Deals with the handling of various types of
interrupts
• Interrupts provide time behaviour to systems
• Interrupts informs the processor that an
external device or an associated tasks requires
immediate attention of the CPU
• Interrupts can be either Synchronous or
Asynchronous
veera
• Interrupts which occurs in sync with currently
executing task is known as synchronous
interrupts
EX: software interrupts,divide by zero, memory
segmentation error, etc. are the examples of
synchronous interrupts
• Asynchronus interrupts are interrupts, which
occurs at any point of execution of any task, and
are not in sync with the currently executing task
EX: the interrupts generated by external devices
connected to the processor/controller, timer
overflow interrupts, serial data
reception/transmission interrupts
veera
Time management
• Accurate time management is essential for
providing precise time reference for all
applications
• The time reference to kernel is provided by a
high-resolution Real-Time Clock(RTC) hardware
chip(hardware timer).
• The hardware timer is programmed to interrupt
the processor/controller at a fixed rate
• The timer interrupt is referred as ’timer tick’
veera
4.3.TASK,
PROCESS,
THREADS
TASKS
The term ‘task’ refers to something to be done
In the operating systems, a task is defined as
the program in execution and the related
information maintained by the OS for the
program.
Task is also known as ‘job’ in OS context.
A program or part of it in execution is also
called a ‘process’
The terms ‘task’, ‘job’ and ‘process’ refer to
the same entity in the OS
PROCESS
A ‘process’ is a program, or part of it, in
execution.
Process is also known as instance of a program in
execution
multiple instances of same program can execute
simultaneously.
A process requires various system resources like
CPU for executing the process, memory for
storing the code corresponding to the process
and associated variables, I/O devices for
information exchange etc.
A process is sequential in execution.
structure of process
The concept of process leads to concurrent
execution of tasks and thereby efficient
utilisation of the CPU and other system
resources.
Concurrent execution is achieved through the
sharing of CPU among the processes
A process mimics a processor in properties
and holds a set of registers, process status, a
program counter(PC) , a stack for holding the
local variables associated with the task and
the code corresponding to the process.
STACK
(Stack Pointer)
Working Registers
Status Registers
READY
BLOCKED
RUNNING
COMPLETED
Process management