SlideShare a Scribd company logo
1 of 123
Download to read offline
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56
RTOS for Embedded System Design
Mr. Anand H. D.
1
RTOS for Embedded System Design
Department of Electronics & Communication Engineering
Dr. Ambedkar Institute of Technology
Bengaluru-56
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 2
RTOS for Embedded System Design
SYLLABUS:
Operating System basics
Types of operating systems
Task, process and threads
Multiprocessing and Multitasking
Task scheduling
How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 3
RTOS for Embedded System Design
Operating System (OS) acts as a bridge between user applications/tasks and the
underlying 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 .
The primary functions of OS are:
1. Make the system convenient to use.
2. Organize and mange the system resources efficiently and correctly.
 Is the core of OS and is responsible for managing the system resources and the
communication among the hardware and other system services.
 Acts as the abstraction layer between system resources and user applications.
 Contains a set of system libraries and services.
The Kernel:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 4
RTOS for Embedded System Design
Now let us consider the Architecture of OS:
General Purpose OS contains different services for handling
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 4
RTOS for Embedded System Design
Now let us consider the Architecture of OS:
Primary Memory Management:
Refers to volatile memory RAM, where processes are loaded
and variables and shared data associated with process are
stored.
The Memory Management Unit (MMU) of the kernel is
responsible for
•Keeping track of which part of memory area is currently used
by which process.
•Allocating and de-allocating memory space on need basis
(Dynamic Memory Allocation)
General Purpose OS contains different services for handling
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 4
RTOS for Embedded System Design
Now let us consider the Architecture of OS:
Primary Memory Management:
Refers to volatile memory RAM, where processes are loaded
and variables and shared data associated with process are
stored.
The Memory Management Unit (MMU) of the kernel is
responsible for
•Keeping track of which part of memory area is currently used
by which process.
•Allocating and de-allocating memory space on need basis
(Dynamic Memory Allocation)
General Purpose OS contains different services for handling
Process Management:
•Deals with managing the processes/tasks.
•By setting up the memory space for the process, loading the
process’s code into the memory space, allocating system
resources, scheduling and managing execution of process,
setting up and managing the Process Control Block (PCB),
Inter-process Communication and synchronization, process
termination/deletion etc.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 4
RTOS for Embedded System Design
Time Management:
Deals with at what time which process needs to be scheduled.
Till what duration processes needs to be executed.
After what time a process needs to be preempted.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 4
RTOS for Embedded System Design
Time Management:
Deals with at what time which process needs to be scheduled.
Till what duration processes needs to be executed.
After what time a process needs to be preempted.
File System Management:
File is collection of information.
A file could be a program, text file, image file, word
documents, audio/video files etc.
Each of these files differ in kind of information they hold
and the way in which information is stored.
The file system management service of kernel is responsible
for:
•Creation, deletion and alteration of files.
•Creation, deletion and alteration of directories.
•Saving of files in secondary storage memory.
•Providing automatic allocation of file space based on amount
of free space available.
•Providing a flexible naming convention for the files.
The various file system management operations are OS
dependent.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 4
RTOS for Embedded System Design
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 direct access of I/O devices is not allowed and
access to them is provided through a Application Programming
Interfaces (API) exposed by kernel.
Kernel maintains a list of I/O devices of the system. This list may be
available well in advance at the time of building the kernel or in cases
Kernels dynamically updates the list and where the new device is
installed.
The service ‘Device Manager’ is responsible handling all I/O device
related operations.
The kernel talks to I/O devices through a set of low level system calls,
which are implemented in a service called device drivers. These drivers
are specific to a device or a class of devices.
The device manager is responsible for :
•Loading & unloading of device drivers.
• Exchanging information and the system specific controls to and from
the device.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 4
RTOS for Embedded System Design
The Operating System Architecture
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 5
RTOS for Embedded System Design
Secondary Storage Management:
Deals with management of secondary storage devices.
Secondary memory is used as a backup medium for program
and data since the main memory is volatile.
In most of the systems the secondary storage is in the for of
disks (Hard disks).
The secondary storage management services of kernel deals
with : Disk Storage allocation.
Disk Scheduling .
Free disk space management
Protection System:
Most of the modern OS are deigned in such a way that they
support multiple users with different levels of access permissions .
Protection deals with implementing the security polices to
restrict the access to both user and system resources by different
applications or processes or users.
In multiuser OS, one user may not be allowed to view or modify
complete portion of another user’s data or profile details.
Also some applications may not be granted permissions to make
use of certain system resources.
Interrupt Handler:
Kernel provides handler mechanism for all external/internal interrupts generated by the system.
These are some of the services offered by kernel of an OS.
Depending on type of OS, a kernel may contain lesser/more number of services/components.
In addition to above mentioned services many OS offer a no. of add-on services to kernel, Network communication, network
management, user-interface graphics, timer services, error handler, database management etc.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 6
RTOS for Embedded System Design
The applications/services are classified into : User applications and Kernel applications
The program code corresponding to kernel applications/services are kept in contiguous area of primary memory and
is protected from unauthorized access by user programs/applications—Kernel Space
All user programs are loaded to a specific area of primary memory and this memory area is referred as User space.
The portioning of memory into Kernel space and user space is purely OS dependent.
In OS with virtual memory support, the user applications are loaded into corresponding virtual memory space
with demand paging technique — the entire code for user application need not be loaded into main memory at once;
instead user application is divided into different pages and these pages are loaded into and out of main memory area
on a need basis – Swapping.
Swapping happens between main memory and secondary storage memory.
Each process run in its own virtual memory space and are not allowed accessing the memory space corresponding
to another processes unless explicitly requested by the process.
Most of the OS keep the kernel application code in main memory and it is not swapped out into the secondary
memory.
Kernel Space Vs User Space:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 7
RTOS for Embedded System Design
Monolithic Kernel and Microkernel:
Monolithic Kernel
In monolithic kernel architecture, all kernel services run in
the kernel space.
All kernel modules run in same memory space under a
single kernel thread.
Tight internal integration of kernel modules allows the
effective utilization of the low level features of the
underlying system.
Major drawback is that any error or failure in any one of
the kernel modules leads to the crashing of entire kernel
applications.
LINUX, MS-DOS, SOLARIS are examples of monolithic
kernel OS.
The Monolithic kernel Model
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 8
RTOS for Embedded System Design
Microkernel
Incorporates only essential set of OS services into the
kernel and rest of OS services are implemented in programs
known as Servers which run in user space.
Provides a highly modular design and OS-neutral
abstraction to the kernel.
Memory management, process management, time system
and interrupt handlers are essential services which forms the
part of microkernel.
Mach, QNX, MINIX3 are examples of microkernel OS.
Offers 2 benefits:
•Robustness: server programs can be reconfigured &
restarted, chances of corruption are ideally zero.
•Configurability: any server application can be changed
without restarting the entire system—dynamically
configurable
The Microkernel Model
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 9
RTOS for Embedded System Design
Depending on kernel and kernel services, purpose and type of computing systems where OS is deployed and
responsiveness to applications, OSs are classified into 2 types:
General Purpose Operating System (GPOS)
Real-Time Operating System (RTOS)
General Purpose Operating System (GPOS)
Deployed in general computing systems.
Kernel is more generalized and it contains all kinds of
services required for executing generic applications.
Often non-deterministic in behavior, there services can
inject random delays into application software and may
cause slow responsiveness of an application at unexpected
times.
They are often deployed in general computing systems
where deterministic behavior is not important.
Personal computers/desktop system is typical example of
a system where GPOS is deployed.
Windows XP/MS-DOS etc. are examples of GPOSs.
Real-Time Operating System (RTOS)
Real-time implies deterministic timing behavior.
Means OS services consumes only known and expected
amounts of time regardless the number of services.
RTOS implements policies and rules concerning time-
critical allocation of system resources.
RTOS decides which application should run in which
order and how much time must be allocated for each
application.
Predictable performance is hallmark of RTOS. This is
achievable by consistent application of policies and rules.
Windows CE, QNX, VxWorks, MicroC/OS-II etc. are
examples of RTOS
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10
RTOS for Embedded System Design
Real Time Kernel:
kernel of RTOS
Compare to conventional OS kernel Real
Time kernel is highly specialized and it
contains only minimal set of services required
for running the user applications/tasks.
The basic functions of Real Time Kernel
are:
•Task/Process management.
•Task/Process scheduling.
•Task/Process synchronization.
•Error/Exception Handling.
•Memory management.
•Interrupt Handling.
•Time Management
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10
RTOS for Embedded System Design
Real Time Kernel:
kernel of RTOS
Compare to conventional OS kernel Real
Time kernel is highly specialized and it
contains only minimal set of services required
for running the user applications/tasks.
The basic functions of Real Time Kernel
are:
•Task/Process management.
•Task/Process scheduling.
•Task/Process synchronization.
•Error/Exception Handling.
•Memory management.
•Interrupt Handling.
•Time Management
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, termination and deletion.
TCB is used to hold information corresponding to task which includes:
Implementation of TCB is kernel dependent.
Task management service uses TCB of a task in following way:
•Creates a TCB for a task on creating a task.
•Delete/remove TCB of task when task is terminated/deleted
•Reads TCB to get the state of task.
•Update TCB with updated parameters on need basis.
•Modify TCB to change task priority dynamically.
•Task ID •Task state
•Task type •Task Priority
•Task context pointer •Task memory pointers
•Task system resource pointers •Task pointers.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10
RTOS for Embedded System Design
Real Time Kernel:
kernel of RTOS
Compare to conventional OS kernel Real
Time kernel is highly specialized and it
contains only minimal set of services required
for running the user applications/tasks.
The basic functions of Real Time Kernel
are:
•Task/Process management.
•Task/Process scheduling.
•Task/Process synchronization.
•Error/Exception Handling.
•Memory management.
•Interrupt Handling.
•Time Management
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, termination and deletion.
TCB is used to hold information corresponding to task which includes:
Implementation of TCB is kernel dependent.
Task management service uses TCB of a task in following way:
•Creates a TCB for a task on creating a task.
•Delete/remove TCB of task when task is terminated/deleted
•Reads TCB to get the state of task.
•Update TCB with updated parameters on need basis.
•Modify TCB to change task priority dynamically.
Task/Process scheduling:
Deals with sharing CPU among various tasks/processes.
A kernel service called ‘Scheduler’ handles task scheduling.
Scheduler is nothing but an algorithm implementation which performs the
efficient and optimal scheduling of task to provide a deterministic behavior.
•Task ID •Task state
•Task type •Task Priority
•Task context pointer •Task memory pointers
•Task system resource pointers •Task pointers.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10
RTOS for Embedded System Design
Real Time Kernel:
kernel of RTOS
Compare to conventional OS kernel Real
Time kernel is highly specialized and it
contains only minimal set of services required
for running the user applications/tasks.
The basic functions of Real Time Kernel
are:
•Task/Process management.
•Task/Process scheduling.
•Task/Process synchronization.
•Error/Exception Handling.
•Memory management.
•Interrupt Handling.
•Time Management
Task/Process synchronization:
Deals with the synchronization of concurrent access of resources, which is shared
across multiple tasks and communication between various tasks.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10
RTOS for Embedded System Design
Real Time Kernel:
kernel of RTOS
Compare to conventional OS kernel Real
Time kernel is highly specialized and it
contains only minimal set of services required
for running the user applications/tasks.
The basic functions of Real Time Kernel
are:
•Task/Process management.
•Task/Process scheduling.
•Task/Process synchronization.
•Error/Exception Handling.
•Memory management.
•Interrupt Handling.
•Time Management
Task/Process synchronization:
Deals with the synchronization of concurrent access of resources, which is shared
across multiple tasks and communication between various tasks.
Error/Exception Handling:
Deals with registering and handling the errors occurred/exceptions raised during
execution of tasks.
Insufficient memory, timeouts, deadlocks, deadline missing, bus error, divide by
zero, unknown instruction execution etc. are examples of errors/exceptions.
Errors/Exceptions can occur at kernel level services or at task level. Deadlock is an
kernel level error whereas timeout is an example for task level.
The OS kernel gives the information in the form of System Call (API).
Watchdog timer will be used for handling timeouts.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10
RTOS for Embedded System Design
Real Time Kernel:
kernel of RTOS
Compare to conventional OS kernel Real
Time kernel is highly specialized and it
contains only minimal set of services required
for running the user applications/tasks.
The basic functions of Real Time Kernel
are:
•Task/Process management.
•Task/Process scheduling.
•Task/Process synchronization.
•Error/Exception Handling.
•Memory management.
•Interrupt Handling.
•Time Management
Task/Process synchronization:
Deals with the synchronization of concurrent access of resources, which is shared
across multiple tasks and communication between various tasks.
Error/Exception Handling:
Deals with registering and handling the errors occurred/exceptions raised during
execution of tasks.
Insufficient memory, timeouts, deadlocks, deadline missing, bus error, divide by
zero, unknown instruction execution etc. are examples of errors/exceptions.
Errors/Exceptions can occur at kernel level services or at task level. Deadlock is an
kernel level error whereas timeout is an example for task level.
The OS kernel gives the information in the form of System Call (API).
Watchdog timer will be used for handling timeouts.
Memory Management:
Compare to GPOS, memory management of RTOS is slightly different.
Memory allocation time increases depending upon the block of memory needs to
be allocated and state of allocated memory.
RTOS makes use of ‘block’ based memory allocation technique instead of usual
dynamic memory allocation used by GPOS.
RTOS kernel uses blocks of fixed size of dynamic memory and block is allocated
to a task on need basis. The blocks are stored in ‘free buffer queues’.
To achieve predictable timing and avoid timing overhead, RTOS allows task to
access any memory blocks without any memory protection.
Few RTOS kernels implement Virtual Memory concept of memory allocation if
system supports secondary memory storage.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10
RTOS for Embedded System Design
Real Time Kernel:
kernel of RTOS
Compare to conventional OS kernel Real
Time kernel is highly specialized and it
contains only minimal set of services required
for running the user applications/tasks.
The basic functions of Real Time Kernel
are:
•Task/Process management.
•Task/Process scheduling.
•Task/Process synchronization.
•Error/Exception Handling.
•Memory management.
•Interrupt Handling.
•Time Management
Interrupt Handling:
Deals with handling different types of interrupts.
Interrupts provide Real time behavior to system. Interrupts inform the
processor that an external device or an associated task requires
immediate attention of CPU.
Interrupts can be Synchronous or Asynchronous.
Interrupts that occur in sync with currently executing task are known
as Synchronous interrupts — usually software interrupts – divide by 0,
memory segmentation error etc. are few examples.
For Synchronous interrupts the interrupt handler runs in same context
of interrupting task.
Interrupts that occur at any point of execution of any task and are not
in sync with currently executing task are Asynchronous interrupts. –
generated by external devices connected to process/controller – timer
overflow interrupts, serial data reception/transmission interrupts etc. are
examples.
For Asynchronous interrupts the interrupt handler is usually written as
separate task and it runs in different context. Hence a context-switch
occurs while handling an asynchronous interrupt.
Priority levels can be assigned to interrupts and each interrupts can be
enabled and disabled individually.
Most of the RTOS kernel implements ‘Nested interrupts’ architecture,
which allows interruption of a Interrupt Service Routine (ISR), while
servicing an interrupt, by a high priority interrupt.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10
RTOS for Embedded System Design
Real Time Kernel:
kernel of RTOS
Compare to conventional OS kernel Real
Time kernel is highly specialized and it
contains only minimal set of services required
for running the user applications/tasks.
The basic functions of Real Time Kernel
are:
•Task/Process management.
•Task/Process scheduling.
•Task/Process synchronization.
•Error/Exception Handling.
•Memory management.
•Interrupt Handling.
•Time Management
Time Management:
Accurate time management is essential for providing precise time
reference to all applications.
The time reference to kernel is provided by a high resolution Real-
Time-Clock (RTC) hardware chip.
The hardware time is programmed to interrupt the processor/controller
at a fixed interval. This is referred as ‘timer tick’. Usually varies in µsec.
If timer tick interval is 1 µsec, system time register will reset in
If timer tick interval is 1 millisecond, system time register will reset in
This timer tick can be utilized for:
•Save the current context.
•Increment the timer register by one.
•Update the timers implemented in kernel.
•Activate the periodic tasks, which are in idle state.
•Invoke the scheduler and schedule the tasks again based on scheduling
algorithm.
•Delete all terminated tasks and associated data structures (TCBs).
•Load the context for first task in the ready queue.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 11
RTOS for Embedded System Design
Hard Real Time:
RTOSs that strictly adhere to the timing constraints
for a task are referred as ‘Hard Real Time’systems.
Hard real time system must meet the deadlines for a
task without any slippage. Missing any deadlines may
produce catastrophic results for Hard real time systems
including permanent data lose and irrecoverable
damages to the system/users.
Emphasizes on ‘ a late answer is a wrong answer’ .
Air bag control system and Anti-lock Braking
System (ABS) are typical examples.
The airbag control system must be into action and
deploy the airbags when vehicles meet severe
accident.
Soft Real Time:
RTOSs that does not guarantee meeting deadlines but offer the best effort to meet the deadlines are referred as
‘Soft Real Time’systems.
Missing deadlines for tasks are acceptable if the frequency of deadline missing is within the compliance limit of
‘Quality of Service (QoS)’ .
Emphasizes on ‘ a late answer is a an acceptable answer, but it could have done bit faster’.
Most often have ‘Human in the loop (HITL)’ ,Automatic Teller machine (ATM) is a typical example.
A audio-video playback system is another example.
Ideally speaking the response time of air bag system
must be zero and bags should be deployed exactly
within the time frame which is predefined.
Any delay in deployment of air-bags makes the life
of passengers under threat.
When the airbag deployment task is triggered, the
currently executing task must be preempted, airbag
deployment task must be brought into execution and
necessary I/O systems should be made readily available
As a Thumb rule hard real time systems doesn’t
implement virtual memory model. This eliminates the
delay in swapping in and out the code.
Most of the Hard Real Time systems are automatic
and does not contain a ‘human in the loop (HITL)’.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 12
RTOS for Embedded System Design
In OS context a ‘task’ is defined as the program in execution and the related information maintained by the OS
for the program.
A 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 context and most often they are used
interchangeably.
Process:
Also known as an instance of program in execution.
Multiple instances of the 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.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 13
RTOS for Embedded System Design
Structure of a Process
The Structure of a Process:
The concept of process leads to
concurrent execution of tasks thereby the
efficient utilization of CPU and other
system resources.
A process mimics a processor in
properties and holds:
•A stack for holding the local variables
associated with the process
•A set of working registers,
•Process status registers,
•A Program Counter (PC) to point to
next executable instruction of the
process and
•The code corresponding to process.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 13
RTOS for Embedded System Design
Structure of a Process
The Structure of a Process:
The concept of process leads to
concurrent execution of tasks thereby the
efficient utilization of CPU and other
system resources.
A process mimics a processor in
properties and holds:
•A stack for holding the local variables
associated with the process
•A set of working registers,
•Process status registers,
•A Program Counter (PC) to point to
next executable instruction of the
process and
•The code corresponding to process.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 13
RTOS for Embedded System Design
Structure of a Process
The Structure of a Process:
The concept of process leads to
concurrent execution of tasks thereby the
efficient utilization of CPU and other
system resources.
A process mimics a processor in
properties and holds:
•A stack for holding the local variables
associated with the process
•A set of working registers,
•Process status registers,
•A Program Counter (PC) to point to
next executable instruction of the
process and
•The code corresponding to process.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 13
RTOS for Embedded System Design
Structure of a Process
The Structure of a Process:
The concept of process leads to
concurrent execution of tasks thereby the
efficient utilization of CPU and other
system resources.
A process mimics a processor in
properties and holds:
•A stack for holding the local variables
associated with the process
•A set of working registers,
•Process status registers,
•A Program Counter (PC) to point to
next executable instruction of the
process and
•The code corresponding to process.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 13
RTOS for Embedded System Design
Structure of a Process
The Structure of a Process:
The concept of process leads to
concurrent execution of tasks thereby the
efficient utilization of CPU and other
system resources.
A process mimics a processor in
properties and holds:
•A stack for holding the local variables
associated with the process
•A set of working registers,
•Process status registers,
•A Program Counter (PC) to point to
next executable instruction of the
process and
•The code corresponding to process.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 13
RTOS for Embedded System Design
The concept of process leads to
concurrent execution of tasks thereby the
efficient utilization of CPU and other
system resources.
A process mimics a processor in
properties and holds:
•A stack for holding the local variables
associated with the process
•A set of working registers,
•Process status registers,
•A Program Counter (PC) to point to
next executable instruction of the
process and
•The code corresponding to process.
Structure of a Process
The Structure of a Process:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 14
RTOS for Embedded System Design
A process which inherits all properties of CPU can be considered as a
virtual processor, awaiting its turn to have its properties switched into
physical processor.
When process gets it turn, its registers and the PC register maps to
physical registers of CPU.
On loading a process into main memory, a specific area of memory
is allocated for the process.
The memory occupied by process is segregated into 3 regions:
•Stack Memory—holds all temporary data such as variables local to the
process.
•Data Memory – holds all global data for the process.
•Code Memory – contains the program code corresponding to process.
Stack memory starts at the highest address from allocated memory and
grows downwards.
Say if allocated memory area for process is 2048-2100, the stack
memory starts at address 2100 and grows downwards. Memory organization of a Process
Memory Organization of a Process:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 14
RTOS for Embedded System Design
A process which inherits all properties of CPU can be considered as a
virtual processor, awaiting its turn to have its properties switched into
physical processor.
When process gets it turn, its registers and the PC register maps to
physical registers of CPU.
On loading a process into main memory, a specific area of memory is
allocated for the process.
The memory occupied by process is segregated into 3 regions:
•Code Memory – contains the program code corresponding to process.
•Stack Memory—holds all temporary data such as variables local to the
process.
•Data Memory – holds all global data for the process.
Stack memory starts at the highest address from allocated memory and
grows downwards.
Say if allocated memory area for process is 2048-2100, the stack
memory starts at address 2100 and grows downwards. Memory organization of a Process
Memory Organization of a Process:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 14
RTOS for Embedded System Design
A process which inherits all properties of CPU can be considered as a
virtual processor, awaiting its turn to have its properties switched into
physical processor.
When process gets it turn, its registers and the PC register maps to
physical registers of CPU.
On loading a process into main memory, a specific area of memory is
allocated for the process.
The memory occupied by process is segregated into 3 regions:
•Code Memory – contains the program code corresponding to process.
•Data Memory – holds all global data for the process.
•Stack Memory—holds all temporary data such as variables local to the
process.
from allocated memory and grows downwards.
Say if allocated memory area for process is 2048-2100, the stack
memory starts at address 2100 and grows downwards.
Memory organization of a Process
Memory Organization of a Process:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 14
RTOS for Embedded System Design
A process which inherits all properties of CPU can be considered as a
virtual processor, awaiting its turn to have its properties switched into
physical processor.
When process gets it turn, its registers and the PC register maps to
physical registers of CPU.
On loading a process into main memory, a specific area of memory is
allocated for the process.
The memory occupied by process is segregated into 3 regions:
•Code Memory – contains the program code corresponding to process.
•Data Memory – holds all global data for the process.
•Stack Memory—holds all temporary data such as variables local to the
process.
Stack memory starts at the highest address from allocated memory and
grows downwards.
Say if allocated memory area for process is 2048-2100, the stack
memory starts at address 2100 and grows downwards. Memory organization of a Process
Memory Organization of a Process:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 14
RTOS for Embedded System Design
A process which inherits all properties of CPU can be considered as a
virtual processor, awaiting its turn to have its properties switched into
physical processor.
When process gets it turn, its registers and the PC register maps to
physical registers of CPU.
On loading a process into main memory, a specific area of memory is
allocated for the process.
The memory occupied by process is segregated into 3 regions:
•Code Memory – contains the program code corresponding to process.
•Data Memory – holds all global data for the process.
•Stack Memory—holds all temporary data such as variables local to the
process.
Stack memory starts at the highest address from allocated memory and
grows downwards.
Say if allocated memory area for process is 2048-2100, the stack
memory starts at address 2100 and grows downwards. Memory organization of a Process
Memory Organization of a Process:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 14
RTOS for Embedded System Design
A process which inherits all properties of CPU can be considered as a
virtual processor, awaiting its turn to have its properties switched into
physical processor.
When process gets it turn, its registers and the PC register maps to
physical registers of CPU.
On loading a process into main memory, a specific area of memory is
allocated for the process.
The memory occupied by process is segregated into 3 regions:
•Code Memory – contains the program code corresponding to process.
•Data Memory – holds all global data for the process.
•Stack Memory—holds all temporary data such as variables local to the
process.
Stack memory starts at the highest address from allocated memory
and grows downwards.
Say if allocated memory area for process is 2048-2100, the stack
memory starts at address 2100 and grows downwards. Memory organization of a Process
Memory Organization of a Process:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15
RTOS for Embedded System Design
The creation of a process to its termination is not a single step
operation.
The process traverses a series of states during its transition from
newly created state to terminated state – ‘Process Life Cycle’.
‘Created’ state – state at which a process is created, OS recognizes
that a process is created but no resources are allocated.
‘Ready’ state – state where a process is incepted into the memory
and awaiting Processor time for execution. Processes is placed in
‘Ready list queue’.
‘Running’ state – state at which a process execution happens.
‘Blocked/Wait’ state – state where a running process is temporarily
suspended from execution and does not have immediate access to
resources.
‘Completed’ state – state where process completes its execution.
Transistion of a process from one state to another is called as
‘State Transistion’
Process Sates & State transition representation
Process States and State Transition:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15
RTOS for Embedded System Design
The creation of a process to its termination is not a single step
operation.
The process traverses a series of states during its transition from
newly created state to terminated state – ‘Process Life Cycle’.
‘Created’ state – state at which a process is created, OS recognizes
that a process is created but no resources are allocated.
‘Ready’ state – state where a process is incepted into the memory
and awaiting Processor time for execution. Processes is placed in
‘Ready list queue’.
‘Running’ state – state at which a process execution happens.
‘Blocked/Wait’ state – state where a running process is temporarily
suspended from execution and does not have immediate access to
resources.
‘Completed’ state – state where process completes its execution.
Transistion of a process from one state to another is called as
‘State Transistion’
Process Sates & State transition representation
Process States and State Transition:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15
RTOS for Embedded System Design
The creation of a process to its termination is not a single step
operation.
The process traverses a series of states during its transition from
newly created state to terminated state – ‘Process Life Cycle’.
‘Created’ state – state at which a process is created, OS recognizes
that a process is created but no resources are allocated.
‘Ready’ state – state where a process is incepted into the memory
and awaiting Processor time for execution. Processes is placed in
‘Ready list queue’.
‘Running’ state – state at which a process execution happens.
‘Blocked/Wait’ state – state where a running process is temporarily
suspended from execution and does not have immediate access to
resources.
‘Completed’ state – state where process completes its execution.
Transistion of a process from one state to another is called as
‘State Transistion’
Process Sates & State transition representation
Process States and State Transition:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15
RTOS for Embedded System Design
The creation of a process to its termination is not a single step
operation.
The process traverses a series of states during its transition from
newly created state to terminated state – ‘Process Life Cycle’.
‘Created’ state – state at which a process is created, OS recognizes
that a process is created but no resources are allocated.
‘Ready’ state – state where a process is incepted into the memory
and awaiting Processor time for execution. Processes is placed in
‘Ready list queue’.
‘Running’ state – state at which a process execution happens.
‘Blocked/Wait’ state – state where a running process is temporarily
suspended from execution and does not have immediate access to
resources.
‘Completed’ state – state where process completes its execution.
Transistion of a process from one state to another is called as
‘State Transistion’
Process Sates & State transition representation
Process States and State Transition:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15
RTOS for Embedded System Design
The creation of a process to its termination is not a single step
operation.
The process traverses a series of states during its transition from
newly created state to terminated state – ‘Process Life Cycle’.
‘Created’ state – state at which a process is created, OS recognizes
that a process is created but no resources are allocated.
‘Ready’ state – state where a process is incepted into the memory
and awaiting Processor time for execution. Processes is placed in
‘Ready list queue’.
‘Running’ state – state at which a process execution happens.
‘Blocked/Wait’ state – state where a running process is temporarily
suspended from execution and does not have immediate access to
resources.
‘Completed’ state – state where process completes its execution.
Transistion of a process from one state to another is called as
‘State Transistion’
Process Sates & State transition representation
Process States and State Transition:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15
RTOS for Embedded System Design
The creation of a process to its termination is not a single step
operation.
The process traverses a series of states during its transition from
newly created state to terminated state – ‘Process Life Cycle’.
‘Created’ state – state at which a process is created, OS recognizes
that a process is created but no resources are allocated.
‘Ready’ state – state where a process is incepted into the memory
and awaiting Processor time for execution. Processes is placed in
‘Ready list queue’.
‘Running’ state – state at which a process execution happens.
‘Blocked/Wait’ state – state where a running process is temporarily
suspended from execution and does not have immediate access to
resources.
‘Completed’ state – state where process completes its execution.
Transistion of a process from one state to another is called as
‘State Transistion’
Process Sates & State transition representation
Process States and State Transition:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15
RTOS for Embedded System Design
The creation of a process to its termination is not a single step
operation.
The process traverses a series of states during its transition from
newly created state to terminated state – ‘Process Life Cycle’.
‘Created’ state – state at which a process is created, OS recognizes
that a process is created but no resources are allocated.
‘Ready’ state – state where a process is incepted into the memory
and awaiting Processor time for execution. Processes is placed in
‘Ready list queue’.
‘Running’ state – state at which a process execution happens.
‘Blocked/Wait’ state – state where a running process is temporarily
suspended from execution and does not have immediate access to
resources.
‘Completed’ state – state where process completes its execution.
Transistion of a process from one state to another is called as
‘State Transistion’
Process Sates & State transition representation
Process States and State Transition:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15
RTOS for Embedded System Design
The creation of a process to its termination is not a single step
operation.
The process traverses a series of states during its transition from
newly created state to terminated state – ‘Process Life Cycle’.
‘Created’ state – state at which a process is created, OS recognizes
that a process is created but no resources are allocated.
‘Ready’ state – state where a process is incepted into the memory
and awaiting Processor time for execution. Processes is placed in
‘Ready list queue’.
‘Running’ state – state at which a process execution happens.
‘Blocked/Wait’ state – state where a running process is temporarily
suspended from execution and does not have immediate access to
resources.
‘Completed’ state – state where process completes its execution.
Transistion of a process from one state to another is called as
‘State Transistion’
Process Sates & State transition representation
Process States and State Transition:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15
RTOS for Embedded System Design
The creation of a process to its termination is not a single step
operation.
The process traverses a series of states during its transition from
newly created state to terminated state – ‘Process Life Cycle’.
‘Created’ state – state at which a process is created, OS recognizes
that a process is created but no resources are allocated.
‘Ready’ state – state where a process is incepted into the memory
and awaiting Processor time for execution. Processes is placed in
‘Ready list queue’.
‘Running’ state – state at which a process execution happens.
‘Blocked/Wait’ state – state where a running process is temporarily
suspended from execution and does not have immediate access to
resources.
‘Completed’ state – state where process completes its execution.
Transistion of a process from one state to another is called as
‘State Transistion’
Process Sates & State transition representation
Process States and State Transition:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15
RTOS for Embedded System Design
The creation of a process to its termination is not a single step
operation.
The process traverses a series of states during its transition from
newly created state to terminated state – ‘Process Life Cycle’.
‘Created’ state – state at which a process is created, OS recognizes
that a process is created but no resources are allocated.
‘Ready’ state – state where a process is incepted into the memory
and awaiting Processor time for execution. Processes is placed in
‘Ready list queue’.
‘Running’ state – state at which a process execution happens.
‘Blocked/Wait’ state – state where a running process is temporarily
suspended from execution and does not have immediate access to
resources.
‘Completed’ state – state where process completes its execution.
Transistion of a process from one state to another is called as
‘State Transistion’
Process Sates & State transition representation
Process States and State Transition:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15
RTOS for Embedded System Design
The creation of a process to its termination is not a single step
operation.
The process traverses a series of states during its transition from
newly created state to terminated state – ‘Process Life Cycle’.
‘Created’ state – state at which a process is created, OS recognizes
that a process is created but no resources are allocated.
‘Ready’ state – state where a process is incepted into the memory
and awaiting Processor time for execution. Processes is placed in
‘Ready list queue’.
‘Running’ state – state at which a process execution happens.
‘Blocked/Wait’ state – state where a running process is temporarily
suspended from execution and does not have immediate access to
resources.
‘Completed’ state – state where process completes its execution.
Transistion of a process from one state to another is called as
‘State Transistion’
Process Sates & State transition representation
Process States and State Transition:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15
RTOS for Embedded System Design
The creation of a process to its termination is not a single step
operation.
The process traverses a series of states during its transition from
newly created state to terminated state – ‘Process Life Cycle’.
‘Created’ state – state at which a process is created, OS recognizes
that a process is created but no resources are allocated.
‘Ready’ state – state where a process is incepted into the memory
and awaiting Processor time for execution. Processes is placed in
‘Ready list queue’.
‘Running’ state – state at which a process execution happens.
‘Blocked/Wait’ state – state where a running process is temporarily
suspended from execution and does not have immediate access to
resources.
‘Completed’ state – state where process completes its execution.
Transistion of a process from one state to another is called as
‘State Transistion’
Process Sates & State transition representation
Process States and State Transition:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 16
RTOS for Embedded System Design
A thread is the primitive that can execute
code.
A thread is a single sequential flow of
control within a process.
Thread is also known as light weighted
process.
A process can have many threads of
execution.
Different threads, which are part of a
process, share the same address space (same
code, data and heap memory area).
Threads maintain there own thread status—
CPU register values, PC and stack.
Threads:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 16
RTOS for Embedded System Design
A thread is the primitive that can execute
code.
A thread is a single sequential flow of
control within a process.
Thread is also known as light weighted
process.
A process can have many threads of
execution.
Different threads, which are part of a
process, share the same address space (same
code, data and heap memory area).
Threads maintain there own thread status—
CPU register values, PC and stack. Memory Organization of a process & its associated threads
Threads:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 16
RTOS for Embedded System Design
A thread is the primitive that can execute
code.
A thread is a single sequential flow of
control within a process.
Thread is also known as light weighted
process.
A process can have many threads of
execution.
Different threads, which are part of a
process, share the same address space (same
code, data and heap memory area).
Threads maintain there own thread status—
CPU register values, PC and stack. Memory Organization of a process & its associated threads
Threads:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 16
RTOS for Embedded System Design
A thread is the primitive that can execute
code.
A thread is a single sequential flow of
control within a process.
Thread is also known as light weighted
process.
A process can have many threads of
execution.
Different threads, which are part of a
process, share the same address space (same
code, data and heap memory area).
Threads maintain there own thread status—
CPU register values, PC and stack. Memory Organization of a process & its associated threads
Threads:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 16
RTOS for Embedded System Design
A thread is the primitive that can execute
code.
A thread is a single sequential flow of
control within a process.
Thread is also known as light weighted
process.
A process can have many threads of
execution.
Different threads, which are part of a
process, share the same address space (same
code, data and heap memory area).
Threads maintain there own thread status—
CPU register values, PC and stack. Memory Organization of a process & its associated threads
Threads:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 16
RTOS for Embedded System Design
A thread is the primitive that can execute
code.
A thread is a single sequential flow of
control within a process.
Thread is also known as light weighted
process.
A process can have many threads of
execution.
Different threads, which are part of a
process, share the same address space (same
code, data and heap memory area).
Threads maintain there own thread status—
CPU register values, PC and stack. Memory Organization of a process & its associated threads
Threads:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 16
RTOS for Embedded System Design
A thread is the primitive that can execute
code.
A thread is a single sequential flow of
control within a process.
Thread is also known as light weighted
process.
A process can have many threads of
execution.
Different threads, which are part of a
process, share the same address space (same
code, data and heap memory area).
Threads maintain there own thread status—
CPU register values, PC and stack. Memory Organization of a process & its associated threads
Threads:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 16
RTOS for Embedded System Design
A thread is the primitive that can execute
code.
A thread is a single sequential flow of
control within a process.
Thread is also known as light weighted
process.
A process can have many threads of
execution.
Different threads, which are part of a
process, share the same address space (same
code, data and heap memory area).
Threads maintain there own thread status—
CPU register values, PC and stack. Memory Organization of a process & its associated threads
Threads:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 17
RTOS for Embedded System Design
A process/thread in a embedded application may be a
complex or lengthy one and it may contain various sub-
operations like getting input from I/O devices
connected to processor, performing some internal
calculations /operations, updating some I/O devices etc.
If all these sub-operations are executed in sequence,
the CPU utilization may not be efficient.
Instead of this single sequential execution of the
whole process, if task/process is split into different
threads carrying out the different sub-functionalities of
the process, the CPU can be effectively utilized.
Threads corresponding to I/O operations enter wait
state, while other threads which do not require I/O can
be switched to execution.
The concept of Multithreading:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 17
RTOS for Embedded System Design
If the process is split into multiple threads, which
executes a portion of the process, there will be a main
thread and rest of them will be created within main
thread.
Use of multiple threads to execute a process results in
following advantages:
Better Memory Utilization: multiple threads of
same process share address space for data memory,
also reduces inter thread communication since variables
will be shared.
Speedy execution: since process splits into different
threads, when one thread enters wait state other thread
can be scheduled.
Efficient CPU Utilization: CPU is engaged all time
Process with multi-threads
The concept of Multithreading:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 17
RTOS for Embedded System Design
If the process is split into multiple threads, which
executes a portion of the process, there will be a main
thread and rest of them will be created within main
thread.
Use of multiple threads to execute a process results in
following advantages:
Better Memory Utilization: multiple threads of
same process share address space for data memory,
also reduces inter thread communication since variables
will be shared.
Speedy execution: since process splits into different
threads, when one thread enters wait state other thread
can be scheduled.
Efficient CPU Utilization: CPU is engaged all time
Process with multi-threads
The concept of Multithreading:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 17
RTOS for Embedded System Design
If the process is split into multiple threads, which
executes a portion of the process, there will be a main
thread and rest of them will be created within main
thread.
Use of multiple threads to execute a process results in
following advantages:
Better Memory Utilization: multiple threads of
same process share address space for data memory,
also reduces inter thread communication since variables
will be shared.
Speedy execution: since process splits into different
threads, when one thread enters wait state other thread
can be scheduled.
Efficient CPU Utilization: CPU is engaged all time
Process with multi-threads
The concept of Multithreading:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 17
RTOS for Embedded System Design
If the process is split into multiple threads, which
executes a portion of the process, there will be a main
thread and rest of them will be created within main
thread.
Use of multiple threads to execute a process results in
following advantages:
Better Memory Utilization: multiple threads of
same process share address space for data memory,
also reduces inter thread communication since variables
will be shared.
Speedy execution: since process splits into different
threads, when one thread enters wait state other thread
can be scheduled.
Efficient CPU Utilization: CPU is engaged all time
Process with multi-threads
The concept of Multithreading:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 17
RTOS for Embedded System Design
If the process is split into multiple threads, which
executes a portion of the process, there will be a main
thread and rest of them will be created within main
thread.
Use of multiple threads to execute a process results in
following advantages:
Better Memory Utilization: multiple threads of
same process share address space for data memory,
also reduces inter thread communication since variables
will be shared.
Speedy execution: since process splits into different
threads, when one thread enters wait state other thread
can be scheduled.
Efficient CPU Utilization: CPU is engaged all time
Process with multi-threads
The concept of Multithreading:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 17
RTOS for Embedded System Design
If the process is split into multiple threads, which
executes a portion of the process, there will be a main
thread and rest of them will be created within main
thread.
Use of multiple threads to execute a process results in
following advantages:
Better Memory Utilization: multiple threads of
same process share address space for data memory,
also reduces inter thread communication since variables
will be shared.
Speedy execution: since process splits into different
threads, when one thread enters wait state other thread
can be scheduled.
Efficient CPU Utilization: CPU is engaged all time
Process with multi-threads
The concept of Multithreading:
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 18
RTOS for Embedded System Design
Thread standard deals with different standards available for thread creation and management.
These standards utilize OS for thread creation and management. It is a set of thread class libraries.
The commonly available thread class libraries are POSIX threads, Win32 Threads, Java Threads etc.
Thread Standard:
POSIX Threads:
Stands for Portable Operating System Interface.
POSIX. 4 standard deals with real time extensions and POSIX.4a standard deals with thread extensions.
The POSIX standard library for thread creation and management is ‘Pthreads’.
The Pthreads library defines the set of POSIX thread creation and management functions in ‘C’ language.
int pthread_create(pthread_t *new_thread_ID, const pthread_attr_t *attribute,
void * (*start function) (void *), void *arguments;
The above primitive is used for creating new thread for running the function start_function.
Here pthread_t is the handle to newly created thread and pthread_attr_t is data type for holding thread attributes.
Start_function is the function, the thread is going to execute, arguments is the arguments for start_function
On successful creation of a Pthread, Pthread_create() associates the TCB corresponding to the newly created thread to
variable of type Pthread_t
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 19
RTOS for Embedded System Design
int pthread_join (pthread_t new_thread, void *, *thread_status);
The above primitive blocks the current thread and waits until the completion of the thread pointed by it.
All POSIX thread calls return an integer.
A return value of zero indicates the success of the call. It is always good to check the return value of each call.
Example:
Write a multithread appliction to print “Hello I’m in main thread” from the main thread and “Hello I’m in new
thread” 5 times each, using pthread_create() and pthread_join() POSIX primitives.
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
Void *new_thread (void *thread_args)
{
int i,j;
for (j=0;j<5;j++)
{
printf( “Hello I’m in new threadn”);
for (i=0;i<10000;i++)
}
return NULL;
}
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 20
RTOS for Embedded System Design
if (pthread_join(tcb, NULL))
{
printf(“Error in thread joiningn”);
return -1;
}
return 1;
}
int main (void)
{
int i,j;
pthread_t tcb;
If (pthread_create(&tcb, NULL, new-thread ,NULL))
{
printf(“Error in creating new threadn”);
return -1;
}
for (j=0;j<5;j++)
{
printf( “Hello I’m in main threadn”);
for (i=0;i<10000;i++)
}
Termination of thread can happen in different ways:
•Natural termination—threads completes executions and returns
back to main thread through simple return or by executing
pthread_exit().
•Forced termination—by calling pthread_cancel() or termination
of main thread with exit or exec function.
Exiting with pthread_exit() will not perform a cleanup.
Calling pthread_join() at the end of main thread is best way to
achieve synchronization and cleanup.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 21
RTOS for Embedded System Design
Thread is a single unit of execution and is part of
process.
Process is a program in execution and contains one or
more threads.
Thread does not have its own data memory and
heap memory. It shares the data memory and
heap memory with other threads of same process.
Process has its own code memory, data memory and stack
memory
Thread cannot live independently: it lives within
the process.
Process contains at least one thread
There can be multiple threads in a process. The
first thread calls the main function and occupies
the start of stack memory of the process.
Threads within a Process shares data, code and heap
memory. Each thread holds separate memory area for
stack.(Share the total stack memory of process)
Threads are very inexpensive to create. Process are very expensive to create as they involve many
OS overhead.
Context switching is inexpensive. and fast Context switching is complex and involves lot of OS
overhead and comparatively slower.
If a Thread expires, its stack is reclaimed by the
process.
If a process dies, the resources allocated to it reclaimed by
OS and all associated threads of the process also dies.
Thread Process
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 22
RTOS for Embedded System Design
Multiprocessing and Multitasking
Multiprocessing and Multitasking sounds alike.
In OS context Multiprocessing describes the ability to execute multiple process simultaneously.
Systems that are capable of performing multiprocessing, are known as multiprocessor systems.
Multiprocessor systems posses multiple processors (CPUs) and can execute multiple processes simultaneously.
The ability of OS multiple programs in memory, which are ready for execution is referred as
Multiprogramming.
In uniprocessor system, it is not possible to execute multiple process simultaneously.
However with uniprocessor system it is possible to achieve some degree of pseudo parallelism in the execution
of multiple processes by switching the execution among different processes.
The ability of the processor to hold multiple processes in memory and switch the processor from executing one
process to another process is known as multitasking.
Multitasking creates the illusion of multiple tasks executing in parallel.
Ina multitasking environment when task/process switching happens, the virtual processor (task/process) gets its
properties converted into that of physical processor. This is controlled by scheduler of OS kernel.
Whenever a CPE switching happens, the current context of execution should be saved to retrieve it at a later
stage when CPU switches to process which was interrupted due to execution switching.
This context saving and later retrieval is essential for resuming exactly from the point where it was interrupted.
Act of switching CPU among the processes or changing current execution context— ‘Context switching’
Act of saving the current context details(Registers, memory, system resource, execution time etc.)— ‘Context
saving’
Process of retrieving the saved context details for a process, which is going to resume its execution— ‘Context
retrieval’
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23
RTOS for Embedded System Design
Multiprocessing and Multitasking
Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’.
Time
Process
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23
RTOS for Embedded System Design
Multiprocessing and Multitasking
Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’.
Time
Process 1
Process
running
idle
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23
RTOS for Embedded System Design
Multiprocessing and Multitasking
Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’.
Time
Process 1
Process
running
idle
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23
RTOS for Embedded System Design
Multiprocessing and Multitasking
Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’.
Time
Process 1
Process
running
idle
Process 2
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23
RTOS for Embedded System Design
Multiprocessing and Multitasking
Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’.
Time
Process 1
Process
running
idle
Process 2
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23
RTOS for Embedded System Design
Multiprocessing and Multitasking
Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’.
Time
Process 1
Process
running
idle
Process 2
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23
RTOS for Embedded System Design
Multiprocessing and Multitasking
Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’.
Time
Process 1
Process
running
idle
Process 2
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23
RTOS for Embedded System Design
Multiprocessing and Multitasking
Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’.
Time
Process 1
Process
running
idle
Process 2
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23
RTOS for Embedded System Design
Multiprocessing and Multitasking
Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’.
Time
Process 1
Process
running
idle
Process 2
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23
RTOS for Embedded System Design
Multiprocessing and Multitasking
Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’.
Time
Process 1
Process
running
idle
Process 2
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23
RTOS for Embedded System Design
Multiprocessing and Multitasking
Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’.
Time
Process 1
Process
running
idle
Process 2
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23
RTOS for Embedded System Design
Multiprocessing and Multitasking
Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’.
Time
Process 1
Process
running
idle
Process 2
Most primitive form of multitasking, in which a task/process gets a chance to execute only when currently
executing voluntarily relinquishes the CPU.
Any task/process can hold CPU as much time as it wants.
This name because, this type of implementation involves mercy of tasks each other for getting CPU time for
execution.
If tasks are non-cooperative, the other tasks have to wait for a long time to get the CPU.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Operating System basics Types of operating systems Task, process and threads
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 24
RTOS for Embedded System Design
Multiprocessing and Multitasking
Types of Multitasking:
Co-operative Multitasking:
Preemptive Multitasking:
Non-Preemptive Multitasking:
Ensures that every task/process gets a chance to execute.
When and how much time a process gets is dependent on the implementation of preemptive scheduling.
The currently running task/process is preempted to give a chance to other tasks/processes to execute.
Preemption of task may be based on time slots or task/process priority.
The task/process to which CPU is currently allocated is allocated to execute until it terminates or enters
‘Blocked/wait’state, waiting for I/O or system resource.
In cooperative multitasking process/task will not relinquish CPU when it enters s ‘Blocked/wait’state.
Where as in Non-preemptive multitasking currently executing process/task relinquish CPU when it waits for an
I/O or system resource or an event to occur.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 25
RTOS for Embedded System Design
0000 Task scheduling
Operating System basics Types of operating systems Task, process and threads
0000 Task schedulingMultiprocessing and Multitasking
There should be some mechanism in place to share the CPU among the different tasks and to decide which
process/task is to be executed at a given point of time.
Determining which task/process is to be executed at given point if time is known as Task Scheduling.
Task scheduling forms the basis for multitasking.
Scheduling polices form the guidelines for determining which task is to be executed when.
The scheduling polices are run in an algorithm by the OS kernel as a service.
The kernel service/application which implements scheduling algorithm, is known as Scheduler.
The process scheduling decision may take place under 4 scenarios, when a process switches its state to:
•Ready’ State from ‘Running’State — Scenario 1
•‘Blocked/Wait’State from ‘Running’State — Scenario 2
•‘Ready’ State from ‘Blocked/Wait’State — Scenario 3
•‘Completed’State — Scenario 4
Scenario 1: A process switches to ‘Ready’ state from ‘Running’ state when its preempted.— Preemptive Scheduling.
Scheduling in Scenario 2 can be either preemptive or non-preemptive.
Scenario 3: When a high priority process in Blocked/Wait Ready state , the scheduler picks it for execution if
scheduling policy is priority based preemptive.
Scheduling under Scenario 4 can be preemptive, non-preemptive or cooperative scheduling.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 26
RTOS for Embedded System Design
0000 Task scheduling
Operating System basics Types of operating systems Task, process and threads
0000 Task schedulingMultiprocessing and Multitasking
The selection of a scheduling criterion/algorithm should consider the following factors:
CPU Utilization: should be high. It is the direct measure of how much percentage of CPU is being utilized.
Throughput: indicates no. of processes executed per unit time. It should always be higher.
Turnaround time: It is the amount of time taken by a process for completing its execution.
It includes time spent by process for waiting for the main memory, time spent in the ready queue, time
spent on completing I/O operations and time spent in execution.
Waiting Time: It is the amount of time spent by process in ‘Ready’ queue waiting to get CPU, should be minimal.
Response Time: time elapsed between submission of process and the first response, should be as least as possible.
The OS maintains various queues in connection with CPU scheduling and a process passes through these queues
during the course of admittance to execution completion.
•Job queue: contains all processes in the system.
•Ready queue: contains all processes which are ready for execution and waiting for CPU. Empty when no
process is ready for running.
•Device queue contains a processes, which are waiting for an I/O device
Therefore a good scheduling algorithm should have high CPU utilization, minimum Turn Around Time
(TAT), maximum throughput and least response time.
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27
RTOS for Embedded System Design
0000 Task scheduling
Operating System basics Types of operating systems Task, process and threads
0000 Task schedulingMultiprocessing and Multitasking
Now let us consider an diagrammatic representation that shows transition of Process through various queues:
Illustration of Process transition through various queues
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27
RTOS for Embedded System Design
0000 Task scheduling
Operating System basics Types of operating systems Task, process and threads
0000 Task schedulingMultiprocessing and Multitasking
Now let us consider an diagrammatic representation that shows transition of Process through various queues:
Illustration of Process transition through various queues
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27
RTOS for Embedded System Design
0000 Task scheduling
Operating System basics Types of operating systems Task, process and threads
0000 Task schedulingMultiprocessing and Multitasking
Now let us consider an diagrammatic representation that shows transition of Process through various queues:
Illustration of Process transition through various queues
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27
RTOS for Embedded System Design
0000 Task scheduling
Operating System basics Types of operating systems Task, process and threads
0000 Task schedulingMultiprocessing and Multitasking
Now let us consider an diagrammatic representation that shows transition of Process through various queues:
Illustration of Process transition through various queues
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27
RTOS for Embedded System Design
0000 Task scheduling
Operating System basics Types of operating systems Task, process and threads
0000 Task schedulingMultiprocessing and Multitasking
Now let us consider an diagrammatic representation that shows transition of Process through various queues:
Illustration of Process transition through various queues
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27
RTOS for Embedded System Design
0000 Task scheduling
Operating System basics Types of operating systems Task, process and threads
0000 Task schedulingMultiprocessing and Multitasking
Now let us consider an diagrammatic representation that shows transition of Process through various queues:
Illustration of Process transition through various queues
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27
RTOS for Embedded System Design
0000 Task scheduling
Operating System basics Types of operating systems Task, process and threads
0000 Task schedulingMultiprocessing and Multitasking
Now let us consider an diagrammatic representation that shows transition of Process through various queues:
Illustration of Process transition through various queues
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27
RTOS for Embedded System Design
0000 Task scheduling
Operating System basics Types of operating systems Task, process and threads
0000 Task schedulingMultiprocessing and Multitasking
Now let us consider an diagrammatic representation that shows transition of Process through various queues:
Illustration of Process transition through various queues
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27
RTOS for Embedded System Design
0000 Task scheduling
Operating System basics Types of operating systems Task, process and threads
0000 Task schedulingMultiprocessing and Multitasking
Now let us consider an diagrammatic representation that shows transition of Process through various queues:
Illustration of Process transition through various queues
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27
RTOS for Embedded System Design
0000 Task scheduling
Operating System basics Types of operating systems Task, process and threads
0000 Task schedulingMultiprocessing and Multitasking
Now let us consider an diagrammatic representation that shows transition of Process through various queues:
Illustration of Process transition through various queues
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56
Operating System basics Types of operating systems Task, process and threads
Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
RTOS for Embedded System Design
0000 Task scheduling
Operating System basics Types of operating systems Task, process and threads
0000 Task schedulingMultiprocessing and Multitasking
Non-Preemptive Scheduling:
Non-Preemptive Scheduling is employed in systems, which implement non-preemptive multitasking model.
The currently executing task/process is allowed to run until it terminates or enters the Block/Wait state waiting for
an I/O or system resource.
The various types of non-preemptive scheduling adopted in task/process scheduling are:
First Come First Served (FCFS)/FIFO Scheduling
Last Come First Served (LCFS)/LIFO Scheduling
Shortest Job First (SJF) Scheduling
Priority Based Scheduling
Allocates CPU time to the process based on order in which they enter the ‘Ready’ queue.
Example is Ticket reservation system where people need to stand in a queue and the first person in the queue is
serviced first.
The first entered process is serviced first, also called as First In First Out (FIFO) scheduling.
First Come First Served (FCFS)/FIFO Scheduling:
28
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design
RTOS for Embedded System Design

More Related Content

What's hot

Computational models
Computational modelsComputational models
Computational modelsanand hd
 
Chapter 3 Charateristics and Quality Attributes of Embedded System
Chapter 3 Charateristics and Quality Attributes of Embedded SystemChapter 3 Charateristics and Quality Attributes of Embedded System
Chapter 3 Charateristics and Quality Attributes of Embedded SystemMoe Moe Myint
 
Unit 2 processor&amp;memory-organisation
Unit 2 processor&amp;memory-organisationUnit 2 processor&amp;memory-organisation
Unit 2 processor&amp;memory-organisationPavithra S
 
BUilt-In-Self-Test for VLSI Design
BUilt-In-Self-Test for VLSI DesignBUilt-In-Self-Test for VLSI Design
BUilt-In-Self-Test for VLSI DesignUsha Mehta
 
Chapter 4 Embedded System: Application and Domain Specific
Chapter 4 Embedded System: Application and Domain SpecificChapter 4 Embedded System: Application and Domain Specific
Chapter 4 Embedded System: Application and Domain SpecificMoe Moe Myint
 
Task communication
Task communicationTask communication
Task communication1jayanti
 
Device drivers and interrupt service mechanism
Device drivers and interrupt service mechanismDevice drivers and interrupt service mechanism
Device drivers and interrupt service mechanismVijay Kumar
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 80869840596838
 
M ary psk and m ary qam ppt
M ary psk and m ary qam pptM ary psk and m ary qam ppt
M ary psk and m ary qam pptDANISHAMIN950
 
Rs232 485 fundamental
Rs232 485 fundamentalRs232 485 fundamental
Rs232 485 fundamentalrounak077
 
VLSI Testing Techniques
VLSI Testing TechniquesVLSI Testing Techniques
VLSI Testing TechniquesA B Shinde
 
4.4 diversity combining techniques
4.4   diversity combining techniques4.4   diversity combining techniques
4.4 diversity combining techniquesJAIGANESH SEKAR
 
Communication Interface of The Embedded Systems
Communication Interface of The Embedded Systems Communication Interface of The Embedded Systems
Communication Interface of The Embedded Systems VijayKumar5738
 

What's hot (20)

Computational models
Computational modelsComputational models
Computational models
 
Chapter 3 Charateristics and Quality Attributes of Embedded System
Chapter 3 Charateristics and Quality Attributes of Embedded SystemChapter 3 Charateristics and Quality Attributes of Embedded System
Chapter 3 Charateristics and Quality Attributes of Embedded System
 
ARM Processors
ARM ProcessorsARM Processors
ARM Processors
 
VLSI routing
VLSI routingVLSI routing
VLSI routing
 
Unit 2 processor&amp;memory-organisation
Unit 2 processor&amp;memory-organisationUnit 2 processor&amp;memory-organisation
Unit 2 processor&amp;memory-organisation
 
BUilt-In-Self-Test for VLSI Design
BUilt-In-Self-Test for VLSI DesignBUilt-In-Self-Test for VLSI Design
BUilt-In-Self-Test for VLSI Design
 
Chapter 4 Embedded System: Application and Domain Specific
Chapter 4 Embedded System: Application and Domain SpecificChapter 4 Embedded System: Application and Domain Specific
Chapter 4 Embedded System: Application and Domain Specific
 
Task communication
Task communicationTask communication
Task communication
 
Design for Testability
Design for Testability Design for Testability
Design for Testability
 
Device drivers and interrupt service mechanism
Device drivers and interrupt service mechanismDevice drivers and interrupt service mechanism
Device drivers and interrupt service mechanism
 
Hardware-Software Codesign
Hardware-Software CodesignHardware-Software Codesign
Hardware-Software Codesign
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
06. thumb instructions
06. thumb instructions06. thumb instructions
06. thumb instructions
 
M ary psk and m ary qam ppt
M ary psk and m ary qam pptM ary psk and m ary qam ppt
M ary psk and m ary qam ppt
 
Rs232 485 fundamental
Rs232 485 fundamentalRs232 485 fundamental
Rs232 485 fundamental
 
Lambda design rule
Lambda design ruleLambda design rule
Lambda design rule
 
IS-95 Cdma
IS-95 CdmaIS-95 Cdma
IS-95 Cdma
 
VLSI Testing Techniques
VLSI Testing TechniquesVLSI Testing Techniques
VLSI Testing Techniques
 
4.4 diversity combining techniques
4.4   diversity combining techniques4.4   diversity combining techniques
4.4 diversity combining techniques
 
Communication Interface of The Embedded Systems
Communication Interface of The Embedded Systems Communication Interface of The Embedded Systems
Communication Interface of The Embedded Systems
 

Similar to RTOS for Embedded System Design

Operating system basics, Types of operating systems, Tasks, Process and Thre...
Operating system basics, Types of operating  systems, Tasks, Process and Thre...Operating system basics, Types of operating  systems, Tasks, Process and Thre...
Operating system basics, Types of operating systems, Tasks, Process and Thre...SattiBabu16
 
Kernel security Concepts
Kernel security ConceptsKernel security Concepts
Kernel security ConceptsMohit Saxena
 
Structure of Operating System
Structure of Operating System Structure of Operating System
Structure of Operating System anand hd
 
operating system over view.ppt operating sysyems
operating system over view.ppt operating sysyemsoperating system over view.ppt operating sysyems
operating system over view.ppt operating sysyemsJyoReddy9
 
Introduction to Operating System
Introduction to Operating SystemIntroduction to Operating System
Introduction to Operating SystemDivya S
 
Operating system
Operating systemOperating system
Operating systemmak120
 
Ch1kiit [compatibility mode]
Ch1kiit [compatibility mode]Ch1kiit [compatibility mode]
Ch1kiit [compatibility mode]Amit Gupta
 
Operating System Introduction
Operating System IntroductionOperating System Introduction
Operating System IntroductionSravani Kommuri
 
OPERATING SYSTEM
OPERATING SYSTEM OPERATING SYSTEM
OPERATING SYSTEM Khehra Saab
 
Docs_CSEOSLNotes2013.pdf
Docs_CSEOSLNotes2013.pdfDocs_CSEOSLNotes2013.pdf
Docs_CSEOSLNotes2013.pdfGGESBachianwali
 
OS - Ch1
OS - Ch1OS - Ch1
OS - Ch1sphs
 
Chapter 1 - Introduction
Chapter 1 - IntroductionChapter 1 - Introduction
Chapter 1 - IntroductionWayne Jones Jnr
 
Operating systems. replace ch1 with numbers for next chapters
Operating systems. replace ch1 with numbers for next chaptersOperating systems. replace ch1 with numbers for next chapters
Operating systems. replace ch1 with numbers for next chapterssphs
 
Unit 1-Operating Systems Overview .pptx
Unit 1-Operating Systems Overview .pptxUnit 1-Operating Systems Overview .pptx
Unit 1-Operating Systems Overview .pptxThamaraiselviAvinuty
 

Similar to RTOS for Embedded System Design (20)

UNIT 2.pptx
UNIT 2.pptxUNIT 2.pptx
UNIT 2.pptx
 
Operating system basics, Types of operating systems, Tasks, Process and Thre...
Operating system basics, Types of operating  systems, Tasks, Process and Thre...Operating system basics, Types of operating  systems, Tasks, Process and Thre...
Operating system basics, Types of operating systems, Tasks, Process and Thre...
 
Kernel security Concepts
Kernel security ConceptsKernel security Concepts
Kernel security Concepts
 
Structure of Operating System
Structure of Operating System Structure of Operating System
Structure of Operating System
 
operating system over view.ppt operating sysyems
operating system over view.ppt operating sysyemsoperating system over view.ppt operating sysyems
operating system over view.ppt operating sysyems
 
Introduction to Operating System
Introduction to Operating SystemIntroduction to Operating System
Introduction to Operating System
 
Operating system
Operating systemOperating system
Operating system
 
Ch1kiit [compatibility mode]
Ch1kiit [compatibility mode]Ch1kiit [compatibility mode]
Ch1kiit [compatibility mode]
 
Operating System Introduction
Operating System IntroductionOperating System Introduction
Operating System Introduction
 
OPERATING SYSTEM
OPERATING SYSTEM OPERATING SYSTEM
OPERATING SYSTEM
 
Docs_CSEOSLNotes2013.pdf
Docs_CSEOSLNotes2013.pdfDocs_CSEOSLNotes2013.pdf
Docs_CSEOSLNotes2013.pdf
 
Ch1
Ch1Ch1
Ch1
 
OS Intro.ppt
OS Intro.pptOS Intro.ppt
OS Intro.ppt
 
OS - Ch1
OS - Ch1OS - Ch1
OS - Ch1
 
Chapter 1 - Introduction
Chapter 1 - IntroductionChapter 1 - Introduction
Chapter 1 - Introduction
 
Operating systems. replace ch1 with numbers for next chapters
Operating systems. replace ch1 with numbers for next chaptersOperating systems. replace ch1 with numbers for next chapters
Operating systems. replace ch1 with numbers for next chapters
 
Operating System
Operating SystemOperating System
Operating System
 
Cs8493 unit 1
Cs8493 unit 1Cs8493 unit 1
Cs8493 unit 1
 
Unit 1-Operating Systems Overview .pptx
Unit 1-Operating Systems Overview .pptxUnit 1-Operating Systems Overview .pptx
Unit 1-Operating Systems Overview .pptx
 
CH01.pdf
CH01.pdfCH01.pdf
CH01.pdf
 

More from anand hd

RMV sensors
RMV sensorsRMV sensors
RMV sensorsanand hd
 
RMV robot programming
RMV robot programmingRMV robot programming
RMV robot programminganand hd
 
Robot applications
Robot applicationsRobot applications
Robot applicationsanand hd
 
RMV Mechanics
RMV MechanicsRMV Mechanics
RMV Mechanicsanand hd
 
Robot Machine Vision
Robot Machine VisionRobot Machine Vision
Robot Machine Visionanand hd
 
RMV Artificial Intelligence
RMV Artificial IntelligenceRMV Artificial Intelligence
RMV Artificial Intelligenceanand hd
 
OS file systems
OS file systemsOS file systems
OS file systemsanand hd
 
OS virtual memory
OS virtual memoryOS virtual memory
OS virtual memoryanand hd
 
OS scheduling
OS schedulingOS scheduling
OS schedulinganand hd
 
OS Memory Management
OS Memory ManagementOS Memory Management
OS Memory Managementanand hd
 
Modules and ports in Verilog HDL
Modules and ports in Verilog HDLModules and ports in Verilog HDL
Modules and ports in Verilog HDLanand hd
 
Characteristics and Quality Attributes of Embedded System
Characteristics and Quality Attributes of Embedded SystemCharacteristics and Quality Attributes of Embedded System
Characteristics and Quality Attributes of Embedded Systemanand hd
 
Basic concepts in Verilog HDL
Basic concepts in Verilog HDLBasic concepts in Verilog HDL
Basic concepts in Verilog HDLanand hd
 
Overview of digital design with Verilog HDL
Overview of digital design with Verilog HDLOverview of digital design with Verilog HDL
Overview of digital design with Verilog HDLanand hd
 
Typical Embedded System
Typical Embedded SystemTypical Embedded System
Typical Embedded Systemanand hd
 
OS-Process Management
OS-Process ManagementOS-Process Management
OS-Process Managementanand hd
 
Robotics Endeffectors
Robotics EndeffectorsRobotics Endeffectors
Robotics Endeffectorsanand hd
 
Fundamentals of Robotics and Machine Vision System
Fundamentals of Robotics and Machine Vision SystemFundamentals of Robotics and Machine Vision System
Fundamentals of Robotics and Machine Vision Systemanand hd
 
Os overview
Os overviewOs overview
Os overviewanand hd
 
OS introduction
OS introductionOS introduction
OS introductionanand hd
 

More from anand hd (20)

RMV sensors
RMV sensorsRMV sensors
RMV sensors
 
RMV robot programming
RMV robot programmingRMV robot programming
RMV robot programming
 
Robot applications
Robot applicationsRobot applications
Robot applications
 
RMV Mechanics
RMV MechanicsRMV Mechanics
RMV Mechanics
 
Robot Machine Vision
Robot Machine VisionRobot Machine Vision
Robot Machine Vision
 
RMV Artificial Intelligence
RMV Artificial IntelligenceRMV Artificial Intelligence
RMV Artificial Intelligence
 
OS file systems
OS file systemsOS file systems
OS file systems
 
OS virtual memory
OS virtual memoryOS virtual memory
OS virtual memory
 
OS scheduling
OS schedulingOS scheduling
OS scheduling
 
OS Memory Management
OS Memory ManagementOS Memory Management
OS Memory Management
 
Modules and ports in Verilog HDL
Modules and ports in Verilog HDLModules and ports in Verilog HDL
Modules and ports in Verilog HDL
 
Characteristics and Quality Attributes of Embedded System
Characteristics and Quality Attributes of Embedded SystemCharacteristics and Quality Attributes of Embedded System
Characteristics and Quality Attributes of Embedded System
 
Basic concepts in Verilog HDL
Basic concepts in Verilog HDLBasic concepts in Verilog HDL
Basic concepts in Verilog HDL
 
Overview of digital design with Verilog HDL
Overview of digital design with Verilog HDLOverview of digital design with Verilog HDL
Overview of digital design with Verilog HDL
 
Typical Embedded System
Typical Embedded SystemTypical Embedded System
Typical Embedded System
 
OS-Process Management
OS-Process ManagementOS-Process Management
OS-Process Management
 
Robotics Endeffectors
Robotics EndeffectorsRobotics Endeffectors
Robotics Endeffectors
 
Fundamentals of Robotics and Machine Vision System
Fundamentals of Robotics and Machine Vision SystemFundamentals of Robotics and Machine Vision System
Fundamentals of Robotics and Machine Vision System
 
Os overview
Os overviewOs overview
Os overview
 
OS introduction
OS introductionOS introduction
OS introduction
 

Recently uploaded

CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 

Recently uploaded (20)

CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 

RTOS for Embedded System Design

  • 1. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 RTOS for Embedded System Design Mr. Anand H. D. 1 RTOS for Embedded System Design Department of Electronics & Communication Engineering Dr. Ambedkar Institute of Technology Bengaluru-56
  • 2. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 2 RTOS for Embedded System Design SYLLABUS: Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS.
  • 3. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 3 RTOS for Embedded System Design Operating System (OS) acts as a bridge between user applications/tasks and the underlying 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 . The primary functions of OS are: 1. Make the system convenient to use. 2. Organize and mange the system resources efficiently and correctly.  Is the core of OS and is responsible for managing the system resources and the communication among the hardware and other system services.  Acts as the abstraction layer between system resources and user applications.  Contains a set of system libraries and services. The Kernel:
  • 4. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 4 RTOS for Embedded System Design Now let us consider the Architecture of OS: General Purpose OS contains different services for handling
  • 5. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 4 RTOS for Embedded System Design Now let us consider the Architecture of OS: Primary Memory Management: Refers to volatile memory RAM, where processes are loaded and variables and shared data associated with process are stored. The Memory Management Unit (MMU) of the kernel is responsible for •Keeping track of which part of memory area is currently used by which process. •Allocating and de-allocating memory space on need basis (Dynamic Memory Allocation) General Purpose OS contains different services for handling
  • 6. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 4 RTOS for Embedded System Design Now let us consider the Architecture of OS: Primary Memory Management: Refers to volatile memory RAM, where processes are loaded and variables and shared data associated with process are stored. The Memory Management Unit (MMU) of the kernel is responsible for •Keeping track of which part of memory area is currently used by which process. •Allocating and de-allocating memory space on need basis (Dynamic Memory Allocation) General Purpose OS contains different services for handling Process Management: •Deals with managing the processes/tasks. •By setting up the memory space for the process, loading the process’s code into the memory space, allocating system resources, scheduling and managing execution of process, setting up and managing the Process Control Block (PCB), Inter-process Communication and synchronization, process termination/deletion etc.
  • 7. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 4 RTOS for Embedded System Design Time Management: Deals with at what time which process needs to be scheduled. Till what duration processes needs to be executed. After what time a process needs to be preempted.
  • 8. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 4 RTOS for Embedded System Design Time Management: Deals with at what time which process needs to be scheduled. Till what duration processes needs to be executed. After what time a process needs to be preempted. File System Management: File is collection of information. A file could be a program, text file, image file, word documents, audio/video files etc. Each of these files differ in kind of information they hold and the way in which information is stored. The file system management service of kernel is responsible for: •Creation, deletion and alteration of files. •Creation, deletion and alteration of directories. •Saving of files in secondary storage memory. •Providing automatic allocation of file space based on amount of free space available. •Providing a flexible naming convention for the files. The various file system management operations are OS dependent.
  • 9. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 4 RTOS for Embedded System Design 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 direct access of I/O devices is not allowed and access to them is provided through a Application Programming Interfaces (API) exposed by kernel. Kernel maintains a list of I/O devices of the system. This list may be available well in advance at the time of building the kernel or in cases Kernels dynamically updates the list and where the new device is installed. The service ‘Device Manager’ is responsible handling all I/O device related operations. The kernel talks to I/O devices through a set of low level system calls, which are implemented in a service called device drivers. These drivers are specific to a device or a class of devices. The device manager is responsible for : •Loading & unloading of device drivers. • Exchanging information and the system specific controls to and from the device.
  • 10. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 4 RTOS for Embedded System Design The Operating System Architecture
  • 11. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 5 RTOS for Embedded System Design Secondary Storage Management: Deals with management of secondary storage devices. Secondary memory is used as a backup medium for program and data since the main memory is volatile. In most of the systems the secondary storage is in the for of disks (Hard disks). The secondary storage management services of kernel deals with : Disk Storage allocation. Disk Scheduling . Free disk space management Protection System: Most of the modern OS are deigned in such a way that they support multiple users with different levels of access permissions . Protection deals with implementing the security polices to restrict the access to both user and system resources by different applications or processes or users. In multiuser OS, one user may not be allowed to view or modify complete portion of another user’s data or profile details. Also some applications may not be granted permissions to make use of certain system resources. Interrupt Handler: Kernel provides handler mechanism for all external/internal interrupts generated by the system. These are some of the services offered by kernel of an OS. Depending on type of OS, a kernel may contain lesser/more number of services/components. In addition to above mentioned services many OS offer a no. of add-on services to kernel, Network communication, network management, user-interface graphics, timer services, error handler, database management etc.
  • 12. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 6 RTOS for Embedded System Design The applications/services are classified into : User applications and Kernel applications The program code corresponding to kernel applications/services are kept in contiguous area of primary memory and is protected from unauthorized access by user programs/applications—Kernel Space All user programs are loaded to a specific area of primary memory and this memory area is referred as User space. The portioning of memory into Kernel space and user space is purely OS dependent. In OS with virtual memory support, the user applications are loaded into corresponding virtual memory space with demand paging technique — the entire code for user application need not be loaded into main memory at once; instead user application is divided into different pages and these pages are loaded into and out of main memory area on a need basis – Swapping. Swapping happens between main memory and secondary storage memory. Each process run in its own virtual memory space and are not allowed accessing the memory space corresponding to another processes unless explicitly requested by the process. Most of the OS keep the kernel application code in main memory and it is not swapped out into the secondary memory. Kernel Space Vs User Space:
  • 13. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 7 RTOS for Embedded System Design Monolithic Kernel and Microkernel: Monolithic Kernel In monolithic kernel architecture, all kernel services run in the kernel space. All kernel modules run in same memory space under a single kernel thread. Tight internal integration of kernel modules allows the effective utilization of the low level features of the underlying system. Major drawback is that any error or failure in any one of the kernel modules leads to the crashing of entire kernel applications. LINUX, MS-DOS, SOLARIS are examples of monolithic kernel OS. The Monolithic kernel Model
  • 14. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 8 RTOS for Embedded System Design Microkernel Incorporates only essential set of OS services into the kernel and rest of OS services are implemented in programs known as Servers which run in user space. Provides a highly modular design and OS-neutral abstraction to the kernel. Memory management, process management, time system and interrupt handlers are essential services which forms the part of microkernel. Mach, QNX, MINIX3 are examples of microkernel OS. Offers 2 benefits: •Robustness: server programs can be reconfigured & restarted, chances of corruption are ideally zero. •Configurability: any server application can be changed without restarting the entire system—dynamically configurable The Microkernel Model
  • 15. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 9 RTOS for Embedded System Design Depending on kernel and kernel services, purpose and type of computing systems where OS is deployed and responsiveness to applications, OSs are classified into 2 types: General Purpose Operating System (GPOS) Real-Time Operating System (RTOS) General Purpose Operating System (GPOS) Deployed in general computing systems. Kernel is more generalized and it contains all kinds of services required for executing generic applications. Often non-deterministic in behavior, there services can inject random delays into application software and may cause slow responsiveness of an application at unexpected times. They are often deployed in general computing systems where deterministic behavior is not important. Personal computers/desktop system is typical example of a system where GPOS is deployed. Windows XP/MS-DOS etc. are examples of GPOSs. Real-Time Operating System (RTOS) Real-time implies deterministic timing behavior. Means OS services consumes only known and expected amounts of time regardless the number of services. RTOS implements policies and rules concerning time- critical allocation of system resources. RTOS decides which application should run in which order and how much time must be allocated for each application. Predictable performance is hallmark of RTOS. This is achievable by consistent application of policies and rules. Windows CE, QNX, VxWorks, MicroC/OS-II etc. are examples of RTOS
  • 16. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10 RTOS for Embedded System Design Real Time Kernel: kernel of RTOS Compare to conventional OS kernel Real Time kernel is highly specialized and it contains only minimal set of services required for running the user applications/tasks. The basic functions of Real Time Kernel are: •Task/Process management. •Task/Process scheduling. •Task/Process synchronization. •Error/Exception Handling. •Memory management. •Interrupt Handling. •Time Management
  • 17. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10 RTOS for Embedded System Design Real Time Kernel: kernel of RTOS Compare to conventional OS kernel Real Time kernel is highly specialized and it contains only minimal set of services required for running the user applications/tasks. The basic functions of Real Time Kernel are: •Task/Process management. •Task/Process scheduling. •Task/Process synchronization. •Error/Exception Handling. •Memory management. •Interrupt Handling. •Time Management 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, termination and deletion. TCB is used to hold information corresponding to task which includes: Implementation of TCB is kernel dependent. Task management service uses TCB of a task in following way: •Creates a TCB for a task on creating a task. •Delete/remove TCB of task when task is terminated/deleted •Reads TCB to get the state of task. •Update TCB with updated parameters on need basis. •Modify TCB to change task priority dynamically. •Task ID •Task state •Task type •Task Priority •Task context pointer •Task memory pointers •Task system resource pointers •Task pointers.
  • 18. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10 RTOS for Embedded System Design Real Time Kernel: kernel of RTOS Compare to conventional OS kernel Real Time kernel is highly specialized and it contains only minimal set of services required for running the user applications/tasks. The basic functions of Real Time Kernel are: •Task/Process management. •Task/Process scheduling. •Task/Process synchronization. •Error/Exception Handling. •Memory management. •Interrupt Handling. •Time Management 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, termination and deletion. TCB is used to hold information corresponding to task which includes: Implementation of TCB is kernel dependent. Task management service uses TCB of a task in following way: •Creates a TCB for a task on creating a task. •Delete/remove TCB of task when task is terminated/deleted •Reads TCB to get the state of task. •Update TCB with updated parameters on need basis. •Modify TCB to change task priority dynamically. Task/Process scheduling: Deals with sharing CPU among various tasks/processes. A kernel service called ‘Scheduler’ handles task scheduling. Scheduler is nothing but an algorithm implementation which performs the efficient and optimal scheduling of task to provide a deterministic behavior. •Task ID •Task state •Task type •Task Priority •Task context pointer •Task memory pointers •Task system resource pointers •Task pointers.
  • 19. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10 RTOS for Embedded System Design Real Time Kernel: kernel of RTOS Compare to conventional OS kernel Real Time kernel is highly specialized and it contains only minimal set of services required for running the user applications/tasks. The basic functions of Real Time Kernel are: •Task/Process management. •Task/Process scheduling. •Task/Process synchronization. •Error/Exception Handling. •Memory management. •Interrupt Handling. •Time Management Task/Process synchronization: Deals with the synchronization of concurrent access of resources, which is shared across multiple tasks and communication between various tasks.
  • 20. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10 RTOS for Embedded System Design Real Time Kernel: kernel of RTOS Compare to conventional OS kernel Real Time kernel is highly specialized and it contains only minimal set of services required for running the user applications/tasks. The basic functions of Real Time Kernel are: •Task/Process management. •Task/Process scheduling. •Task/Process synchronization. •Error/Exception Handling. •Memory management. •Interrupt Handling. •Time Management Task/Process synchronization: Deals with the synchronization of concurrent access of resources, which is shared across multiple tasks and communication between various tasks. Error/Exception Handling: Deals with registering and handling the errors occurred/exceptions raised during execution of tasks. Insufficient memory, timeouts, deadlocks, deadline missing, bus error, divide by zero, unknown instruction execution etc. are examples of errors/exceptions. Errors/Exceptions can occur at kernel level services or at task level. Deadlock is an kernel level error whereas timeout is an example for task level. The OS kernel gives the information in the form of System Call (API). Watchdog timer will be used for handling timeouts.
  • 21. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10 RTOS for Embedded System Design Real Time Kernel: kernel of RTOS Compare to conventional OS kernel Real Time kernel is highly specialized and it contains only minimal set of services required for running the user applications/tasks. The basic functions of Real Time Kernel are: •Task/Process management. •Task/Process scheduling. •Task/Process synchronization. •Error/Exception Handling. •Memory management. •Interrupt Handling. •Time Management Task/Process synchronization: Deals with the synchronization of concurrent access of resources, which is shared across multiple tasks and communication between various tasks. Error/Exception Handling: Deals with registering and handling the errors occurred/exceptions raised during execution of tasks. Insufficient memory, timeouts, deadlocks, deadline missing, bus error, divide by zero, unknown instruction execution etc. are examples of errors/exceptions. Errors/Exceptions can occur at kernel level services or at task level. Deadlock is an kernel level error whereas timeout is an example for task level. The OS kernel gives the information in the form of System Call (API). Watchdog timer will be used for handling timeouts. Memory Management: Compare to GPOS, memory management of RTOS is slightly different. Memory allocation time increases depending upon the block of memory needs to be allocated and state of allocated memory. RTOS makes use of ‘block’ based memory allocation technique instead of usual dynamic memory allocation used by GPOS. RTOS kernel uses blocks of fixed size of dynamic memory and block is allocated to a task on need basis. The blocks are stored in ‘free buffer queues’. To achieve predictable timing and avoid timing overhead, RTOS allows task to access any memory blocks without any memory protection. Few RTOS kernels implement Virtual Memory concept of memory allocation if system supports secondary memory storage.
  • 22. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10 RTOS for Embedded System Design Real Time Kernel: kernel of RTOS Compare to conventional OS kernel Real Time kernel is highly specialized and it contains only minimal set of services required for running the user applications/tasks. The basic functions of Real Time Kernel are: •Task/Process management. •Task/Process scheduling. •Task/Process synchronization. •Error/Exception Handling. •Memory management. •Interrupt Handling. •Time Management Interrupt Handling: Deals with handling different types of interrupts. Interrupts provide Real time behavior to system. Interrupts inform the processor that an external device or an associated task requires immediate attention of CPU. Interrupts can be Synchronous or Asynchronous. Interrupts that occur in sync with currently executing task are known as Synchronous interrupts — usually software interrupts – divide by 0, memory segmentation error etc. are few examples. For Synchronous interrupts the interrupt handler runs in same context of interrupting task. Interrupts that occur at any point of execution of any task and are not in sync with currently executing task are Asynchronous interrupts. – generated by external devices connected to process/controller – timer overflow interrupts, serial data reception/transmission interrupts etc. are examples. For Asynchronous interrupts the interrupt handler is usually written as separate task and it runs in different context. Hence a context-switch occurs while handling an asynchronous interrupt. Priority levels can be assigned to interrupts and each interrupts can be enabled and disabled individually. Most of the RTOS kernel implements ‘Nested interrupts’ architecture, which allows interruption of a Interrupt Service Routine (ISR), while servicing an interrupt, by a high priority interrupt.
  • 23. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10 RTOS for Embedded System Design Real Time Kernel: kernel of RTOS Compare to conventional OS kernel Real Time kernel is highly specialized and it contains only minimal set of services required for running the user applications/tasks. The basic functions of Real Time Kernel are: •Task/Process management. •Task/Process scheduling. •Task/Process synchronization. •Error/Exception Handling. •Memory management. •Interrupt Handling. •Time Management Time Management: Accurate time management is essential for providing precise time reference to all applications. The time reference to kernel is provided by a high resolution Real- Time-Clock (RTC) hardware chip. The hardware time is programmed to interrupt the processor/controller at a fixed interval. This is referred as ‘timer tick’. Usually varies in µsec. If timer tick interval is 1 µsec, system time register will reset in If timer tick interval is 1 millisecond, system time register will reset in This timer tick can be utilized for: •Save the current context. •Increment the timer register by one. •Update the timers implemented in kernel. •Activate the periodic tasks, which are in idle state. •Invoke the scheduler and schedule the tasks again based on scheduling algorithm. •Delete all terminated tasks and associated data structures (TCBs). •Load the context for first task in the ready queue.
  • 24. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 11 RTOS for Embedded System Design Hard Real Time: RTOSs that strictly adhere to the timing constraints for a task are referred as ‘Hard Real Time’systems. Hard real time system must meet the deadlines for a task without any slippage. Missing any deadlines may produce catastrophic results for Hard real time systems including permanent data lose and irrecoverable damages to the system/users. Emphasizes on ‘ a late answer is a wrong answer’ . Air bag control system and Anti-lock Braking System (ABS) are typical examples. The airbag control system must be into action and deploy the airbags when vehicles meet severe accident. Soft Real Time: RTOSs that does not guarantee meeting deadlines but offer the best effort to meet the deadlines are referred as ‘Soft Real Time’systems. Missing deadlines for tasks are acceptable if the frequency of deadline missing is within the compliance limit of ‘Quality of Service (QoS)’ . Emphasizes on ‘ a late answer is a an acceptable answer, but it could have done bit faster’. Most often have ‘Human in the loop (HITL)’ ,Automatic Teller machine (ATM) is a typical example. A audio-video playback system is another example. Ideally speaking the response time of air bag system must be zero and bags should be deployed exactly within the time frame which is predefined. Any delay in deployment of air-bags makes the life of passengers under threat. When the airbag deployment task is triggered, the currently executing task must be preempted, airbag deployment task must be brought into execution and necessary I/O systems should be made readily available As a Thumb rule hard real time systems doesn’t implement virtual memory model. This eliminates the delay in swapping in and out the code. Most of the Hard Real Time systems are automatic and does not contain a ‘human in the loop (HITL)’.
  • 25. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 12 RTOS for Embedded System Design In OS context a ‘task’ is defined as the program in execution and the related information maintained by the OS for the program. A 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 context and most often they are used interchangeably. Process: Also known as an instance of program in execution. Multiple instances of the 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.
  • 26. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 13 RTOS for Embedded System Design Structure of a Process The Structure of a Process: The concept of process leads to concurrent execution of tasks thereby the efficient utilization of CPU and other system resources. A process mimics a processor in properties and holds: •A stack for holding the local variables associated with the process •A set of working registers, •Process status registers, •A Program Counter (PC) to point to next executable instruction of the process and •The code corresponding to process.
  • 27. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 13 RTOS for Embedded System Design Structure of a Process The Structure of a Process: The concept of process leads to concurrent execution of tasks thereby the efficient utilization of CPU and other system resources. A process mimics a processor in properties and holds: •A stack for holding the local variables associated with the process •A set of working registers, •Process status registers, •A Program Counter (PC) to point to next executable instruction of the process and •The code corresponding to process.
  • 28. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 13 RTOS for Embedded System Design Structure of a Process The Structure of a Process: The concept of process leads to concurrent execution of tasks thereby the efficient utilization of CPU and other system resources. A process mimics a processor in properties and holds: •A stack for holding the local variables associated with the process •A set of working registers, •Process status registers, •A Program Counter (PC) to point to next executable instruction of the process and •The code corresponding to process.
  • 29. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 13 RTOS for Embedded System Design Structure of a Process The Structure of a Process: The concept of process leads to concurrent execution of tasks thereby the efficient utilization of CPU and other system resources. A process mimics a processor in properties and holds: •A stack for holding the local variables associated with the process •A set of working registers, •Process status registers, •A Program Counter (PC) to point to next executable instruction of the process and •The code corresponding to process.
  • 30. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 13 RTOS for Embedded System Design Structure of a Process The Structure of a Process: The concept of process leads to concurrent execution of tasks thereby the efficient utilization of CPU and other system resources. A process mimics a processor in properties and holds: •A stack for holding the local variables associated with the process •A set of working registers, •Process status registers, •A Program Counter (PC) to point to next executable instruction of the process and •The code corresponding to process.
  • 31. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 13 RTOS for Embedded System Design The concept of process leads to concurrent execution of tasks thereby the efficient utilization of CPU and other system resources. A process mimics a processor in properties and holds: •A stack for holding the local variables associated with the process •A set of working registers, •Process status registers, •A Program Counter (PC) to point to next executable instruction of the process and •The code corresponding to process. Structure of a Process The Structure of a Process:
  • 32. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 14 RTOS for Embedded System Design A process which inherits all properties of CPU can be considered as a virtual processor, awaiting its turn to have its properties switched into physical processor. When process gets it turn, its registers and the PC register maps to physical registers of CPU. On loading a process into main memory, a specific area of memory is allocated for the process. The memory occupied by process is segregated into 3 regions: •Stack Memory—holds all temporary data such as variables local to the process. •Data Memory – holds all global data for the process. •Code Memory – contains the program code corresponding to process. Stack memory starts at the highest address from allocated memory and grows downwards. Say if allocated memory area for process is 2048-2100, the stack memory starts at address 2100 and grows downwards. Memory organization of a Process Memory Organization of a Process:
  • 33. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 14 RTOS for Embedded System Design A process which inherits all properties of CPU can be considered as a virtual processor, awaiting its turn to have its properties switched into physical processor. When process gets it turn, its registers and the PC register maps to physical registers of CPU. On loading a process into main memory, a specific area of memory is allocated for the process. The memory occupied by process is segregated into 3 regions: •Code Memory – contains the program code corresponding to process. •Stack Memory—holds all temporary data such as variables local to the process. •Data Memory – holds all global data for the process. Stack memory starts at the highest address from allocated memory and grows downwards. Say if allocated memory area for process is 2048-2100, the stack memory starts at address 2100 and grows downwards. Memory organization of a Process Memory Organization of a Process:
  • 34. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 14 RTOS for Embedded System Design A process which inherits all properties of CPU can be considered as a virtual processor, awaiting its turn to have its properties switched into physical processor. When process gets it turn, its registers and the PC register maps to physical registers of CPU. On loading a process into main memory, a specific area of memory is allocated for the process. The memory occupied by process is segregated into 3 regions: •Code Memory – contains the program code corresponding to process. •Data Memory – holds all global data for the process. •Stack Memory—holds all temporary data such as variables local to the process. from allocated memory and grows downwards. Say if allocated memory area for process is 2048-2100, the stack memory starts at address 2100 and grows downwards. Memory organization of a Process Memory Organization of a Process:
  • 35. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 14 RTOS for Embedded System Design A process which inherits all properties of CPU can be considered as a virtual processor, awaiting its turn to have its properties switched into physical processor. When process gets it turn, its registers and the PC register maps to physical registers of CPU. On loading a process into main memory, a specific area of memory is allocated for the process. The memory occupied by process is segregated into 3 regions: •Code Memory – contains the program code corresponding to process. •Data Memory – holds all global data for the process. •Stack Memory—holds all temporary data such as variables local to the process. Stack memory starts at the highest address from allocated memory and grows downwards. Say if allocated memory area for process is 2048-2100, the stack memory starts at address 2100 and grows downwards. Memory organization of a Process Memory Organization of a Process:
  • 36. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 14 RTOS for Embedded System Design A process which inherits all properties of CPU can be considered as a virtual processor, awaiting its turn to have its properties switched into physical processor. When process gets it turn, its registers and the PC register maps to physical registers of CPU. On loading a process into main memory, a specific area of memory is allocated for the process. The memory occupied by process is segregated into 3 regions: •Code Memory – contains the program code corresponding to process. •Data Memory – holds all global data for the process. •Stack Memory—holds all temporary data such as variables local to the process. Stack memory starts at the highest address from allocated memory and grows downwards. Say if allocated memory area for process is 2048-2100, the stack memory starts at address 2100 and grows downwards. Memory organization of a Process Memory Organization of a Process:
  • 37. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 14 RTOS for Embedded System Design A process which inherits all properties of CPU can be considered as a virtual processor, awaiting its turn to have its properties switched into physical processor. When process gets it turn, its registers and the PC register maps to physical registers of CPU. On loading a process into main memory, a specific area of memory is allocated for the process. The memory occupied by process is segregated into 3 regions: •Code Memory – contains the program code corresponding to process. •Data Memory – holds all global data for the process. •Stack Memory—holds all temporary data such as variables local to the process. Stack memory starts at the highest address from allocated memory and grows downwards. Say if allocated memory area for process is 2048-2100, the stack memory starts at address 2100 and grows downwards. Memory organization of a Process Memory Organization of a Process:
  • 38. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15 RTOS for Embedded System Design The creation of a process to its termination is not a single step operation. The process traverses a series of states during its transition from newly created state to terminated state – ‘Process Life Cycle’. ‘Created’ state – state at which a process is created, OS recognizes that a process is created but no resources are allocated. ‘Ready’ state – state where a process is incepted into the memory and awaiting Processor time for execution. Processes is placed in ‘Ready list queue’. ‘Running’ state – state at which a process execution happens. ‘Blocked/Wait’ state – state where a running process is temporarily suspended from execution and does not have immediate access to resources. ‘Completed’ state – state where process completes its execution. Transistion of a process from one state to another is called as ‘State Transistion’ Process Sates & State transition representation Process States and State Transition:
  • 39. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15 RTOS for Embedded System Design The creation of a process to its termination is not a single step operation. The process traverses a series of states during its transition from newly created state to terminated state – ‘Process Life Cycle’. ‘Created’ state – state at which a process is created, OS recognizes that a process is created but no resources are allocated. ‘Ready’ state – state where a process is incepted into the memory and awaiting Processor time for execution. Processes is placed in ‘Ready list queue’. ‘Running’ state – state at which a process execution happens. ‘Blocked/Wait’ state – state where a running process is temporarily suspended from execution and does not have immediate access to resources. ‘Completed’ state – state where process completes its execution. Transistion of a process from one state to another is called as ‘State Transistion’ Process Sates & State transition representation Process States and State Transition:
  • 40. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15 RTOS for Embedded System Design The creation of a process to its termination is not a single step operation. The process traverses a series of states during its transition from newly created state to terminated state – ‘Process Life Cycle’. ‘Created’ state – state at which a process is created, OS recognizes that a process is created but no resources are allocated. ‘Ready’ state – state where a process is incepted into the memory and awaiting Processor time for execution. Processes is placed in ‘Ready list queue’. ‘Running’ state – state at which a process execution happens. ‘Blocked/Wait’ state – state where a running process is temporarily suspended from execution and does not have immediate access to resources. ‘Completed’ state – state where process completes its execution. Transistion of a process from one state to another is called as ‘State Transistion’ Process Sates & State transition representation Process States and State Transition:
  • 41. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15 RTOS for Embedded System Design The creation of a process to its termination is not a single step operation. The process traverses a series of states during its transition from newly created state to terminated state – ‘Process Life Cycle’. ‘Created’ state – state at which a process is created, OS recognizes that a process is created but no resources are allocated. ‘Ready’ state – state where a process is incepted into the memory and awaiting Processor time for execution. Processes is placed in ‘Ready list queue’. ‘Running’ state – state at which a process execution happens. ‘Blocked/Wait’ state – state where a running process is temporarily suspended from execution and does not have immediate access to resources. ‘Completed’ state – state where process completes its execution. Transistion of a process from one state to another is called as ‘State Transistion’ Process Sates & State transition representation Process States and State Transition:
  • 42. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15 RTOS for Embedded System Design The creation of a process to its termination is not a single step operation. The process traverses a series of states during its transition from newly created state to terminated state – ‘Process Life Cycle’. ‘Created’ state – state at which a process is created, OS recognizes that a process is created but no resources are allocated. ‘Ready’ state – state where a process is incepted into the memory and awaiting Processor time for execution. Processes is placed in ‘Ready list queue’. ‘Running’ state – state at which a process execution happens. ‘Blocked/Wait’ state – state where a running process is temporarily suspended from execution and does not have immediate access to resources. ‘Completed’ state – state where process completes its execution. Transistion of a process from one state to another is called as ‘State Transistion’ Process Sates & State transition representation Process States and State Transition:
  • 43. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15 RTOS for Embedded System Design The creation of a process to its termination is not a single step operation. The process traverses a series of states during its transition from newly created state to terminated state – ‘Process Life Cycle’. ‘Created’ state – state at which a process is created, OS recognizes that a process is created but no resources are allocated. ‘Ready’ state – state where a process is incepted into the memory and awaiting Processor time for execution. Processes is placed in ‘Ready list queue’. ‘Running’ state – state at which a process execution happens. ‘Blocked/Wait’ state – state where a running process is temporarily suspended from execution and does not have immediate access to resources. ‘Completed’ state – state where process completes its execution. Transistion of a process from one state to another is called as ‘State Transistion’ Process Sates & State transition representation Process States and State Transition:
  • 44. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15 RTOS for Embedded System Design The creation of a process to its termination is not a single step operation. The process traverses a series of states during its transition from newly created state to terminated state – ‘Process Life Cycle’. ‘Created’ state – state at which a process is created, OS recognizes that a process is created but no resources are allocated. ‘Ready’ state – state where a process is incepted into the memory and awaiting Processor time for execution. Processes is placed in ‘Ready list queue’. ‘Running’ state – state at which a process execution happens. ‘Blocked/Wait’ state – state where a running process is temporarily suspended from execution and does not have immediate access to resources. ‘Completed’ state – state where process completes its execution. Transistion of a process from one state to another is called as ‘State Transistion’ Process Sates & State transition representation Process States and State Transition:
  • 45. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15 RTOS for Embedded System Design The creation of a process to its termination is not a single step operation. The process traverses a series of states during its transition from newly created state to terminated state – ‘Process Life Cycle’. ‘Created’ state – state at which a process is created, OS recognizes that a process is created but no resources are allocated. ‘Ready’ state – state where a process is incepted into the memory and awaiting Processor time for execution. Processes is placed in ‘Ready list queue’. ‘Running’ state – state at which a process execution happens. ‘Blocked/Wait’ state – state where a running process is temporarily suspended from execution and does not have immediate access to resources. ‘Completed’ state – state where process completes its execution. Transistion of a process from one state to another is called as ‘State Transistion’ Process Sates & State transition representation Process States and State Transition:
  • 46. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15 RTOS for Embedded System Design The creation of a process to its termination is not a single step operation. The process traverses a series of states during its transition from newly created state to terminated state – ‘Process Life Cycle’. ‘Created’ state – state at which a process is created, OS recognizes that a process is created but no resources are allocated. ‘Ready’ state – state where a process is incepted into the memory and awaiting Processor time for execution. Processes is placed in ‘Ready list queue’. ‘Running’ state – state at which a process execution happens. ‘Blocked/Wait’ state – state where a running process is temporarily suspended from execution and does not have immediate access to resources. ‘Completed’ state – state where process completes its execution. Transistion of a process from one state to another is called as ‘State Transistion’ Process Sates & State transition representation Process States and State Transition:
  • 47. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15 RTOS for Embedded System Design The creation of a process to its termination is not a single step operation. The process traverses a series of states during its transition from newly created state to terminated state – ‘Process Life Cycle’. ‘Created’ state – state at which a process is created, OS recognizes that a process is created but no resources are allocated. ‘Ready’ state – state where a process is incepted into the memory and awaiting Processor time for execution. Processes is placed in ‘Ready list queue’. ‘Running’ state – state at which a process execution happens. ‘Blocked/Wait’ state – state where a running process is temporarily suspended from execution and does not have immediate access to resources. ‘Completed’ state – state where process completes its execution. Transistion of a process from one state to another is called as ‘State Transistion’ Process Sates & State transition representation Process States and State Transition:
  • 48. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15 RTOS for Embedded System Design The creation of a process to its termination is not a single step operation. The process traverses a series of states during its transition from newly created state to terminated state – ‘Process Life Cycle’. ‘Created’ state – state at which a process is created, OS recognizes that a process is created but no resources are allocated. ‘Ready’ state – state where a process is incepted into the memory and awaiting Processor time for execution. Processes is placed in ‘Ready list queue’. ‘Running’ state – state at which a process execution happens. ‘Blocked/Wait’ state – state where a running process is temporarily suspended from execution and does not have immediate access to resources. ‘Completed’ state – state where process completes its execution. Transistion of a process from one state to another is called as ‘State Transistion’ Process Sates & State transition representation Process States and State Transition:
  • 49. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 15 RTOS for Embedded System Design The creation of a process to its termination is not a single step operation. The process traverses a series of states during its transition from newly created state to terminated state – ‘Process Life Cycle’. ‘Created’ state – state at which a process is created, OS recognizes that a process is created but no resources are allocated. ‘Ready’ state – state where a process is incepted into the memory and awaiting Processor time for execution. Processes is placed in ‘Ready list queue’. ‘Running’ state – state at which a process execution happens. ‘Blocked/Wait’ state – state where a running process is temporarily suspended from execution and does not have immediate access to resources. ‘Completed’ state – state where process completes its execution. Transistion of a process from one state to another is called as ‘State Transistion’ Process Sates & State transition representation Process States and State Transition:
  • 50. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 16 RTOS for Embedded System Design A thread is the primitive that can execute code. A thread is a single sequential flow of control within a process. Thread is also known as light weighted process. A process can have many threads of execution. Different threads, which are part of a process, share the same address space (same code, data and heap memory area). Threads maintain there own thread status— CPU register values, PC and stack. Threads:
  • 51. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 16 RTOS for Embedded System Design A thread is the primitive that can execute code. A thread is a single sequential flow of control within a process. Thread is also known as light weighted process. A process can have many threads of execution. Different threads, which are part of a process, share the same address space (same code, data and heap memory area). Threads maintain there own thread status— CPU register values, PC and stack. Memory Organization of a process & its associated threads Threads:
  • 52. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 16 RTOS for Embedded System Design A thread is the primitive that can execute code. A thread is a single sequential flow of control within a process. Thread is also known as light weighted process. A process can have many threads of execution. Different threads, which are part of a process, share the same address space (same code, data and heap memory area). Threads maintain there own thread status— CPU register values, PC and stack. Memory Organization of a process & its associated threads Threads:
  • 53. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 16 RTOS for Embedded System Design A thread is the primitive that can execute code. A thread is a single sequential flow of control within a process. Thread is also known as light weighted process. A process can have many threads of execution. Different threads, which are part of a process, share the same address space (same code, data and heap memory area). Threads maintain there own thread status— CPU register values, PC and stack. Memory Organization of a process & its associated threads Threads:
  • 54. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 16 RTOS for Embedded System Design A thread is the primitive that can execute code. A thread is a single sequential flow of control within a process. Thread is also known as light weighted process. A process can have many threads of execution. Different threads, which are part of a process, share the same address space (same code, data and heap memory area). Threads maintain there own thread status— CPU register values, PC and stack. Memory Organization of a process & its associated threads Threads:
  • 55. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 16 RTOS for Embedded System Design A thread is the primitive that can execute code. A thread is a single sequential flow of control within a process. Thread is also known as light weighted process. A process can have many threads of execution. Different threads, which are part of a process, share the same address space (same code, data and heap memory area). Threads maintain there own thread status— CPU register values, PC and stack. Memory Organization of a process & its associated threads Threads:
  • 56. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 16 RTOS for Embedded System Design A thread is the primitive that can execute code. A thread is a single sequential flow of control within a process. Thread is also known as light weighted process. A process can have many threads of execution. Different threads, which are part of a process, share the same address space (same code, data and heap memory area). Threads maintain there own thread status— CPU register values, PC and stack. Memory Organization of a process & its associated threads Threads:
  • 57. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 16 RTOS for Embedded System Design A thread is the primitive that can execute code. A thread is a single sequential flow of control within a process. Thread is also known as light weighted process. A process can have many threads of execution. Different threads, which are part of a process, share the same address space (same code, data and heap memory area). Threads maintain there own thread status— CPU register values, PC and stack. Memory Organization of a process & its associated threads Threads:
  • 58. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 17 RTOS for Embedded System Design A process/thread in a embedded application may be a complex or lengthy one and it may contain various sub- operations like getting input from I/O devices connected to processor, performing some internal calculations /operations, updating some I/O devices etc. If all these sub-operations are executed in sequence, the CPU utilization may not be efficient. Instead of this single sequential execution of the whole process, if task/process is split into different threads carrying out the different sub-functionalities of the process, the CPU can be effectively utilized. Threads corresponding to I/O operations enter wait state, while other threads which do not require I/O can be switched to execution. The concept of Multithreading:
  • 59. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 17 RTOS for Embedded System Design If the process is split into multiple threads, which executes a portion of the process, there will be a main thread and rest of them will be created within main thread. Use of multiple threads to execute a process results in following advantages: Better Memory Utilization: multiple threads of same process share address space for data memory, also reduces inter thread communication since variables will be shared. Speedy execution: since process splits into different threads, when one thread enters wait state other thread can be scheduled. Efficient CPU Utilization: CPU is engaged all time Process with multi-threads The concept of Multithreading:
  • 60. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 17 RTOS for Embedded System Design If the process is split into multiple threads, which executes a portion of the process, there will be a main thread and rest of them will be created within main thread. Use of multiple threads to execute a process results in following advantages: Better Memory Utilization: multiple threads of same process share address space for data memory, also reduces inter thread communication since variables will be shared. Speedy execution: since process splits into different threads, when one thread enters wait state other thread can be scheduled. Efficient CPU Utilization: CPU is engaged all time Process with multi-threads The concept of Multithreading:
  • 61. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 17 RTOS for Embedded System Design If the process is split into multiple threads, which executes a portion of the process, there will be a main thread and rest of them will be created within main thread. Use of multiple threads to execute a process results in following advantages: Better Memory Utilization: multiple threads of same process share address space for data memory, also reduces inter thread communication since variables will be shared. Speedy execution: since process splits into different threads, when one thread enters wait state other thread can be scheduled. Efficient CPU Utilization: CPU is engaged all time Process with multi-threads The concept of Multithreading:
  • 62. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 17 RTOS for Embedded System Design If the process is split into multiple threads, which executes a portion of the process, there will be a main thread and rest of them will be created within main thread. Use of multiple threads to execute a process results in following advantages: Better Memory Utilization: multiple threads of same process share address space for data memory, also reduces inter thread communication since variables will be shared. Speedy execution: since process splits into different threads, when one thread enters wait state other thread can be scheduled. Efficient CPU Utilization: CPU is engaged all time Process with multi-threads The concept of Multithreading:
  • 63. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 17 RTOS for Embedded System Design If the process is split into multiple threads, which executes a portion of the process, there will be a main thread and rest of them will be created within main thread. Use of multiple threads to execute a process results in following advantages: Better Memory Utilization: multiple threads of same process share address space for data memory, also reduces inter thread communication since variables will be shared. Speedy execution: since process splits into different threads, when one thread enters wait state other thread can be scheduled. Efficient CPU Utilization: CPU is engaged all time Process with multi-threads The concept of Multithreading:
  • 64. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 17 RTOS for Embedded System Design If the process is split into multiple threads, which executes a portion of the process, there will be a main thread and rest of them will be created within main thread. Use of multiple threads to execute a process results in following advantages: Better Memory Utilization: multiple threads of same process share address space for data memory, also reduces inter thread communication since variables will be shared. Speedy execution: since process splits into different threads, when one thread enters wait state other thread can be scheduled. Efficient CPU Utilization: CPU is engaged all time Process with multi-threads The concept of Multithreading:
  • 65. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 18 RTOS for Embedded System Design Thread standard deals with different standards available for thread creation and management. These standards utilize OS for thread creation and management. It is a set of thread class libraries. The commonly available thread class libraries are POSIX threads, Win32 Threads, Java Threads etc. Thread Standard: POSIX Threads: Stands for Portable Operating System Interface. POSIX. 4 standard deals with real time extensions and POSIX.4a standard deals with thread extensions. The POSIX standard library for thread creation and management is ‘Pthreads’. The Pthreads library defines the set of POSIX thread creation and management functions in ‘C’ language. int pthread_create(pthread_t *new_thread_ID, const pthread_attr_t *attribute, void * (*start function) (void *), void *arguments; The above primitive is used for creating new thread for running the function start_function. Here pthread_t is the handle to newly created thread and pthread_attr_t is data type for holding thread attributes. Start_function is the function, the thread is going to execute, arguments is the arguments for start_function On successful creation of a Pthread, Pthread_create() associates the TCB corresponding to the newly created thread to variable of type Pthread_t
  • 66. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 19 RTOS for Embedded System Design int pthread_join (pthread_t new_thread, void *, *thread_status); The above primitive blocks the current thread and waits until the completion of the thread pointed by it. All POSIX thread calls return an integer. A return value of zero indicates the success of the call. It is always good to check the return value of each call. Example: Write a multithread appliction to print “Hello I’m in main thread” from the main thread and “Hello I’m in new thread” 5 times each, using pthread_create() and pthread_join() POSIX primitives. #include <pthread.h> #include <stdlib.h> #include <stdio.h> Void *new_thread (void *thread_args) { int i,j; for (j=0;j<5;j++) { printf( “Hello I’m in new threadn”); for (i=0;i<10000;i++) } return NULL; }
  • 67. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 20 RTOS for Embedded System Design if (pthread_join(tcb, NULL)) { printf(“Error in thread joiningn”); return -1; } return 1; } int main (void) { int i,j; pthread_t tcb; If (pthread_create(&tcb, NULL, new-thread ,NULL)) { printf(“Error in creating new threadn”); return -1; } for (j=0;j<5;j++) { printf( “Hello I’m in main threadn”); for (i=0;i<10000;i++) } Termination of thread can happen in different ways: •Natural termination—threads completes executions and returns back to main thread through simple return or by executing pthread_exit(). •Forced termination—by calling pthread_cancel() or termination of main thread with exit or exec function. Exiting with pthread_exit() will not perform a cleanup. Calling pthread_join() at the end of main thread is best way to achieve synchronization and cleanup.
  • 68. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 21 RTOS for Embedded System Design Thread is a single unit of execution and is part of process. Process is a program in execution and contains one or more threads. Thread does not have its own data memory and heap memory. It shares the data memory and heap memory with other threads of same process. Process has its own code memory, data memory and stack memory Thread cannot live independently: it lives within the process. Process contains at least one thread There can be multiple threads in a process. The first thread calls the main function and occupies the start of stack memory of the process. Threads within a Process shares data, code and heap memory. Each thread holds separate memory area for stack.(Share the total stack memory of process) Threads are very inexpensive to create. Process are very expensive to create as they involve many OS overhead. Context switching is inexpensive. and fast Context switching is complex and involves lot of OS overhead and comparatively slower. If a Thread expires, its stack is reclaimed by the process. If a process dies, the resources allocated to it reclaimed by OS and all associated threads of the process also dies. Thread Process
  • 69. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 22 RTOS for Embedded System Design Multiprocessing and Multitasking Multiprocessing and Multitasking sounds alike. In OS context Multiprocessing describes the ability to execute multiple process simultaneously. Systems that are capable of performing multiprocessing, are known as multiprocessor systems. Multiprocessor systems posses multiple processors (CPUs) and can execute multiple processes simultaneously. The ability of OS multiple programs in memory, which are ready for execution is referred as Multiprogramming. In uniprocessor system, it is not possible to execute multiple process simultaneously. However with uniprocessor system it is possible to achieve some degree of pseudo parallelism in the execution of multiple processes by switching the execution among different processes. The ability of the processor to hold multiple processes in memory and switch the processor from executing one process to another process is known as multitasking. Multitasking creates the illusion of multiple tasks executing in parallel. Ina multitasking environment when task/process switching happens, the virtual processor (task/process) gets its properties converted into that of physical processor. This is controlled by scheduler of OS kernel. Whenever a CPE switching happens, the current context of execution should be saved to retrieve it at a later stage when CPU switches to process which was interrupted due to execution switching. This context saving and later retrieval is essential for resuming exactly from the point where it was interrupted. Act of switching CPU among the processes or changing current execution context— ‘Context switching’ Act of saving the current context details(Registers, memory, system resource, execution time etc.)— ‘Context saving’ Process of retrieving the saved context details for a process, which is going to resume its execution— ‘Context retrieval’
  • 70. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23 RTOS for Embedded System Design Multiprocessing and Multitasking Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’. Time Process
  • 71. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23 RTOS for Embedded System Design Multiprocessing and Multitasking Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’. Time Process 1 Process running idle
  • 72. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23 RTOS for Embedded System Design Multiprocessing and Multitasking Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’. Time Process 1 Process running idle
  • 73. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23 RTOS for Embedded System Design Multiprocessing and Multitasking Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’. Time Process 1 Process running idle Process 2
  • 74. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23 RTOS for Embedded System Design Multiprocessing and Multitasking Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’. Time Process 1 Process running idle Process 2
  • 75. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23 RTOS for Embedded System Design Multiprocessing and Multitasking Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’. Time Process 1 Process running idle Process 2
  • 76. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23 RTOS for Embedded System Design Multiprocessing and Multitasking Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’. Time Process 1 Process running idle Process 2
  • 77. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23 RTOS for Embedded System Design Multiprocessing and Multitasking Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’. Time Process 1 Process running idle Process 2
  • 78. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23 RTOS for Embedded System Design Multiprocessing and Multitasking Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’. Time Process 1 Process running idle Process 2
  • 79. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23 RTOS for Embedded System Design Multiprocessing and Multitasking Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’. Time Process 1 Process running idle Process 2
  • 80. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23 RTOS for Embedded System Design Multiprocessing and Multitasking Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’. Time Process 1 Process running idle Process 2
  • 81. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 23 RTOS for Embedded System Design Multiprocessing and Multitasking Multitasking involves ‘Context Switching’, ‘Context Saving’and ‘Context Retrieving’. Time Process 1 Process running idle Process 2
  • 82. Most primitive form of multitasking, in which a task/process gets a chance to execute only when currently executing voluntarily relinquishes the CPU. Any task/process can hold CPU as much time as it wants. This name because, this type of implementation involves mercy of tasks each other for getting CPU time for execution. If tasks are non-cooperative, the other tasks have to wait for a long time to get the CPU. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Operating System basics Types of operating systems Task, process and threads Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 24 RTOS for Embedded System Design Multiprocessing and Multitasking Types of Multitasking: Co-operative Multitasking: Preemptive Multitasking: Non-Preemptive Multitasking: Ensures that every task/process gets a chance to execute. When and how much time a process gets is dependent on the implementation of preemptive scheduling. The currently running task/process is preempted to give a chance to other tasks/processes to execute. Preemption of task may be based on time slots or task/process priority. The task/process to which CPU is currently allocated is allocated to execute until it terminates or enters ‘Blocked/wait’state, waiting for I/O or system resource. In cooperative multitasking process/task will not relinquish CPU when it enters s ‘Blocked/wait’state. Where as in Non-preemptive multitasking currently executing process/task relinquish CPU when it waits for an I/O or system resource or an event to occur.
  • 83. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 25 RTOS for Embedded System Design 0000 Task scheduling Operating System basics Types of operating systems Task, process and threads 0000 Task schedulingMultiprocessing and Multitasking There should be some mechanism in place to share the CPU among the different tasks and to decide which process/task is to be executed at a given point of time. Determining which task/process is to be executed at given point if time is known as Task Scheduling. Task scheduling forms the basis for multitasking. Scheduling polices form the guidelines for determining which task is to be executed when. The scheduling polices are run in an algorithm by the OS kernel as a service. The kernel service/application which implements scheduling algorithm, is known as Scheduler. The process scheduling decision may take place under 4 scenarios, when a process switches its state to: •Ready’ State from ‘Running’State — Scenario 1 •‘Blocked/Wait’State from ‘Running’State — Scenario 2 •‘Ready’ State from ‘Blocked/Wait’State — Scenario 3 •‘Completed’State — Scenario 4 Scenario 1: A process switches to ‘Ready’ state from ‘Running’ state when its preempted.— Preemptive Scheduling. Scheduling in Scenario 2 can be either preemptive or non-preemptive. Scenario 3: When a high priority process in Blocked/Wait Ready state , the scheduler picks it for execution if scheduling policy is priority based preemptive. Scheduling under Scenario 4 can be preemptive, non-preemptive or cooperative scheduling.
  • 84. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 26 RTOS for Embedded System Design 0000 Task scheduling Operating System basics Types of operating systems Task, process and threads 0000 Task schedulingMultiprocessing and Multitasking The selection of a scheduling criterion/algorithm should consider the following factors: CPU Utilization: should be high. It is the direct measure of how much percentage of CPU is being utilized. Throughput: indicates no. of processes executed per unit time. It should always be higher. Turnaround time: It is the amount of time taken by a process for completing its execution. It includes time spent by process for waiting for the main memory, time spent in the ready queue, time spent on completing I/O operations and time spent in execution. Waiting Time: It is the amount of time spent by process in ‘Ready’ queue waiting to get CPU, should be minimal. Response Time: time elapsed between submission of process and the first response, should be as least as possible. The OS maintains various queues in connection with CPU scheduling and a process passes through these queues during the course of admittance to execution completion. •Job queue: contains all processes in the system. •Ready queue: contains all processes which are ready for execution and waiting for CPU. Empty when no process is ready for running. •Device queue contains a processes, which are waiting for an I/O device Therefore a good scheduling algorithm should have high CPU utilization, minimum Turn Around Time (TAT), maximum throughput and least response time.
  • 85. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27 RTOS for Embedded System Design 0000 Task scheduling Operating System basics Types of operating systems Task, process and threads 0000 Task schedulingMultiprocessing and Multitasking Now let us consider an diagrammatic representation that shows transition of Process through various queues: Illustration of Process transition through various queues
  • 86. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27 RTOS for Embedded System Design 0000 Task scheduling Operating System basics Types of operating systems Task, process and threads 0000 Task schedulingMultiprocessing and Multitasking Now let us consider an diagrammatic representation that shows transition of Process through various queues: Illustration of Process transition through various queues
  • 87. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27 RTOS for Embedded System Design 0000 Task scheduling Operating System basics Types of operating systems Task, process and threads 0000 Task schedulingMultiprocessing and Multitasking Now let us consider an diagrammatic representation that shows transition of Process through various queues: Illustration of Process transition through various queues
  • 88. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27 RTOS for Embedded System Design 0000 Task scheduling Operating System basics Types of operating systems Task, process and threads 0000 Task schedulingMultiprocessing and Multitasking Now let us consider an diagrammatic representation that shows transition of Process through various queues: Illustration of Process transition through various queues
  • 89. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27 RTOS for Embedded System Design 0000 Task scheduling Operating System basics Types of operating systems Task, process and threads 0000 Task schedulingMultiprocessing and Multitasking Now let us consider an diagrammatic representation that shows transition of Process through various queues: Illustration of Process transition through various queues
  • 90. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27 RTOS for Embedded System Design 0000 Task scheduling Operating System basics Types of operating systems Task, process and threads 0000 Task schedulingMultiprocessing and Multitasking Now let us consider an diagrammatic representation that shows transition of Process through various queues: Illustration of Process transition through various queues
  • 91. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27 RTOS for Embedded System Design 0000 Task scheduling Operating System basics Types of operating systems Task, process and threads 0000 Task schedulingMultiprocessing and Multitasking Now let us consider an diagrammatic representation that shows transition of Process through various queues: Illustration of Process transition through various queues
  • 92. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27 RTOS for Embedded System Design 0000 Task scheduling Operating System basics Types of operating systems Task, process and threads 0000 Task schedulingMultiprocessing and Multitasking Now let us consider an diagrammatic representation that shows transition of Process through various queues: Illustration of Process transition through various queues
  • 93. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27 RTOS for Embedded System Design 0000 Task scheduling Operating System basics Types of operating systems Task, process and threads 0000 Task schedulingMultiprocessing and Multitasking Now let us consider an diagrammatic representation that shows transition of Process through various queues: Illustration of Process transition through various queues
  • 94. Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 27 RTOS for Embedded System Design 0000 Task scheduling Operating System basics Types of operating systems Task, process and threads 0000 Task schedulingMultiprocessing and Multitasking Now let us consider an diagrammatic representation that shows transition of Process through various queues: Illustration of Process transition through various queues
  • 95. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 Operating System basics Types of operating systems Task, process and threads Multiprocessing and Multitasking Task scheduling How to choose an RTOS. RTOS for Embedded System Design 0000 Task scheduling Operating System basics Types of operating systems Task, process and threads 0000 Task schedulingMultiprocessing and Multitasking Non-Preemptive Scheduling: Non-Preemptive Scheduling is employed in systems, which implement non-preemptive multitasking model. The currently executing task/process is allowed to run until it terminates or enters the Block/Wait state waiting for an I/O or system resource. The various types of non-preemptive scheduling adopted in task/process scheduling are: First Come First Served (FCFS)/FIFO Scheduling Last Come First Served (LCFS)/LIFO Scheduling Shortest Job First (SJF) Scheduling Priority Based Scheduling Allocates CPU time to the process based on order in which they enter the ‘Ready’ queue. Example is Ticket reservation system where people need to stand in a queue and the first person in the queue is serviced first. The first entered process is serviced first, also called as First In First Out (FIFO) scheduling. First Come First Served (FCFS)/FIFO Scheduling: 28