SlideShare a Scribd company logo
Threads and Processes in
Operating Systems
Introduction to Operating Systems
● An operating system (OS) is system software that
manages computer hardware and software
resources
● Key functions of an OS:
- Process Management
- Memory Management
- File System Management
- I/O Management
● Modern OS examples: Windows, Linux, macOS,
Android, iOS
What is a Process?
● A process is an independent program in execution
● Each process has its own:
- Memory space (Code, Data, Stack, Heap)
- CPU registers
- Process Control Block (PCB)
- I/O resources
● Examples: Web browser, text editor, music player
● Processes communicate through Inter-Process
Communication (IPC) mechanisms
Process States
● New: Process is being created
● Ready: Process is waiting to be assigned to a processor
● Running: Instructions are being executed
● Waiting/Blocked: Process is waiting for some event to
occur
● Terminated: Process has finished execution
Process Control Block (PCB)
● PCB is a data structure maintained by the OS for
each process
● Contains all information needed to manage the
process:
- Process ID (PID)
- Process State
- Program Counter
- CPU Registers
- Memory Management Information
What is a Thread?
● A thread is a lightweight execution unit within a
process
● Threads share memory and resources with other
threads in the same process
● Enables concurrent execution within a process
Thread Attributes
- Thread ID: Unique identifier for each thread.
- Program Counter: Tracks the next instruction.
- Register Set: Stores working variables.
Example usage of threads
Output:
This example demonstrates:
1.Creation of two threads using pthread_create()
2.Each thread executes the print_message function with
a different argument
3.The main thread waits for both threads to complete
using pthread_join()
4.Threads share the same code but have different
execution paths
Process vs Thread
Aspect Process Thread
Definition Independent program
in execution
Lightweight execution
unit within a process
Memory Separate memory
space
Shared memory
space
Communication Inter-Process
Communication (IPC)
Direct through shared
memory
Creation Overhead High Low
Context Switch Expensive Less expensive
Multi-threading: Benefits and Applications
Benefits of Multi-threading:
- Improved responsiveness
- Resource sharing
- Economy (less overhead than multiple processes)
- Scalability (better utilization of multiprocessor architectures)
Types of Threads
● User-Level Threads:
- Managed by user libraries
- Faster but blocks entire process
● Kernel-Level Threads:
- Managed by OS kernel
- Slower but more robust
User-Level Threads
Implemented by user-level thread libraries
● Advantages:
- Fast thread switching
- Can be implemented on any OS
● Disadvantages:
- Entire process blocks if one thread makes a blocking system call
Kernel-Level Threads
Implemented and managed by the OS kernel
● Advantages:
- Can utilize multiprocessor architectures
- If one thread blocks, others can still run
● Disadvantages:
- Higher overhead for thread management
Thread Implementation Examples
● POSIX Threads (Pthreads):
- Standard API for creating and manipulating threads
● Java Threads:
- Built into Java language
● Windows Threads:
- Part of the Win32 API
Practical Applications
● Web Browsers:
- Separate threads for rendering, JavaScript
execution, network I/O
● Server Applications:
- Thread pool for handling multiple client
connections
● Mobile Applications:
- Background threads for data synchronization
● Video Editing Software:
- Parallel processing of video frames
Thank You!
A Anshul Rao
23B81A05D6

More Related Content

PPTX
OSModule1 important topics in detailed with examples
JithinS34
 
PPT
Advanced_OS_Unit 1 & 2.ppt
DuraisamySubramaniam1
 
PPT
cs-intro-os.ppt
infomerlin
 
PDF
MK Sistem Operasi.pdf
wisard1
 
PPT
EMBEDDED OS
AJAL A J
 
PPT
Processes and Threads in Windows Vista
Trinh Phuc Tho
 
PDF
Linux-Internals-and-Networking
Emertxe Information Technologies Pvt Ltd
 
PDF
Unit 4
pm_ghate
 
OSModule1 important topics in detailed with examples
JithinS34
 
Advanced_OS_Unit 1 & 2.ppt
DuraisamySubramaniam1
 
cs-intro-os.ppt
infomerlin
 
MK Sistem Operasi.pdf
wisard1
 
EMBEDDED OS
AJAL A J
 
Processes and Threads in Windows Vista
Trinh Phuc Tho
 
Linux-Internals-and-Networking
Emertxe Information Technologies Pvt Ltd
 
Unit 4
pm_ghate
 

Similar to Threads and Processes in Operating Systems.pptx (20)

PPT
Os concepts
Sudheesh P Enathu
 
PDF
Threads in Operating System for GATE.pdf
RahulRaj493025
 
PPTX
Chapter -2 operating system presentation
chnrketan
 
PPTX
Bca i-fundamental of computer-u-3-functions operating systems
Rai University
 
PDF
operating system S6 ktu physics and computer application
ebindboby1
 
PPTX
Distributive operating system
Muhammad Adeel Rajput
 
PPTX
Introduction _to_ OperatingSystem_1.pptx
shyamala53
 
PPTX
Mca i-fundamental of computer-u-3-functions operating systems
Rai University
 
PPTX
Bsc cs 1 fit u-3 operating systems
Rai University
 
PPTX
Bsc cs 1 fit u-3 operating systems
Rai University
 
PDF
Operating System Concepts Presentation
Nitish Jadia
 
PDF
Ch3 processes
Welly Dian Astika
 
PPTX
Operating Systems & Applications
Maulen Bale
 
