Threads in Operating System | DIT Notes
Threads
A simple, student-friendly and exam-oriented guide to threads, multithreading, thread components, shared resources, and types of threads.
Quick Access
Jump directly to any major part of Article 3.5.
3.5.1 What is a Thread?
The basic idea of a thread in an Operating System.
A thread is the smallest unit of execution within a process. A process can contain one or more threads, and each thread can perform a particular task.
Example: A web browser may use separate threads for loading a webpage, playing a video, handling user input, and downloading files.
3.5.2 Process and Thread
Understand the simple relationship between a process and its threads.
A process is a program in execution, while a thread is an execution path within a process.
| Process | Thread |
|---|---|
| Program in execution. | Unit of execution within a process. |
| Has its own address space. | Shares address space with threads of the same process. |
| Generally requires more resources. | Generally requires fewer resources. |
| Communication between processes can be more complex. | Threads can communicate through shared process resources. |
| Creation is relatively expensive. | Creation is generally faster. |
| Can contain one or more threads. | Exists within a process. |
3.5.3 Single-Threaded and Multithreaded Process
Two simple ways to understand how many threads a process contains.
Single-Threaded Process
A single-threaded process contains only one thread of execution. The process performs one sequence of instructions at a time.
Multithreaded Process
A multithreaded process contains two or more threads that can execute different tasks.
One sequence of instructions at a time.
Different tasks can make progress within the same process.
3.5.4 Components of a Thread
Each thread normally has its own execution-related information.
- Thread ID: Uniquely identifies a thread within its process.
- Program Counter: Stores the address of the next instruction to be executed by the thread.
- CPU Registers: Store the CPU register values required during execution.
- Stack: Stores function calls, local variables, and temporary data.
3.5.6 Advantages of Threads
Why threads are useful in applications.
3.5.7 Types of Threads
The source classifies threads into user-level and kernel-level threads.
1. User-Level Threads
User-level threads are managed by a user-level thread library rather than directly by the operating system kernel.
- Advantages: Fast to create and manage; less overhead; can be implemented without extensive kernel support.
- Limitation: If one thread performs a blocking operation, depending on the implementation, the entire process may be affected.
2. Kernel-Level Threads
Kernel-level threads are managed directly by the Operating System. The OS schedules these threads and manages their execution.
- Advantages: Better support for parallel execution; one blocked thread does not necessarily block other threads of the same process; suitable for multicore systems.
- Limitation: Thread management may involve more overhead than user-level threads.
Fast and less overhead.
Blocking may affect the process depending on implementation.
Better support for parallel execution and multicore systems.
May have more management overhead.
3.5.8 Process vs. Thread
A quick comparison for exam preparation.
| Process | Thread |
|---|---|
| Program in execution. | Unit of execution within a process. |
| Has its own address space. | Shares address space with threads of the same process. |
| Generally requires more resources. | Generally requires fewer resources. |
| Communication can be more complex. | Can communicate through shared process resources. |
| Creation is relatively expensive. | Creation is generally faster. |
| Can contain one or more threads. | Exists within a process. |
Quick Revision
Read these points once before attempting the questions.
- A thread is the smallest unit of execution within a process.
- A process can contain one or more threads.
- Threads of the same process share code, data, heap, open files, and other process resources.
- Each thread normally has its own Thread ID, Program Counter, CPU registers, and stack.
- A single-threaded process has one thread; a multithreaded process has two or more threads.
- Important advantages include responsiveness, resource sharing, economy, better performance, and improved application structure.
- User-level threads are managed by a user-level thread library.
- Kernel-level threads are managed directly by the Operating System.
- Learn the definition of a thread.
- Understand single-threaded vs. multithreaded process.
- Remember the four main thread components.
- Remember which resources are shared and which are private to a thread.
- Know the basic difference between user-level and kernel-level threads.
6 Short Questions & Answers
Simple questions for quick exam preparation.
Q1. What is a thread?
A thread is the smallest unit of execution within a process. It is a lightweight unit of execution inside a process.
Q2. What is a single-threaded process?
A single-threaded process contains only one thread of execution and performs one sequence of instructions at a time.
Q3. What is a multithreaded process?
A multithreaded process contains two or more threads that can execute different tasks within the same process.
Q4. Name the resources shared by threads of the same process.
Threads generally share program code, data, heap memory, open files, and other process resources.
Q5. What is a user-level thread?
A user-level thread is managed by a user-level thread library rather than directly by the operating system kernel.
Q6. What is a kernel-level thread?
A kernel-level thread is managed directly by the operating system. The OS schedules the thread and manages its execution.
1 Long Question & Answer
One focused long question for exam practice.
Q1. What is a thread? Explain single-threaded and multithreaded processes, components of a thread, and the advantages of threads.
A thread is the smallest unit of execution within a process. A process can contain one or more threads, and each thread can perform a particular task.
Single-threaded process: It contains only one thread of execution and performs one sequence of instructions at a time.
Multithreaded process: It contains two or more threads that can execute different tasks. For example, a media application may use separate threads for playing audio, displaying video, and handling user input.
Main components of a thread:
- Thread ID
- Program Counter
- CPU Registers
- Stack
Advantages: Threads improve responsiveness, allow resource sharing, generally require fewer resources than separate processes, can improve performance on multicore processors, and help divide complex applications into smaller tasks.
10 Important MCQs
Open each question, choose an option, then use “Show Answer”.
1. A thread is the smallest unit of:
Show Answer
2. A process may contain:
Show Answer
3. Which resource is normally private to each thread?
Show Answer
4. Which resource is generally shared by threads of the same process?
Show Answer
5. A process with two or more threads is called:
Show Answer
6. Which is an advantage of multithreading?
Show Answer
7. User-level threads are managed by:
Show Answer
8. Kernel-level threads are managed directly by:
Show Answer
9. Which type of thread is generally fast to create and manage?
Show Answer
10. Threads of the same process can communicate more easily because they:
Show Answer
Final Exam Reminder
Last-minute revision checklist.

No comments