Embedded Systems Chapter 3
Embedded Systems Chapter 3
Presented by
Dr. B. Naresh Kumar Reddy
Department of Electronics and Communication Engineering
Outline 1
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
What is an Operating System? 2
▶ An Operating system (OS) is a software which acts as an
interface between the end user and computer hardware.
▶ Every computer must have at least one OS to run other programs
▶ An application like Chrome, MS Word, Games, etc needs some
environment in which it will run and perform its task.
▶ The OS helps you to communicate with the computer without
knowing how to speak the computer’s language.
▶ It is not possible for the user to use any computer or mobile
device without having an operating system.
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
History Of OS 3
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
4
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Functions of an Operating System 5
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
In an operating system software performs each
of the function: 6
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
7
▶ Secondary-Storage Management: Systems have several levels
of storage which includes primary storage, secondary storage.
▶ Security: Security module protects the data and information of a
computer system against malware threat and authorized access.
▶ Command interpretation: This module is interpreting commands
given by the and acting system resources to process that
commands.
▶ Networking: A distributed system is a group of processors which
do not share memory, hardware devices, or a clock.
▶ Job accounting: Keeping track of time & resource used by
various job and users.
▶ Communication management: Coordination and assignment of
compilers, interpreters, and another software resource of the
various users of the computer systems.
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Types of Operating system 8
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Difference Between Firmware and Operating
System 9
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Advantages of Operating System 10
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Kernel in Operating System 12
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Functions of Kernel with Real-Time Examples 13
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
15
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Difference Between Shell and Kernel with Real-
Life Examples 16
Shell Kernel
Interface between user and Core component managing OS tasks
kernel (e.g., Linux Kernel in Android, Ubuntu)
(e.g., Command Prompt in
Windows, Terminal in Linux)
Executes user commands Handles resource management
(e.g., Running a script using (e.g., Allocating CPU time to applications)
Bash)
Provides command-line in- Directly interacts with hardware
terpreter (e.g., Managing memory allocation in real-
(e.g., macOS Terminal for time applications)
Unix commands)
Supports scripting and au- Manages memory and process scheduling
tomation (e.g., Ensuring smooth multitasking on
(e.g., Automating tasks us- smartphones)
ing shell scripts in Linux)
Example: Bash, Csh, Ksh Example: Linux, Windows NT, Minix
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Kernel Features 17
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Real-Time Kernels 18
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
What is a Process? 19
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
What is a Thread? 20
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Process vs. Thread: A Comparison 21
Process Thread
Program in execution Segment of a process
Own memory space Shares memory with other
threads
Heavier weight Lighter weight
Slower creation and termination Faster creation and termination
More overhead in context Less overhead in context switch-
switching ing
Inter-process communication is Intra-process communication is
less efficient efficient
Isolated execution Shared environment; changes
affect all threads
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Advantages and Disadvantages 22
Processes:
▶ Advantages:
▶ Memory isolation improves security.
▶ Independent resource allocation.
▶ Processes can be prioritized.
▶ Disadvantages:
▶ Slower creation and termination.
▶ Context switching is more time-consuming.
▶ High memory usage if too many processes are running.
Threads:
▶ Advantages:
▶ Faster creation and termination.
▶ Efficient handling of multiple tasks concurrently.
▶ Lower resource consumption.
▶ Disadvantages:
▶ Shared memory can lead to synchronization issues.
▶ Lack of isolation can cause interference between threads.
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Real-time Example: Processes & Threads in a
Web Browser 23
Processes:
▶ Each browser tab runs as a separate process with its own
memory.
▶ Isolation ensures that a crash in one tab does not affect the
others.
Threads within a Process:
▶ UI Thread: Handles user interactions (scrolling, clicking, typing).
▶ Rendering Thread: Draws the webpage content.
▶ Network Thread: Manages data fetching (images, scripts, text).
▶ JavaScript Thread: Executes scripts for interactivity.
Benefit: Multitasking with threads within isolated processes provides
a smooth, responsive browsing experience.
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Introduction to Synchronization 24
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
What is a Mutex? 25
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
What is a Semaphore? 26
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Usage in Operating Systems 27
▶ Mutexes:
▶ Protect critical sections in multi-threaded applications.
▶ Prevent race conditions in kernel data structures and process
scheduling.
▶ Semaphores:
▶ Regulate access to shared devices (e.g., printers, disk I/O).
▶ Manage pools of resources such as database connections or
thread pools.
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Usage in Embedded Systems 28
▶ Mutexes:
▶ Ensure exclusive access to hardware peripherals (e.g., sensor data
buffers).
▶ Used in Real-Time Operating Systems (RTOS) to coordinate task
execution.
▶ Semaphores:
▶ Control access to shared resources like communication buses
(I2C, SPI).
▶ Manage limited hardware resources (e.g., ADC channels) in
time-critical applications.
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Key Differences & Real-Time Examples 29
Differences:
▶ Mutex:
▶ Exclusive access; a single thread can hold the lock.
▶ Ownership rules prevent unintended release.
▶ Semaphore:
▶ Allows a limited number of threads to access resources
concurrently.
▶ Can be signaled by any thread.
Real-Time Examples:
▶ Operating Systems:
▶ A web server might use a counting semaphore to limit concurrent
access to a database.
▶ A mutex protects a critical section in the OS kernel to update
scheduling queues.
▶ Embedded Systems:
▶ An RTOS in a drone uses a mutex to secure sensor data
processing.
▶ A counting semaphore controls access to a limited number of
communication channels on a microcontroller.
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Overview of Context Switching 30
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
31
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
32
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Mechanism of Context Switching 33
▶ Saving State: The CPU saves the state of the currently running
process.
▶ Loading State: The CPU loads the state of the new process.
▶ Resuming Execution: Execution continues with the new
process.
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Impact on Performance 34
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Real-Time Embedded Systems 35
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Key Concepts 36
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Soft vs. Hard Real-Time Systems 37
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Jobs, Tasks, and Processors 38
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Clock-Driven Scheduling 39
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Round Robin Scheduling 40
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Weighted Round Robin Scheduling 41
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Priority-Driven Scheduling 42
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Example 43
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Job Scheduling Examples 44
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Effective Release Time 45
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Effective Deadline 46
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Example: Effective Release Time and Deadline 47
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Effective Release Time and Deadline 48
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Job Details and Effective Times 49
Job Given Release Time Given Deadline Effective Release Time Effective Deadline
J1 2 10 2 8
J2 0 7 0 7
J3 1 12 2 8
J4 4 9 4 9
J5 1 8 2 8
J6 0 20 4 20
J7 6 21 6 21
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Example 50
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Example 51
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Example 52
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Earliest Deadline First (EDF) 53
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Example 54
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Example 55
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Slack Time Definition 56
▶ Slack time is the amount of time left after a job if it were started
now.
▶ Defined mathematically as:
s = (d − t) − c ′
▶ Where:
▶ d = Process deadline
▶ t = Current real time since cycle start
▶ c ′ = Remaining computation time
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
LST Scheduling Algorithm 57
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Example 58
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Example 59
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
What is Shared Memory? 60
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Working of Shared Memory 61
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Example 62
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Example 63
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Use Cases of Shared Memory 64
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Advantages of Shared Memory 65
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Disadvantages of Shared Memory 66
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
What is Message-Based Communication? 67
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Distributed Programming Models Using
Message-Based Communication 68
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Advantages of Message-Based Communication 69
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Disadvantages of Message-Based Communica-
tion 70
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Example: Shared Memory Model Working 71
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Example: Message Passing Model Working 72
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Differences Between Shared Memory Model and
Message Passing Model 73
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
What is Memory Management? 74
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Example 75
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Why Memory Management is Required? 76
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Logical vs. Physical Address 77
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Memory Allocation Techniques 78
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Difference Between Paging and Segmentation 79
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Static vs. Dynamic Loading 80
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Static vs. Dynamic Linking 81
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Swapping 82
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Memory Allocation Strategies 83
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Memory allocation 84
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Memory Allocation Methods 85
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Key Differences: Stack vs Heap Memory Alloca-
tion 86
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Challenges of Dynamic Allocation 87
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Alternatives to Dynamic Allocation 88
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Best Practices for Dynamic Memory 89
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
RTOS and Dynamic Memory 90
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.
Real-Time Example: IoT-Based Smart Agricul-
ture System 91
Thank you
Dr. B. Naresh Kumar Reddy | Department of Electronics and Communication Engineering | National Institute of Technology Tiruchirappalli.