0% found this document useful (0 votes)
6 views12 pages

ESD Module3 Notes

Module 3 covers the fundamentals of Real-Time Operating Systems (RTOS) and Integrated Development Environments (IDE) for embedded system design, including operating system basics, task management, and scheduling techniques. It discusses the differences between monolithic and microkernel architectures, as well as the importance of task communication and synchronization. The module also emphasizes the selection of an appropriate RTOS and the integration and testing of embedded hardware and firmware.

Uploaded by

s. Eswar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views12 pages

ESD Module3 Notes

Module 3 covers the fundamentals of Real-Time Operating Systems (RTOS) and Integrated Development Environments (IDE) for embedded system design, including operating system basics, task management, and scheduling techniques. It discusses the differences between monolithic and microkernel architectures, as well as the importance of task communication and synchronization. The module also emphasizes the selection of an appropriate RTOS and the integration and testing of embedded hardware and firmware.

Uploaded by

s. Eswar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Embedded System Design Concepts Module 3

MODULE-3
RTOS and IDE for Embedded System Design:
Operating System basics, Types of operating systems, Task, process and threads (Only POSIX
Threads with an example program), Thread preemption, Preemptive Task scheduling
techniques, Task Communication, Task synchronization issues – Racing and Deadlock. How
to choose an RTOS, Integration and testing of Embedded hardware and firmware, Embedded
system Development Environment – Block diagram (excluding Keil).

