You are on page 1of 10

Embedded Systems and RTOS

Session 4.5

Process and Thread Concept

Shripad V Deshpande

Electronics & Telecommunication Engineering


Symbiosis Institute of Technology, Pune
Symbiosis International (Deemed University), Pune
PROCESS
• A process : Independently executable unit of a program
which is used to perform a specific task in a system.
• Many processes run concurrently.
• Process runs by executing the instructions sequentially
and it can be in one of several states. The state is
controlled by OS (kernel).
• Runs only when it is in ready-to-run state and is
scheduled to run by the OS (kernel)
• Several processes communicate with each other.
• Process Structure: Data, Objects & resources, and
Process Control Block (PCB)
• Application program can be said to consist of number of
processes
2
EXAMPLE – MOBILE PHONE DEVICE
• Software is highly complex
• Several programs must be concurrently running
on a single processor
• Different processes involved
• Voice encoding process
• Modulating process
• Display process
• Key input process

• Each process has its own PCB

3
PROCESS CONTROL BLOCK
• A data structure having the information using which the OS
controls the process state
• Stores in protected memory area of the kernel.
• PCB consists of the information about the process state
• The PCB will have following information
• Process ID (PID)
• Process Priority
• Parent Process
• Child Process(s)
• Address to the PCB of next process, which will run next
• Allocated program memory block details in Physical Memory and
Virtual Memory
• Allocated heap memory details
• Allocated process stack addresses for the functions called
during running of the process
4
THREAD
• A thread is a path of execution within a process.
• PCB controls the working of all threads within that process.
• It is the smallest sequence of programmed instructions that
can be managed independently by an operating
system scheduler.
• A thread can be thought of as a light-weight process
• A thread is contained inside a process.
• Multiple threads can exist within the same process and share
resources such as memory, while different processes do not
share these resources.
• One thread does not interfere with other thread.
• Process : a program in execution
• Thread : function in execution
5
SINGLE AND MULTITHREADED PROCESSES

6
THREAD STRUCTURE
Thread ID

Stack Pointer
Each Threads maintains it own

Program Counter

Set of Registers
7
EXAMPLE : DISPLAY PROCESS IN MOBILE PHONE
• Display_Time_Date thread ─ for displaying clock time and
date.
• Display_Battery thread ─ for displaying battery power.
• Display_Signal thread ─ for displaying signal strength
• Display_Profile thread ─ for displaying silent or sound-
active mode
• Display_Message thread ─ for displaying unread message
in the inbox
• Display_Call Status thread ─ for displaying call status;

• Display threads can share the common memory blocks and


resources allocated to the Display_Process
8
THREADS OF A PROCESS SHARING PROCESS STRUCTURE

Application program can be said to consist of number of threads or


processes

9
Next Session 4.6 ->
Creating and processing POSIX threads

You might also like