๐ง Program vs Process vs Thread
Term | Meaning |
---|---|
Program | A file with code (instructions), stored on disk, ready to be run. |
Process | A running instance of a program (stored in RAM). Has its own memory, resources. |
Thread | A smaller unit of a process. A path of execution within a process. Shares memory with other threads in the same process. |
โ๏ธ Multitasking vs Multithreading
Feature | Multitasking | Multithreading |
---|---|---|
Definition | Running multiple processes at once | Running multiple threads (tasks) inside a single process |
Example | Opening a browser, music player, and Word at the same time | While typing in Word: auto-save, spell-check, and UI update run simultaneously |
Switching | Between processes (heavyweight) | Between threads (lightweight) |
Memory | Each process has separate memory | Threads share memory of the same process |
Speed | Slower (context switch needs more resources) | Faster (context switch is lightweight) |
CPU Requirement | Can work with 1 CPU | Better performance with multi-core CPU |
๐ Context Switching: Process vs Thread
Feature | Thread Switching | Process Switching |
---|---|---|
Switches | Between threads of same process | Between different processes |
Memory Switch | No memory address space switch | Memory address space must switch |
Speed | Fast | Slower |
CPU Cache | Preserved | Flushed |
๐งฉ Components of Operating System

1. Kernel (Core of the OS)
- Directly talks to hardware.
- Loaded first when OS starts.
- Responsible for process mgmt, memory mgmt, file mgmt, I/O mgmt.
2. User Space
- Where apps and software run.
- Can't directly access hardware.
- Talks to kernel via system calls.
- Examples: GUI, Command Line (Shell).
๐งต Kernel Functions in Detail
Process Management
Create/suspend/terminate processes, manage threads
Memory Management
Allocate/deallocate memory, track usage
File Management
Create/delete files and directories, backup
I/O Management
Handle input/output devices, use buffering, caching, spooling
๐ง Buffering vs Caching vs Spooling

Feature | Buffering | Spooling |
---|---|---|
Storage | Uses main memory (RAM) | Uses secondary storage (Disk) |
Purpose | Handle speed mismatch between producer & consumer | Handle device sharing among multiple processes |
Operation | Temporary storage during transfer | Queue system for managing device access |
Devices | Mostly used for fast I/O devices (keyboard, mouse, streaming, etc.) | Mostly used for slow devices (printers, plotters, etc.) |
Data Size | Small amount of data | Large amount of data (since stored on disk) |
Example | YouTube video buffering, keyboard input | Printer spooling, batch job execution |
๐งฌ Types of Kernels
Type | Features | Pros | Cons | Examples |
---|---|---|---|---|
Monolithic Kernel | All OS services (memory, process, file, I/O) are in kernel space. |
|
|
Linux, Unix, MS-DOS |
Microkernel | Only core functionalities (like memory & process management) in kernel. Other services run in user space. |
|
|
MINIX, Symbian OS, L4 Linux |
Hybrid Kernel | Combines features of Monolithic and Microkernels. Some services in kernel, others in user space. |
|
|
Windows NT/7/10, macOS |
๐ Communication: User Mode โ Kernel Mode

- Apps (in user space) cannot directly access hardware.
- They request kernel services via System Calls (with help of Shell or CLI).
- System Call = Gateway between User Mode & Kernel Mode
๐ Example:
mkdir folder
mkdir
is not the real function that creates a folder.It calls a system call (like
mkdir()
syscall in C) to tell kernel to
create directory.
๐ What is a System Call?
- A programmatic way for user applications to ask OS for resources or services.
- Needed because user programs don't have permissions for direct hardware access.
- Implemented in C and triggered by software interrupts.
๐ฏ Common System Calls:
Process Control
fork()
, exec()
, exit()
File Operations
open()
, read()
, write()
Device Management
ioctl()
, read()
, write()
Info Management
getpid()
, alarm()
Communication
pipe()
, shmget()
, msgsnd()
๐ Summary (Quick Revision)
Concept | Key Point |
---|---|
Program | Stored code on disk |
Process | Running instance of a program |
Thread | Light-weight unit of process, shares memory |
Multitasking | Multiple processes running |
Multithreading | Multiple threads in same process |
Kernel | Heart of OS, handles core tasks |
System Call | Bridge between user programs and kernel |
Buffering | Within job, temporary storage (e.g., video streaming) |
Spooling | Job queueing for devices (e.g., printer) |
Caching | Speed up frequent access (e.g., web cache) |
๐งช Interview-Oriented Questions
- What is the difference between a process and a thread?
- How does multithreading improve performance?
- Explain context switching in multithreading vs multitasking.
- What are the responsibilities of a kernel?
- Explain different types of kernels.
- What is the purpose of system calls?
- How does user space communicate with kernel space?
- What is the difference between buffering, spooling, and caching?
- Why is process switching slower than thread switching?
- What happens behind the scenes when we run
mkdir
in the terminal?