Unit 2.2 (2 Out of 4) - 1
Unit 2.2 (2 Out of 4) - 1
(24CS301PC204)
Unit – 2.2
Threads
Dr. Rajchandar Kannan, M.E., M.B.A., Ph.D.
Assistant Professor, School of CS&AI,
SR University, Warangal.
UNIT – II (Contact Hours: 10)
I. Process Management: Process Concept, Process control
block, Process States, Process Scheduling, Operations on
Processes, Inter process Communication.
II. Threads: Overview, Multi core Programming,
Multithreading Models, Threading Issues.
III.CPU Scheduling: Basic Concepts, Scheduling Criteria,
Scheduling Algorithms
IV.Process Synchronization: Background, The Critical-Section
Problem, Peterson’s Solution, Synchronization Hardware,
Mutex Locks, Semaphores, Classic Problems of
Synchronization, Monitors.
31-01-2025 Dr. Rajchandar Kannan - Operating System - Unit 2 2
II. Threads
1.Overview
2.Multi core Programming
3.Multithreading Models
4.Threading Issues.
• Multiple threads can exist within a single process, sharing resources like
memory and file handles.
Thread
Create Threads (e.g., Execute code in
Creation within pthread_create()). threads.
a Process:
Termination of
the Entire Terminate Process.
Process:
Threads
3. Deadlocks
• If two or more threads hold resources while waiting for each other to
release them, a circular wait situation may arise, leading to a deadlock.
4. Starvation
Some threads may be indefinitely delayed due to priority scheduling, preventing
them 31-01-2025
from gaining access to necessary resources.
Dr. Rajchandar Kannan - Operating System - Unit 2 14
Threading Issues
5. Thread Synchronization Issues
Improper use of synchronization mechanisms (such as mutexes, semaphores, and condition variables)
can lead to inefficiencies or errors like deadlocks and priority inversion.
6. Priority Inversion
A high-priority thread may be blocked because a low-priority thread is holding a required resource,
leading to delays in execution.
7. Resource Contention
Multiple threads competing for CPU time, memory, or I/O resources can cause performance
degradation due to excessive locking and waiting.
8. Thread Safety
Functions and shared data structures must be designed to be thread-safe to avoid unexpected behaviors in
concurrent execution.