Affiliated to Visvesvaraya Technological University, Belagavi.
Approved By AICTE, New Delhi.
Recognized by UGC with 2(f) & 12(B) status.
Accredited by NBA and NAAC
ARM MICROCONTROLLER
MVJ22EC61
TITLE:Threads in Embedded Systems
Presented by,
1MJ22EC091 Name:MAHEEN FIRDOUS C
Guided by,
Assistant professor
DIVYA
An AutonomousInstitute Affiliated to VTU Belagavi, Approved by AICTE, Recognized by UGC with 2(f) & 12(b), Accredited by NBA & NAAC 1
OVERVIEW
• Introduction
• Creating and managing threads
• Threading in embedded application
• Effective debugging techniques
• Trends in thread management
2
INTRODUCTION
THREAD IN EMBEDDED SYSTEM
In embedded systems, a thread is the smallest unit of execution within a process. Threads allow multitasking
by enabling a program to perform multiple operations concurrently. This is essential for responsive, real-time
behavior in embedded applications such as automotive systems, IoT devices, or medical instruments.
Key Characteristics:
•Lightweight: Threads share memory space and system resources, making them more efficient than
processes.
•Concurrent Execution: Threads can run simultaneously on multi-core processors or be scheduled rapidly on
single-core CPUs to appear concurrent.
•Responsiveness: Critical in embedded systems where tasks like sensor reading, communication, and user
input must occur in real time.
•Scheduling: Typically managed by a Real-Time Operating System (RTOS) like FreeRTOS, VxWorks, or Zephyr.
Example Use Case:
In a smart home thermostat:
•One thread reads the temperature sensor.
•Another updates the display.
•A third handles network communication.
3
CREATING AND MANAGING THREADS
• In embedded systems, threads are usually created using RTOS APIs. Each RTOS provides its own set of
functions for thread (task) creation and management. Below are thread creation methods using APIs from
the three most widely used RTOS platforms:
RTOS API Function Priority-Based Custom Stack Popular In
FreeRTOS xTaskCreate() ✅ Yes ✅ Yes Industry,
Academia
CMSIS-RTOS2 osThreadNew() ✅ Yes ✅ Yes ARM Cortex-M
Apps
Zephyr RTOS k_thread_create( ✅ Yes ✅ Yes IoT, Nordic, NXP
)
4
CREATING
CREATING AND
AND MANAGING THREADS
MANAGING THREADS
Thread Initialization: Attributes
When creating a thread in an embedded system using an RTOS, attributes define the thread’s behavior and
configuration — such as its name, stack size, priority, and more.
• Below is a concise overview of common thread attributes, especially as used in CMSIS-RTOS2 and
Zephyr RTOS.
Attribute Description
Human-readable thread name (for
Name
debugging/logging)
Amount of stack memory allocated for the
Stack Size
thread (in bytes or words)
Execution priority level of the thread (higher
Priority
= more important)
Optional memory pool for control blocks or
Memory
stack
OS-specific flags for thread behavior (e.g.,
Attributes Flags
detached state)
5
CREATING AND MANAGING THREADS
• Thread Management – Key Aspects
• Efficient thread management is crucial in embedded systems for achieving real-time performance,
resource optimization, and system stability. Below are the key aspects of thread (task) management, as
supported by major RTOS platforms like FreeRTOS, CMSIS-RTOS2, and Zephyr.
Example API (FreeRTOS /
Aspect Description
CMSIS-RTOS2 / Zephyr)
Starts a new thread/task with
xTaskCreate() / osThreadNew() /
Thread Creation defined function, stack, and
k_thread_create()
priority.
Decides which thread runs at a
Auto-managed by RTOS scheduler
Thread Scheduling given time. Supports preemptive
(vTaskStartScheduler() etc.)
and round-robin.
Defines importance of threads;
vTaskPrioritySet() /
Thread Priority higher priority threads preempt
osThreadSetPriority() /
lower ones.
6
THREADING IN EMBEDDED APPLICATION
RTOS in automotive systems
Real-time operating systems (RTOS) implement threading for managing tasks in automotive control systems,
ensuring reliability and efficiency.
Threading in IOT devices
In IOT devices, threading facilitates simultaneous data collection and processing, significantly enhancing
overall performance.
Smart TVs use threading
Consumer electronics like smart TVs utilize threads for executing background updates while keeping the
user interface responsive.
7
EFFECTIVE DEBUGGING TECHNIQUES
• 1) Use Debugging Tools
• Utilize tools like GDB or Valgrind to trace thread behavior.
• 2) Employ Logging Frameworks
• Capture thread activity and performance metrics using logging frameworks.
• 3) Analyze Thread Dumps
• Understand the state of threads at a specific moment by analyzing thread dumps.
• 4) Leverage Static Analysis
• Detect potential threading issues during development with static analysis tools.
8
TRENDS IN THREAD MANAGEMENT
• 1) Al Integration in Thread Management
• The use of Al for dynamic scheduling and optimization is transforming how threads are managed, leading
to more efficient resource utilization.
• 2) Focus on Security in Multi-threading
• As multi-threaded applications become prevalent, there is a growing omphasis on security to mitigate
vulnerabilities and protect data integrity.
• 3)Emergence of Heterogeneous Computing
• The rise of heterogeneous computing environments is prompting the development of new threading
models that cater to various hardware architectures
• 4) Evolution of Programming Languages
• Continuous advancements in programming languages and frameworks are enhancing threading support,
especially in embed better performance
9
THANK YOU
An AutonomousInstitute Affiliated to VTU Belagavi, Approved by AICTE, Recognized by UGC with 2(f) & 12(b), Accredited by NBA & NAAC 10