(Text 1: Ch-10 (Sections 10.1, 10.2, 10.3, 10.5.2 , 10.7, [Link], [Link] only), Ch-12, Ch-
13 (a block diagram before 13.1, only).

Text Book:
1. Shibu K V, “Introduction to Embedded Systems”, Tata McGraw Hill Education, Private
Limited, 2nd Edition.

Sir M Visvesvaraya Institute of Technology 2025-26


Embedded System Design Concepts Module 3

Operating System basics


The operating system acts as a bridge between the 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. A normal computing system is a
collection of different I/O subsystems, working, and storage memory. The primary functions of an operating
system is
➢ Make the system convenient to use
➢ Organize and manage the system resources efficiently and correctly
Figure 1 gives an insight into the basic components of an operating system and their interfaces with rest of
the world.

Fig 1: The Operating System Architecture


The Kernel
The kernel is the core of the operating system and is responsible for managing the system resources and the
communication among the hardware and other system services. Kernel acts as the abstraction layer between
system resources and user applications. Kernel contains a set of system libraries and services. For a general
purpose OS, the kernel contains different services for handling the following.
Process Management Process management: It deals with managing the processes/tasks. Process
management includes setting up the memory space for the process, loading the process’s code into the
memory space, allocating system resources, scheduling and managing the execution of the process, setting
up and managing the Process Control Block (PCB), Inter Process Communication and synchronization,
process termination/ deletion, etc.
Primary Memory Management: The term primary memory refers to the volatile memory (RAM) where
processes are loaded and variables and shared data associated with each process are stored. The Memory
Management Unit (MMU) of the kernel is responsible for
➢ Keeping track of which part of the memory area is currently used by which process
Allocating and De-allocating memory space on a need basis (Dynamic memory allocation).
Sir M Visvesvaraya Institute of Technology 2025-26
Embedded System Design Concepts Module 3

File System Management File is a collection of related information. A fi le could be a program (source code
or executable), text fi les, image fi les, word documents, audio/video fi les, etc. Each of these fi les differ in
the kind of information they hold and the way in which the information is stored. The fi le operation is a
useful service provided by the OS. The fi le system management service of Kernel is responsible for
➢ The creation, deletion and alteration of files
➢ Creation, deletion and alteration of directories
➢ Saving of fi les in the secondary storage memory (e.g. Hard disk storage)
➢ Providing automatic allocation of fi le space based on the amount of free space available
➢ Providing a flexible naming convention for the files
The various file system management operations are OS dependent. For example, the kernel of Microsoft®
DOS OS supports a specific set of file system management operations and they are not the same as the file
system operations supported by UNIX Kernel.
I/O System (Device) Management Kernel is responsible for routing the I/O requests coming from different
user applications to the appropriate I/O devices of the system. In a well-structured OS, the direct accessing
of I/O devices are not allowed and the access to them are provided through a set of Application Programming
Interfaces (APIs) exposed by the kernel. The kernel maintains a list of all the I/O devices of the system.
This list may be available in advance, at the time of building the kernel. Some kernels, dynamically updates
the
list of available devices as and when a new device is installed (e.g. Windows NT kernel keeps the list updated
when a new plug ‘n’ play USB device is attached to the system). The service ‘Device Manager’ (Name may
vary across different OS kernels) of the kernel is responsible for handling all I/O device related operations.
The kernel talks to the I/O device through a set of low-level systems calls, which are implemented in a
service, called device drivers. The device drivers are specific to a device or a class of devices. The Device
Manager is responsible for
➢ Loading and unloading of device drivers
➢ Exchanging information and the system specific control signals to and from the device
Protection Systems:
➢ Most of the modern operating systems are designed in such a way to support multiple users with
different levels of access permissions (e.g. Windows 10 with user permissions like ‘Administrator’,
‘Standard’, ‘Restricted’, etc.).
➢ Protection deals with implementing the security policies to restrict the access to both user and system
resources by different applications or processes or users.
➢ In multiuser supported operating systems, one user may not be allowed to view or modify the
whole/portions of another user’s data or profile details.

Sir M Visvesvaraya Institute of Technology 2025-26


Embedded System Design Concepts Module 3

➢ In addition, some application may not be granted with permission to make use of some of the system
resources. This kind of protection is provided by the protection services running within the kernel.

Monolithic Kernel and Microkernel


As we know, the kernel forms the heart of an operating system. Different approaches are adopted for building
an Operating System kernel. Based on the kernel design, kernels can be classified into ‘Monolithic’ and
‘Micro’.
Monolithic Kernel
Monolithic Kernel In monolithic kernel architecture, all kernel services run in the kernel space. Here all
kernel modules run within the same memory space under a single kernel thread. The tight internal integration
of kernel modules in monolithic kernel architecture allows the effective utilisation of the low-level features
of the underlying system. The major drawback of monolithic kernel is that any error or failure in any one of
the kernel modules leads to the crashing of the entire kernel application. LINUX, SOLARIS, MS-DOS
kernels are examples of monolithic kernel.

Fig 2: The Monolithic Kernel Model


Microkernel
The microkernel design incorporates only the essential set of Operating System services into the kernel. The
rest of the Operating System services are implemented in programs known as ‘Servers’ which runs in user
space. This provides a highly modular design and OS-neutral abstraction to the kernel. Memory management,
process management, timer systems and interrupt handlers are the essential services, which forms the part of
the microkernel. Mach, QNX, Minix 3 kernels are examples for microkernel. The architecture representation
of a microkernel is shown in Fig 3.

Sir M Visvesvaraya Institute of Technology 2025-26


Embedded System Design Concepts Module 3

Fig 3: The Microkernel model

Microkernel based design approach offers the following benefits:


Robustness: If a problem is encountered in any of the services, which runs as ‘Server’ application, the same
can be reconfigured and re-started without the need for re-starting the entire OS. Thus, this approach is highly
useful for systems, which demands high ‘availability’. Refer Chapter 3 to get an understanding of
‘availability’. Since the services which run as ‘Servers’ are running on a different memory space, the chances
of corruption of kernel services are ideally zero.
Configurability: Any services, which run as ‘Server’ application can be changed without the need to restart
the whole system. This makes the system dynamically configurable.

TYPES OF OPERATING SYSTEMS


1. General Purpose Operating System (GPOS)
The operating systems, which are deployed in general computing systems, are referred as General Purpose
Operating Systems. The kernel of such an OS is more generalized and it contains all kinds of services required
for executing generic applications. General-purpose operating systems are often quite non-deterministic in
behaviour. Their services can inject random delays into application software and may cause slow
responsiveness of an application at unexpected times. GPOS are usually deployed in computing systems
where deterministic behaviour is not an important criterion. Personal Computer/Desktop system is a typical
example for a system where GPOSs are deployed. Windows 10/8.x/XP/MS-DOS etc are examples for
General Purpose Operating Systems.
2. Real-Time Operating System (RTOS)
There is no universal definition available for the term ‘ Real-Time’ when it is used in conjunction with
operating systems. What ‘Real-Time’ means in Operating System context is still a debatable topic and there
are many definitions available. In a broad sense, ‘Real-Time’ implies deterministic timing behavior.
Sir M Visvesvaraya Institute of Technology 2025-26
Embedded System Design Concepts Module 3

Deterministic timing behavior in RTOS context means the OS services consumes only known and expected
amounts of time regardless the number of services. A Real-Time Operating System or RTOS implements
policies and rules concerning time-critical allocation of a system’s resources. The RTOS decides which
applications should run in which order and how much time needs to be allocated for each application.
Predictable performance is the hallmark of a well-designed RTOS

The Real-Time Kernel


The kernel of a Real-Time Operating System is referred as Real. Time kernel. In complement to the
conventional OS kernel, the Real-Time kernel is highly specialized and it contains only the minimal set of
services required for running the user applications/tasks. The basic functions of a Real-Time kernel are listed
below:
➢ Task/Process management
➢ Task/Process scheduling
➢ Task/Process synchronisation
➢ Error/Exception handling
➢ Memory management
➢ Interrupt handling
➢ Time management

1. Task/ Process management


Deals with setting up the memory space for the tasks, loading the task’s code into the memory space,
allocating system resources, setting up a Task Control Block (TCB) for the task and task/process
termination/deletion. A Task Control Block (TCB) is used for holding the information corresponding to a
task. TCB usually contains the following set of information.
1. Task ID: Task Identification Number
2. Task State: The current state of the task (e.g. State = ‘Ready’ for a task which is ready to execute)
3. Task Type: Task type. Indicates what is the type for this task. The task can be a hard real time or soft
real time or background task.
4. Task Priority: Task priority (e.g. Task priority = 1 for task with priority = 1)
5. Task Context Pointer: Context pointer. Pointer for context saving
6. Task Memory Pointers: Pointers to the code memory, data memory and stack memory for the task
7. Task System Resource Pointers: Pointers to system resources (semaphores, mutex, etc.) used by the
task
8. Task Pointers: Pointers to other TCBs (TCBs for preceding, next and waiting tasks)
9. Other Parameters: Other relevant task parameters

Sir M Visvesvaraya Institute of Technology 2025-26


Embedded System Design Concepts Module 3

The parameters and implementation of the TCB is kernel dependent. The TCB parameters vary across
different kernels, based on the task management implementation. Task management service utilizes the TCB
of a task in the following way
➢ Creates a TCB for a task on creating a task
➢ Delete/remove the TCB of a task when the task is terminated or deleted
➢ Reads the TCB to get the state of a task
➢ Update the TCB with updated parameters on need basis (e.g. on a context switch)
➢ Modify the TCB to change the priority of the task dynamically
2. Task/ Process Scheduling

Deals with sharing the CPU among various tasks/processes. A kernel application called ‘Scheduler’ handles
the task scheduling. Scheduler is nothing but an algorithm implementation, which performs the efficient
and optimal scheduling of tasks to provide a deterministic behaviour.

3. Task/ Process Synchronization

Deals with synchronizing the concurrent access of a resource, which is shared across multiple tasks and the
communication between various tasks.

4. Error/ Exception Handling


Error/Exception handling deals with detecting and managing issues during task execution. Common errors
include insufficient memory, timeouts, deadlocks, divide-by-zero, and invalid instructions.
Errors can occur at:
➢ Kernel level (e.g., deadlock)
➢ Task level (e.g., timeout)
The OS kernel reports errors using system calls (APIs). A watchdog timer is used to handle timeouts:
➢ It is set with a maximum wait time for an event
➢ If the event occurs in time → watchdog resets
➢ If not → task is timed out and informed
This prevents tasks from hanging due to unresponsive external events.
5. Memory Management
RTOS memory management differs from general-purpose OS by focusing on predictable and deterministic
timing rather than efficiency.
➢ Uses fixed-size block allocation instead of dynamic allocation
➢ Memory blocks are stored in a free buffer queue and assigned as needed
➢ Allocation time is constant, avoiding delays and fragmentation
➢ No garbage collection overhead

Sir M Visvesvaraya Institute of Technology 2025-26


Embedded System Design Concepts Module 3

To maintain speed, most RTOS systems avoid memory protection, allowing tasks to access memory directly.
Some RTOS provide optional protection and enter fail-safe mode on illegal access.
Virtual memory may be used in some systems with secondary storage.
6. Interrupt Handling :
Interrupt handling manages signals that require immediate CPU attention, enabling real-time behavior.
➢ Types of Interrupts:
1. Synchronous: Occur during task execution (e.g., divide-by-zero, memory errors); handled in
the same task context
2. Asynchronous: Occur anytime (e.g., external devices, timers, I/O); handled in a separate
context, causing a context switch
3. Interrupts can have priority levels and can be enabled/disabled individually
➢ RTOS often supports nested interrupts, where a higher-priority interrupt can interrupt a lower-priority
ISR
7. Time Management
➢ Accurate time management is essential for providing precise time reference for all applications. The
time reference to kernel is provided by a high-resolution Real-Time Clock (RTC) hardware
➢ chip (hardware timer).
➢ The hardware timer is programmed to interrupt the processor/controller at a fixed rate.
➢ This timer interrupt is referred as ‘ Timer tick’. The ‘Timer tick’ is taken as the timing reference by
the kernel.
➢ The ‘Timer tick’ interval may vary depending on the hardware timer. Usually the ‘Timer tick’ varies
in the microseconds range. The time parameters for tasks are expressed as the multiples of the ‘Timer
tick’.
TASKS, PROCESS AND THREADS
TASKS
➢ The term ‘ task’ refers to something that needs to be done. In our day-to-day life, we are bound to the
execution of a number of tasks.
➢ The task can be the one assigned by our managers or the one assigned by our professors/teachers or
the one related to our personal or family needs.
➢ In addition, we will have an order of priority and schedule/timeline for executing these tasks. In the
operating system context, a task is defined as the program in execution and the related information
maintained by the operating system for the program.
PROCESS

A ‘Process’ is a program, or part of it, in execution. Process is also known as an instance of a program in
execution. Multiple instances of the same program can execute simultaneously. A process requires various
Sir M Visvesvaraya Institute of Technology 2025-26
Embedded System Design Concepts Module 3

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.

The Structure of a Process


The concept of ‘Process’ leads to concurrent execution (pseudo parallelism) of tasks and thereby the efficient
utilization of the CPU and other system resources. Concurrent execution is achieved through the sharing of
CPU among the processes. A process mimics a processor in properties and holds a set of registers, process
status, a Program Counter (PC) to point to the next executable instruction of the process, a stack for holding
the local variables associated with the process and the code corresponding to the process. This can be
visualized as shown in Fig. 4

Fig 4: Structure of a Process


A process which inherits all the properties of the CPU can be considered as a virtual processor, awaiting its
turn to have its properties switched into the physical processor. When the process gets its turn, its registers
and the program counter register become mapped to the physical registers of the CPU. From a memory
perspective, the memory occupied by the process is segregated into three regions, namely, Stack memory,
Data memory and Code memory in Fig 5.

Fig 5: Memory organisation of a Process

Sir M Visvesvaraya Institute of Technology 2025-26


Embedded System Design Concepts Module 3

The ‘ Stack’ memory holds all temporary data such as variables local to the process. Data memory holds all
global data for the process. The code memory contains the program code (instructions) corresponding to the
process. On loading a process into the main memory, a specifi c area of memory is allocated for the process.
The stack memory usually starts (OS Kernel implementation dependent) at the highest memory address from
the memory area allocated for the process. Say for example, the memory map of the memory area allocated
for the process is 2048 to 2100, the stack memory starts at address 2100 and grows downwards to
accommodate the variables local to the process.
Process States and State Transition
The creation of a process to its termination is not a single step operation. The process traverses through a
series of states during its transition from the newly created state to the terminated state. The cycle through
which a process changes its state from ‘newly created’ to ‘execution completed’ is known as ‘Process Life
Cycle’. The various states through which a process traverses through during a Process Life Cycle indicates
the current status of the process with respect to time and also provides information on what it is allowed to
do next. Figure 6 represents the various states associated with a process.

The state at which a process is being created is referred as ‘Created State’. The Operating System recognises
a process in the ‘Created State’ but no resources are allocated to the process. The state, where a process is
incepted into the memory and awaiting the processor time for execution, is known as ‘Ready State’. At this
stage, the process is placed in the ‘Ready list’ queue maintained by the OS. The state where in the source
code instructions corresponding to the process is being executed is called ‘Running State’. Running state is
the state at which the process execution happens. ‘Blocked State/Wait State’ refers to a state where a running
process is temporarily suspended from execution and does not have immediate access to resources. The
blocked state might be invoked by various conditions like: the process enters a wait state for an event to
occur (e.g. Waiting for user inputs such as keyboard input) or waiting for getting access to a shared resource
(will be discussed at a later section of this chapter). A state where the process completes its execution is
known as ‘Completed State’. The transition of a process from one state to another is known as ‘State
transition’. When a process changes its state from Ready to running or from running to blocked or terminated
or from blocked to running, the CPU allocation for the process may also change.
It should be understood that the process/task state model described here is a general representation. In
different operating system kernels, the names of the states may vary, and the number of states can be more
or fewer than those discussed.
For example, in the VxWorks kernel, a task can exist in states such as READY, PEND, DELAY, and
SUSPEND, either individually or in combination. The PEND state indicates that the task is blocked while
waiting for I/O or a system resource. The DELAY state means the task is in a sleep condition for a specific
period, and the SUSPEND state indicates that the task is temporarily halted and not available for execution.

Sir M Visvesvaraya Institute of Technology 2025-26


Embedded System Design Concepts Module 3

Similarly, in the MicroC/OS-II kernel, tasks may be in states like DORMANT, READY, RUNNING,
WAITING, or INTERRUPTED. The DORMANT state corresponds to the created state, while the WAITING
state represents a condition where the process is waiting for a shared resource or I/O operation.

Fig 6: Process states and state transition representation


Process Management
Process management deals with the creation of a process, setting up the memory space for the process,
loading the process’s code into the memory space, allocating system resources, setting up a Process Control
Block (PCB) for the process and process termination/deletion.

THREADS
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 lightweight process. A process can have many threads of execution. Different
threads, which are part of a process, share the same address space; meaning they share the data memory, code
memory and heap memory area. Threads maintain their own thread status (CPU register values), Program
Counter (PC) and stack. The memory model for a process and its associated threads is given in Fig. 7

Sir M Visvesvaraya Institute of Technology 2025-26


Embedded System Design Concepts Module 3

Fig 7: Memory organisation of a Process and its associated Threads

Sir M Visvesvaraya Institute of Technology 2025-26

You might also like