PDF
Operating System.pdf
Syed Zaid Irshad
 
PDF
threads (1).pdfmjlkjfwjgliwiufuaiusyroayr
abhinandpk2405
 
PPTX
Operating System concepts
E.M.G.yadava womens college
 
PPT
CH3-OS.PPT operating system structures module
deviveeranan7
 
PPTX
Chapter 1 Introduction to Operating System Concepts
MeenalJabde
 
PPTX
Operating system v1 d1
Himanshu Pant
 
Os concepts
Sudheesh P Enathu
 
Threads in Operating System for GATE.pdf
RahulRaj493025
 
Chapter -2 operating system presentation
chnrketan
 
Bca i-fundamental of computer-u-3-functions operating systems
Rai University
 
operating system S6 ktu physics and computer application
ebindboby1
 
Distributive operating system
Muhammad Adeel Rajput
 
Introduction _to_ OperatingSystem_1.pptx
shyamala53
 
Mca i-fundamental of computer-u-3-functions operating systems
Rai University
 
Bsc cs 1 fit u-3 operating systems
Rai University
 
Bsc cs 1 fit u-3 operating systems
Rai University
 
Operating System Concepts Presentation
Nitish Jadia
 
Ch3 processes
Welly Dian Astika
 
Operating Systems & Applications
Maulen Bale
 
Operating System.pdf
Syed Zaid Irshad
 
threads (1).pdfmjlkjfwjgliwiufuaiusyroayr
abhinandpk2405
 
Operating System concepts
E.M.G.yadava womens college
 
CH3-OS.PPT operating system structures module
deviveeranan7
 
Chapter 1 Introduction to Operating System Concepts
MeenalJabde
 
Operating system v1 d1
Himanshu Pant
 
Ad

Recently uploaded (20)

PDF
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PDF
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PPTX
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
PPTX
CDH. pptx
AneetaSharma15
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
PPTX
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
PPTX
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
How to Apply for a Job From Odoo 18 Website
Celine George
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
CDH. pptx
AneetaSharma15
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
How to Apply for a Job From Odoo 18 Website
Celine George
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
Ad

Threads and Processes in Operating Systems.pptx

  • 1. Threads and Processes in Operating Systems
  • 2. Introduction to Operating Systems ● An operating system (OS) is system software that manages computer hardware and software resources ● Key functions of an OS: - Process Management - Memory Management - File System Management - I/O Management ● Modern OS examples: Windows, Linux, macOS, Android, iOS
  • 3. What is a Process? ● A process is an independent program in execution ● Each process has its own: - Memory space (Code, Data, Stack, Heap) - CPU registers - Process Control Block (PCB) - I/O resources ● Examples: Web browser, text editor, music player ● Processes communicate through Inter-Process Communication (IPC) mechanisms
  • 4. Process States ● New: Process is being created ● Ready: Process is waiting to be assigned to a processor ● Running: Instructions are being executed ● Waiting/Blocked: Process is waiting for some event to occur ● Terminated: Process has finished execution
  • 5. Process Control Block (PCB) ● PCB is a data structure maintained by the OS for each process ● Contains all information needed to manage the process: - Process ID (PID) - Process State - Program Counter - CPU Registers - Memory Management Information
  • 6. What is a Thread? ● A thread is a lightweight execution unit within a process ● Threads share memory and resources with other threads in the same process ● Enables concurrent execution within a process
  • 7. Thread Attributes - Thread ID: Unique identifier for each thread. - Program Counter: Tracks the next instruction. - Register Set: Stores working variables.
  • 8. Example usage of threads Output: This example demonstrates: 1.Creation of two threads using pthread_create() 2.Each thread executes the print_message function with a different argument 3.The main thread waits for both threads to complete using pthread_join() 4.Threads share the same code but have different execution paths
  • 9. Process vs Thread Aspect Process Thread Definition Independent program in execution Lightweight execution unit within a process Memory Separate memory space Shared memory space Communication Inter-Process Communication (IPC) Direct through shared memory Creation Overhead High Low Context Switch Expensive Less expensive
  • 10. Multi-threading: Benefits and Applications Benefits of Multi-threading: - Improved responsiveness - Resource sharing - Economy (less overhead than multiple processes) - Scalability (better utilization of multiprocessor architectures)
  • 11. Types of Threads ● User-Level Threads: - Managed by user libraries - Faster but blocks entire process ● Kernel-Level Threads: - Managed by OS kernel - Slower but more robust
  • 12. User-Level Threads Implemented by user-level thread libraries ● Advantages: - Fast thread switching - Can be implemented on any OS ● Disadvantages: - Entire process blocks if one thread makes a blocking system call
  • 13. Kernel-Level Threads Implemented and managed by the OS kernel ● Advantages: - Can utilize multiprocessor architectures - If one thread blocks, others can still run ● Disadvantages: - Higher overhead for thread management
  • 14. Thread Implementation Examples ● POSIX Threads (Pthreads): - Standard API for creating and manipulating threads ● Java Threads: - Built into Java language ● Windows Threads: - Part of the Win32 API
  • 15. Practical Applications ● Web Browsers: - Separate threads for rendering, JavaScript execution, network I/O ● Server Applications: - Thread pool for handling multiple client connections ● Mobile Applications: - Background threads for data synchronization ● Video Editing Software: - Parallel processing of video frames
  • 16. Thank You! A Anshul Rao 23B81A05D6