You are on page 1of 26

CONFIDENTIAL & PROPRIETARY

1
Chapter-3
Real-Time kernels and Operating
Systems


CONFIDENTIAL & PROPRIETARY
2
Tasks and things
CONFIDENTIAL & PROPRIETARY
3
Tasks and things
application comprises a number of tasks that must
be completed in order for the intended application to
be completed.
in an application , the CPU is being shared among
other tasks so that each can progress.
Each of the software modules- collection of
instructions- firmware that direct the CPU to carry
out a prescribed job.
if partitioning is done well , each of the smaller
modules will naturally become one of the tasks that
make up the application.





CONFIDENTIAL & PROPRIETARY
4
Programs and Processes
embedded program made up of a collection of
firmware modules is a static entity.
an executing firmware module- process or task.
process allocated a number of resources (
process stack, memory address space , registers ,
I/O ports, network connections, file descriptors etc
the currently executing instruction and the present
values of the associated data in memory or in
registers are collectively known as the process state.





CONFIDENTIAL & PROPRIETARY
5
CPU - resource
time that a task takes to complete execution
time
duration from the time when the task enters the
system until it terminates - persistence





CONFIDENTIAL & PROPRIETARY
6
Multitasking
CONFIDENTIAL & PROPRIETARY
7
Setting a schedule
CONFIDENTIAL & PROPRIETARY
8
Scheduling strategy
multiprogramming running task continues until
it performs an operation that requires waiting for an
external event.
Real- time tasks with temporal deadlines are
guaranteed to complete before those deadlines
expire.
Time sharing running task is required to give
up the CPU so that another task may get a turn.




CONFIDENTIAL & PROPRIETARY
9
Changing context
CONFIDENTIAL & PROPRIETARY
10
Threads
task or process is characterized by a collection of
resources that are utilized to execute a program.
smallest subset of these resources that is
necessary for the execution of the program is called
a thread.
thread can be in only one process
process without a thread can do nothing.




CONFIDENTIAL & PROPRIETARY
11
Single thread
CONFIDENTIAL & PROPRIETARY
12
Multiple threads
CONFIDENTIAL & PROPRIETARY
13
Sharing resources
Single process- single thread : has only one
process and in an embedded application that
process runs forever.
Multiprocess single thread: multiple
simultaneously executing processes , each process
has only a single thread of control
Single process multiple threads: supports
only one process ; within the process it has multiple
threads of control
multiprocess multiple threads : supports
multiple processes and within each process there is
support for multiple threads of control



CONFIDENTIAL & PROPRIETARY
14
Memory resource management
System level management



CONFIDENTIAL & PROPRIETARY
15
Memory resource management
Process level management
child processes
multiple threads

Reentrant code





CONFIDENTIAL & PROPRIETARY
16
Foreground/background systems
foreground:
initiated by interrupt or by a real time constraint.
higher priority


background:
non interrupt driven
lower priority



CONFIDENTIAL & PROPRIETARY
17
The operating system
an operating system must support three specific
functions :
schedule task execution (scheduler)
dispatch a task to run (dispatcher)
ensure communication and synchronization among
tasks (intertask or interprocess communication)


The kernel is the smallest portion of the operating
system that provides these functions.







CONFIDENTIAL & PROPRIETARY
18
Embedded operating system-services
Process or task management :
creation and deletion of user and system
processes
suspension and resumption of such processes
management of interprocess communication and
deadlocks.

Memory management :
tracking and control of which tasks are loaded into
memory
monitoring which parts of memory are being used
and by whom






CONFIDENTIAL & PROPRIETARY
19
Embedded operating system-services
Memory management :
administering dynamic memory if it is used
managing caching systems.

I/O system management :
in complex systems interaction occurs through
device driver.
application programmers interface (API)

File system management :
creation, deletion and management of files and
directories.









CONFIDENTIAL & PROPRIETARY
20
Embedded operating system-services
File system management :
working with non volatile memory
routine backup of any data that is to be saved as
well as emergency backup

System protection :
protection of data and resources in the context of
concurrent processes.

Networking :
managing distributed intrasystem communication
and remote scheduling of tasks.








CONFIDENTIAL & PROPRIETARY
21
Embedded operating system-services
Command interpretation :
software drivers interact with hardware I/O devices.
as commands and directives come into the system
they must be parsed, checked for grammatical
accuracy and directed to the target task.








CONFIDENTIAL & PROPRIETARY
22
Real Time Operating System(RTOS)
Special class of operating system that ensures
time constraints can be met
key characteristic- deterministic behaviour
hard real time and soft real time
hard real time : system delays are known or at
least bounded. These systems are said to be
operating correctly if they can return results within
the specified timing bounds.
soft real time : critical tasks have priority over
other tasks and retain that priority until it completes











CONFIDENTIAL & PROPRIETARY
23
Tasks
Task or process identifies a job that is to be done
within an embedded application
it is a set of s/w instructions collected together that
are designed and executed to accomplish that job
embedded application collection of such jobs
how & when each is executed is determined by
the schedule and the dispatch algorithms
how and what data are acted upon by the task is
specified by the intertask communication scheme.






CONFIDENTIAL & PROPRIETARY
24
Task Control Block (TCB)
Contains all important information about the task:
Pointer (for linking the TCB to various queues
Process ID and state
Program counter
CPU registers
Scheduling information ( priorities and pointer to
scheduling queues)
Memory management information ( tag tables and
cache information)
Scheduling information ( time limits or time and
resources used)
I/O status information ( resources allocated or
open files)



CONFIDENTIAL & PROPRIETARY
25
Static TCB allocation
No memory management
fixed number of TCBs
memory is allocated at system generation time & placed in
a dormant or unused state
when a task is initiated , TCB is created and appropriate
information is entered
The TCB is then placed into the ready state by the
scheduler
From ready state it will be returned to the execute state by
dispatcher
When a task terminates , the associated TCB is returned to
the dormant state
With a fixed number of TCBs no runtime memory
management is necessary

CONFIDENTIAL & PROPRIETARY
26
Dynamic TCB allocation
Variable number of TCBs can be allocated
heap management must be supported
unlimited supply of TCBs
typical embedded application has limited memory
; allocating too man TCBs can exhaust the supply