Operating Systems
Processes, Threads, CPU Scheduling, Deadlocks, Memory Management & Linux Internals
Operating System Interview Questions — Complete Notes#
Table of Contents#
[[#1. OS Fundamentals]] [[#2. Process Management]] [[#3. CPU Scheduling]] [[#4. Threads]] [[#5. Process Synchronization]] [[#6. Deadlocks]] [[#7. Memory Management]] [[#8. Virtual Memory]] [[#9. File Systems]] [[#10. I/O Management]] [[#11. System Calls]] [[#12. Kernel]] [[#13. Multiprocessing & Distributed Systems]] [[#14. Real-Time Systems]] [[#15. Classic OS Problems]] [[#16. Linux-Specific Questions]] [[#17. Quick Revision]]
1. OS Fundamentals#
Q1. What is an Operating System?#
An Operating System (OS) is system software that acts as an intermediary between users/applications and computer hardware. It manages hardware resources and provides services for programs.
Responsibilities
-
Process Management
-
Memory Management
-
File Management
-
Device Management
-
Security & Protection
-
CPU Scheduling
Examples
-
Windows
-
Linux
-
macOS
-
Android
-
iOS
Interview One-Liner:
"An OS is a resource manager and an abstraction layer between hardware and applications."
Q2. Why do we need an Operating System?#
Without an OS:
-
Applications would directly access hardware.
-
Resource conflicts would occur.
-
Memory management would be difficult.
-
Security would be nearly impossible.
Benefits
-
Ease of use
-
Resource sharing
-
Security
-
Reliability
-
Multitasking
Q3. What are the different types of Operating Systems?#
1. Batch Operating System
Jobs are collected and executed in batches.
Advantages
- High throughput
Disadvantages
- No interaction during execution
2. Multiprogramming OS
Multiple programs reside in memory simultaneously.
Goal
Keep CPU busy.
3. Multitasking OS
Multiple tasks appear to execute simultaneously through context switching.
Example:
-
Browsing
-
Music
-
Coding simultaneously
4. Multiprocessing OS
Uses multiple processors.
Examples:
- Modern CPUs
5. Distributed OS
Multiple systems work together as one system.
6. Real-Time OS (RTOS)
Guarantees response within deadlines.
Examples:
-
Airbag Systems
-
Medical Equipment
Q4. What is the difference between Multiprogramming, Multitasking and Multiprocessing?#
| Multiprogramming | Multitasking | Multiprocessing |
|---|---|---|
| Multiple programs in memory | Multiple tasks executed concurrently | Multiple CPUs execute tasks |
| Single CPU | Usually single CPU | Multiple CPUs |
| Goal: CPU utilization | Goal: User responsiveness | Goal: Parallelism |
Q5. What are the goals of an Operating System?#
Primary Goals
-
Convenience
-
Efficiency
-
Resource Management
-
Fairness
-
Security
-
Reliability
2. Process Management#
Q6. What is a Process?#
A process is a program in execution.
A process consists of:
-
Code Section
-
Data Section
-
Heap
-
Stack
-
Registers
-
Program Counter
Example
Running Chrome Browser = Process
Q7. Program vs Process#
| Program | Process |
|---|---|
| Passive entity | Active entity |
| Stored on disk | Stored in memory |
| Static | Dynamic |
| No state | Has state |
Interview Example
Chrome.exe on disk → Program
Chrome currently running → Process
Q8. What are the states of a Process?#
textNew ↓ Ready ↓ Running ↓ Waiting ↓ Ready ↓ Terminated
New
Process is being created.
Ready
Waiting for CPU allocation.
Running
Currently executing.
Waiting
Waiting for I/O or event.
Terminated
Execution completed.
Q9. What is PCB (Process Control Block)?#
PCB stores information about a process.
Contents
-
Process ID
-
Process State
-
Program Counter
-
CPU Registers
-
Scheduling Information
-
Memory Information
-
Open Files
Importance
Without PCB, context switching is impossible.
Q10. What is Context Switching?#
Process of saving one process state and loading another.
Steps
-
Save current PCB
-
Load next PCB
-
Resume execution
Drawback
Consumes CPU time.
Interview Tip
Context switching is pure overhead.
No useful work is performed.
Q11. What is Process Scheduling?#
Mechanism of selecting a process from the ready queue and assigning CPU.
Objectives
-
Maximize CPU Utilization
-
Minimize Waiting Time
-
Minimize Turnaround Time
-
Maximize Throughput
Q12. What is a Zombie Process?#
A process that has finished execution but whose PCB still exists.
Reason
Parent has not collected exit status.
Solution
cwait();
Interview Tip
Zombie = Dead process occupying process table entry.
Q13. What is an Orphan Process?#
A child process whose parent terminates before it.
What Happens?
OS assigns it to:
textinit process
(or systemd in modern Linux)
Q14. Zombie vs Orphan Process#
| Zombie | Orphan |
|---|---|
| Child terminated | Parent terminated |
| PCB remains | Process still running |
| Wastes process table entry | Adopted by init |
3. Threads#
Q15. What is a Thread?#
A thread is the smallest unit of CPU execution.
Multiple threads can exist inside a process.
Shared Resources
-
Code
-
Heap
-
Data
Private Resources
-
Stack
-
Registers
-
Program Counter
Q16. Process vs Thread#
| Process | Thread |
|---|---|
| Heavyweight | Lightweight |
| Own memory | Shared memory |
| Expensive switching | Cheap switching |
| IPC required | Direct communication |
Interview Tip
Threads are preferred for performance.
Processes are preferred for isolation.
Q17. What is Multithreading?#
Executing multiple threads concurrently inside a process.
Advantages
-
Better CPU utilization
-
Responsiveness
-
Resource sharing
-
Faster execution
Examples
-
Browser Tabs
-
VS Code
-
IDEs
Q18. User Thread vs Kernel Thread#
| User Thread | Kernel Thread |
|---|---|
| Managed by user library | Managed by OS |
| Faster | Slower |
| OS unaware | OS aware |
| Blocking affects all threads | Blocking affects one thread |
4. CPU Scheduling#
Q19. What is CPU Scheduling?#
Process of selecting which ready process gets CPU next.
Scheduling Criteria
-
CPU Utilization
-
Throughput
-
Waiting Time
-
Response Time
-
Turnaround Time
Q20. What are the Scheduling Algorithms?#
FCFS (First Come First Serve)
Processes execute in arrival order.
Advantage
Simple
Disadvantage
Convoy Effect
SJF (Shortest Job First)
Smallest burst time executes first.
Advantage
Minimum average waiting time
Disadvantage
Starvation
Priority Scheduling
Higher priority process executes first.
Problem
Starvation
Solution
Aging
Round Robin
Each process receives a fixed time quantum.
Advantage
Fair scheduling
Used In
Time-sharing systems
Multilevel Queue Scheduling
Processes divided into different queues.
Examples:
-
System Processes
-
Interactive Processes
-
Batch Processes
Multilevel Feedback Queue
Processes can move between queues.
Used in modern operating systems.
[!tip]
Most Frequently Asked OS Questions So Far:
✓ What is OS?
✓ Types of OS
✓ Process vs Program
✓ Process States
✓ PCB
✓ Context Switching
✓ Zombie Process
✓ Orphan Process
✓ Thread vs Process
✓ Multithreading
✓ CPU Scheduling
✓ FCFS
✓ SJF
✓ Round Robin
✓ Priority Scheduling
5. Process Synchronization#
Q21. What is Process Synchronization?#
Process synchronization ensures that multiple processes or threads can safely access shared resources without causing data inconsistency.
Why Needed?
When multiple processes access shared data simultaneously:
-
Race conditions may occur
-
Data corruption may occur
-
Incorrect results may be produced
Goal
Maintain data consistency.
Q22. What is the Critical Section Problem?#
A critical section is a part of a program where shared resources are accessed.
Example
ccount++;
If two threads execute simultaneously, incorrect results may occur.
Requirements of a Good Solution
-
Mutual Exclusion
-
Progress
-
Bounded Waiting
Q23. What is a Race Condition?#
A race condition occurs when the final result depends on the order of execution of concurrent processes.
Example
Initial Value:
textcount = 0
Thread A:
ccount++;
Thread B:
ccount++;
Expected:
textcount = 2
Possible Actual:
textcount = 1
Solution
-
Mutex
-
Semaphore
-
Monitor
Q24. What is Mutual Exclusion?#
Mutual exclusion ensures that only one process enters the critical section at a time.
Goal
Prevent simultaneous access to shared resources.
Q25. What is Peterson's Solution?#
A software-based solution to the critical section problem for two processes.
Uses
-
Turn Variable
-
Flag Array
Properties
✔ Mutual Exclusion
✔ Progress
✔ Bounded Waiting
Limitation
Works only for two processes.
Q26. What is a Semaphore?#
A semaphore is a synchronization mechanism used to control access to shared resources.
Operations
cwait() signal()
Working
-
wait() decreases semaphore value
-
signal() increases semaphore value
Q27. Types of Semaphore#
Binary Semaphore
Values:
text0 or 1
Used like a lock.
Counting Semaphore
Values:
text0 to N
Used when multiple instances of a resource exist.
Example:
textPrinter Pool Connection Pool
Q28. What is a Mutex?#
Mutex stands for:
textMutual Exclusion
A lock that allows only one thread to access a resource.
Operations
clock() unlock()
Important
The thread that acquires the mutex must release it.
Q29. Semaphore vs Mutex#
| Semaphore | Mutex |
|---|---|
| Signaling mechanism | Locking mechanism |
| Integer variable | Object |
| No ownership | Ownership exists |
| Binary/Counting | Binary only |
| Used for synchronization | Used for mutual exclusion |
Interview Tip
Mutex = Lock
Semaphore = Counter
Q30. What is a Monitor?#
A monitor is a high-level synchronization construct.
Contains
-
Shared Data
-
Procedures
-
Synchronization Logic
Advantage
Simpler and safer than semaphores.
Q31. What is a Spinlock?#
A lock where a thread repeatedly checks until the lock becomes available.
cwhile(lock == BUSY);
Advantages
- No context switching
Disadvantages
- CPU wastage
Used When
Waiting time is very short.
6. Deadlocks#
Q32. What is a Deadlock?#
A deadlock occurs when two or more processes wait indefinitely for resources held by each other.
Example
Process P1 holds Resource A and waits for B.
Process P2 holds Resource B and waits for A.
Both wait forever.
Q33. Necessary Conditions for Deadlock#
All four conditions must occur simultaneously.
1. Mutual Exclusion
Resource cannot be shared.
2. Hold and Wait
Process holds one resource and waits for another.
3. No Preemption
Resources cannot be forcibly taken away.
4. Circular Wait
Processes form a cycle of waiting.
Memory Trick
textMHNC M → Mutual Exclusion H → Hold and Wait N → No Preemption C → Circular Wait
Q34. How Can Deadlocks Be Handled?#
Deadlock Prevention
Break one of the four conditions.
Deadlock Avoidance
Allocate resources carefully.
Example:
textBanker's Algorithm
Deadlock Detection
Allow deadlocks and detect them later.
Deadlock Recovery
Recover after detection.
Methods:
-
Kill Process
-
Resource Preemption
Q35. What is Banker's Algorithm?#
A deadlock avoidance algorithm.
Principle
Grant resources only if the system remains in a safe state.
Invented By
Edsger Dijkstra
Q36. What is a Safe State?#
A state where all processes can complete execution in some order.
Safe State
textAll processes can finish.
Unsafe State
textDeadlock may occur.
Q37. Deadlock vs Starvation#
| Deadlock | Starvation |
|---|---|
| Processes wait forever | One process waits forever |
| Circular dependency | Scheduling issue |
| No progress | Some processes continue |
| Resource problem | Priority problem |
Q38. What is Starvation?#
A process waits indefinitely because higher-priority processes keep getting resources.
Example
Priority Scheduling
Low-priority process never executes.
Q39. What is Aging?#
A technique used to prevent starvation.
Idea
Increase process priority gradually over time.
Benefit
Eventually every process gets CPU time.
7. Classic Synchronization Problems#
Q40. What is the Producer Consumer Problem?#
A classic synchronization problem.
Producer
Produces data.
Consumer
Consumes data.
Problems
Buffer Overflow
Producer produces too fast.
Buffer Underflow
Consumer consumes too fast.
Solution
Using:
-
Semaphore
-
Mutex
Real World Examples
-
Kafka Consumers
-
RabbitMQ Queues
-
Job Queues
-
Producer-Consumer Systems
[!tip]
Most Asked Interview Questions From This Section:
✓ Critical Section Problem
✓ Race Condition
✓ Peterson's Solution
✓ Semaphore
✓ Binary vs Counting Semaphore
✓ Mutex
✓ Mutex vs Semaphore
✓ Monitor
✓ Spinlock
✓ Deadlock
✓ Four Deadlock Conditions
✓ Banker's Algorithm
✓ Safe State
✓ Starvation
✓ Aging
✓ Producer Consumer Problem
7. Classic Synchronization Problems#
Q41. What is the Readers-Writers Problem?#
A synchronization problem where:
Readers
-
Only read data.
-
Do not modify data.
Writers
- Modify data.
Rules
-
Multiple readers can read simultaneously.
-
Only one writer can write at a time.
-
No reader should read while a writer is writing.
Goal
Maximize concurrency while maintaining consistency.
Real-World Example
Database systems:
textSELECT → Reader INSERT/UPDATE/DELETE → Writer
Q42. What is the Dining Philosophers Problem?#
A classic synchronization and deadlock problem.
Scenario
-
Five philosophers sit around a table.
-
Five forks are placed between them.
-
A philosopher needs both left and right forks to eat.
Problem
All philosophers pick one fork simultaneously.
Result:
textDeadlock
Solutions
-
Resource ordering
-
Semaphore
-
Arbitrator (Waiter)
Interview Tip
Used to explain:
-
Deadlocks
-
Resource Allocation
-
Starvation
8. Memory Management#
Q43. What is Memory Management?#
Memory management is the process of managing RAM efficiently.
Responsibilities
-
Allocation
-
Deallocation
-
Protection
-
Address Translation
Goal
Maximize memory utilization.
Q44. What is Logical Address vs Physical Address?#
Logical Address
Generated by CPU.
Physical Address
Actual address in RAM.
Mapping
Performed by:
textMMU (Memory Management Unit)
Q45. What is Swapping?#
Moving processes between RAM and secondary storage.
Why?
When RAM becomes insufficient.
Steps
-
Process moved to disk.
-
Space freed in RAM.
-
Process loaded back when needed.
Drawback
Disk is slower than RAM.
Q46. What is Contiguous Memory Allocation?#
Each process gets one continuous block of memory.
Advantages
Simple implementation.
Disadvantages
Leads to fragmentation.
Q47. What is Fragmentation?#
Unused memory that cannot be utilized efficiently.
Types
Internal Fragmentation
Unused memory inside allocated block.
Example:
textNeed = 18 KB Allocated = 20 KB Waste = 2 KB
External Fragmentation
Free memory exists but scattered.
Example:
text10 KB Free 20 KB Free 15 KB Free Need = 40 KB Cannot allocate.
Q48. Internal vs External Fragmentation#
| Internal | External |
|---|---|
| Waste inside block | Waste between blocks |
| Fixed allocation | Variable allocation |
| Paging suffers | Segmentation suffers |
Q49. What is Compaction?#
Technique to eliminate external fragmentation.
Idea
Move processes together.
Result
One large free block.
Drawback
Expensive operation.
9. Paging#
Q50. What is Paging?#
Paging is a memory management technique where:
Logical Memory
Divided into:
textPages
Physical Memory
Divided into:
textFrames
Mapping
Page Table maps pages to frames.
Q51. Why is Paging Used?#
Benefits
✔ Eliminates external fragmentation
✔ Better memory utilization
✔ Supports virtual memory
Q52. What is a Page Table?#
A data structure used to map:
textLogical Address → Physical Address
Maintained By
Operating System
Q53. What is Effective Access Time (EAT)?#
Actual time required to access memory considering page faults.
Formula
textEAT = (1-p) × Memory Access Time + p × Page Fault Service Time
Where:
textp = Page Fault Probability
10. Segmentation#
Q54. What is Segmentation?#
Memory divided according to logical units.
Examples:
-
Code
-
Stack
-
Heap
-
Data
Segment Table
Stores information about segments.
Q55. Paging vs Segmentation#
| Paging | Segmentation |
|---|---|
| Fixed-size blocks | Variable-size blocks |
| Pages and Frames | Segments |
| Eliminates external fragmentation | May suffer external fragmentation |
| User invisible | User visible |
Interview Tip
Paging = Physical View
Segmentation = Logical View
11. Virtual Memory#
Q56. What is Virtual Memory?#
A technique that allows execution of processes larger than physical memory.
Idea
Only required pages remain in RAM.
Remaining pages stay on disk.
Advantages
-
Large address space
-
Better multiprogramming
-
Efficient memory usage
Q57. What is Demand Paging?#
Pages are loaded only when required.
Benefits
-
Faster startup
-
Reduced memory usage
Used In
Almost all modern operating systems.
Q58. What is a Page Fault?#
Occurs when a required page is not present in RAM.
Steps
-
Trap to OS.
-
Locate page on disk.
-
Load page into frame.
-
Update page table.
-
Resume execution.
Interview Tip
Page fault is normal.
Too many page faults indicate a problem.
Q59. What is Thrashing?#
System spends more time swapping pages than executing processes.
Symptoms
-
High CPU wait
-
Low throughput
-
Excessive page faults
Causes
-
Insufficient RAM
-
High degree of multiprogramming
Solution
-
Increase RAM
-
Reduce multiprogramming
Q60. What is Locality of Reference?#
Programs tend to access the same memory locations repeatedly.
Types
Temporal Locality
Recently used data likely to be used again.
Example:
cfor(i=0;i<100;i++)
Spatial Locality
Nearby memory locations likely to be accessed.
Example:
carr[0]
arr[1]
arr[2]
Importance
Basis of:
-
Cache Memory
-
Paging
-
Virtual Memory
[!tip]
Most Asked Questions From This Section:
✓ Fragmentation
✓ Internal vs External Fragmentation
✓ Paging
✓ Page Table
✓ Segmentation
✓ Paging vs Segmentation
✓ Virtual Memory
✓ Demand Paging
✓ Page Fault
✓ Thrashing
✓ Locality of Reference
✓ Compaction
✓ Logical vs Physical Address
These questions alone account for nearly 40% of OS interview questions in placements and product-company interviews.
12. Page Replacement Algorithms#
Q61. Why Do We Need Page Replacement?#
When a page fault occurs and no free frame is available, the OS must decide which page to remove.
This decision is made using page replacement algorithms.
Goal
-
Reduce page faults
-
Improve performance
Q62. What is FIFO Page Replacement?#
FIFO (First In First Out) removes the page that entered memory first.
Example
textFrames = 3 1 2 3 4 Remove 1
Advantages
-
Simple
-
Easy to implement
Disadvantages
-
Poor performance
-
Suffers from Belady's Anomaly
Q63. What is LRU (Least Recently Used)?#
Removes the page that has not been used for the longest time.
Idea
Past behavior predicts future behavior.
Example
textPages used recently stay in memory.
Advantages
-
Better than FIFO
-
Widely used
Disadvantages
- Requires tracking page usage
Q64. What is Optimal Page Replacement?#
Removes the page that will not be used for the longest time in the future.
Advantage
Produces minimum page faults.
Disadvantage
Future knowledge is impossible.
Use
Benchmarking other algorithms.
Q65. Compare FIFO, LRU and Optimal#
| Algorithm | Performance | Practical |
|---|---|---|
| FIFO | Worst | Yes |
| LRU | Better | Yes |
| Optimal | Best | No |
Interview Answer
textOptimal > LRU > FIFO
Q66. What is Belady's Anomaly?#
Increasing the number of frames increases page faults.
Occurs In
✔ FIFO
Does NOT Occur In
✔ LRU
✔ Optimal
Interview Favorite
One of the most frequently asked paging questions.
Q67. What is a TLB (Translation Lookaside Buffer)?#
A cache that stores recently used page table entries.
Purpose
Reduce address translation time.
Without TLB
textPage Table Access + Memory Access
With TLB
Often only:
textMemory Access
Interview Tip
TLB is a cache for page tables.
Q68. What is TLB Hit and TLB Miss?#
TLB Hit
Required entry found in TLB.
Fast access.
TLB Miss
Entry not found.
Need page table lookup.
Slower access.
Q69. What is Cache Memory?#
A small, extremely fast memory located near CPU.
Purpose
Store frequently accessed data.
Memory Hierarchy
textRegisters ↓ Cache ↓ RAM ↓ SSD/HDD
Speed
textCache > RAM > Disk
Q70. What is Cache Hit and Cache Miss?#
Cache Hit
Data found in cache.
Fast access.
Cache Miss
Data not found.
Need RAM access.
Slower.
13. File Systems#
Q71. What is a File System?#
A method used by OS to organize and store files.
Responsibilities
-
File Storage
-
Retrieval
-
Access Control
-
Naming
Examples
-
FAT32
-
NTFS
-
ext4
-
APFS
Q72. What is a File?#
A named collection of related information stored on secondary storage.
Examples:
textnotes.txt photo.jpg video.mp4
Q73. What is a Directory?#
A directory is a collection of files and subdirectories.
Purpose
Organize files logically.
Example:
text/Documents /Downloads /Pictures
Q74. Absolute Path vs Relative Path#
Absolute Path
Starts from root.
Example:
text/home/user/docs/file.txt
Relative Path
Starts from current directory.
Example:
textdocs/file.txt
Q75. What is File Allocation?#
Process of allocating disk blocks to files.
Methods
Contiguous Allocation
Blocks stored consecutively.
Linked Allocation
Blocks linked together.
Indexed Allocation
Index block stores pointers.
Q76. Contiguous vs Linked vs Indexed Allocation#
| Method | Access Speed | Fragmentation |
|---|---|---|
| Contiguous | Fastest | High |
| Linked | Slow | Low |
| Indexed | Moderate | Low |
Q77. What is Inode?#
A data structure in Linux storing file metadata.
Contains
-
Owner
-
Permissions
-
Size
-
Block Addresses
Does NOT Store
textFilename
Interview Favorite
"What does inode store?"
Answer:
Everything except filename.
14. Disk Scheduling#
Q78. Why is Disk Scheduling Needed?#
Disk requests arrive simultaneously.
OS decides servicing order.
Goal
Reduce seek time.
Q79. What is Seek Time?#
Time required to move disk head to desired track.
Components of Disk Access
textSeek Time + Rotational Latency + Transfer Time
Q80. What is FCFS Disk Scheduling?#
Requests served in arrival order.
Advantages
Simple
Disadvantages
Poor performance
Large seek time.
Q81. What is SSTF (Shortest Seek Time First)?#
Chooses request nearest to current head position.
Advantages
Better performance
Disadvantages
Starvation possible.
Q82. What is SCAN Algorithm?#
Disk head moves in one direction servicing requests.
Then reverses.
Also Called
textElevator Algorithm
Q83. What is C-SCAN?#
Circular SCAN.
Working
-
Move in one direction.
-
Reach end.
-
Jump back to beginning.
-
Continue.
Advantage
Uniform waiting time.
Q84. SCAN vs C-SCAN#
| SCAN | C-SCAN |
|---|---|
| Moves both directions | Single direction |
| Unequal waiting | More uniform waiting |
| Simpler | Fairer |
[!tip]
Most Asked Questions From This Section:
✓ FIFO
✓ LRU
✓ Optimal
✓ Belady's Anomaly
✓ TLB
✓ Cache Memory
✓ File System
✓ Inode
✓ Contiguous Allocation
✓ Linked Allocation
✓ Indexed Allocation
✓ FCFS Disk Scheduling
✓ SSTF
✓ SCAN
✓ C-SCAN
These are extremely common in placement interviews and OS viva exams.
15. I/O Management#
Q85. What is I/O Management?#
I/O Management is responsible for managing communication between CPU and I/O devices.
Examples
-
Keyboard
-
Mouse
-
Printer
-
Hard Disk
-
Network Card
Responsibilities
-
Device Allocation
-
Buffering
-
Scheduling
-
Interrupt Handling
Q86. What is an Interrupt?#
An interrupt is a signal sent to CPU requesting immediate attention.
Purpose
Instead of continuously checking devices, CPU gets notified when required.
Examples
-
Keyboard Key Press
-
Mouse Click
-
Disk Read Complete
Q87. Types of Interrupts#
Hardware Interrupt
Generated by hardware devices.
Examples:
-
Keyboard
-
Disk
-
Network Card
Software Interrupt
Generated by software.
Examples:
-
System Calls
-
Exceptions
Q88. What Happens When an Interrupt Occurs?#
-
CPU pauses current process.
-
Saves current state.
-
Executes Interrupt Service Routine (ISR).
-
Returns to original process.
Interview Tip
Interrupts improve CPU efficiency.
Q89. What is Polling?#
CPU continuously checks device status.
Example:
cwhile(device_not_ready);
Advantages
Simple implementation.
Disadvantages
Wastes CPU cycles.
Q90. Polling vs Interrupts#
| Polling | Interrupt |
|---|---|
| CPU checks device repeatedly | Device notifies CPU |
| Wastes CPU | Efficient |
| Simpler | Better performance |
| High CPU usage | Low CPU usage |
Interview Favorite
Interrupts are preferred in modern systems.
Q91. What is DMA (Direct Memory Access)?#
DMA allows devices to transfer data directly between device and memory without CPU involvement.
Traditional Transfer
textDevice ↓ CPU ↓ Memory
DMA Transfer
textDevice ↓ Memory
Advantages
-
Faster I/O
-
Reduced CPU overhead
Q92. Why is DMA Faster?#
CPU does not handle every byte transfer.
CPU only:
-
Starts DMA.
-
Continues other work.
-
Receives completion interrupt.
16. System Calls#
Q93. What is a System Call?#
A system call is an interface between user programs and the Operating System.
Purpose
Allows user applications to request kernel services.
Examples:
cread() write() fork() exec() open() close()
Q94. Why Can't User Programs Access Hardware Directly?#
For:
-
Security
-
Stability
-
Resource Protection
Only kernel can directly access hardware.
Q95. User Mode vs Kernel Mode#
| User Mode | Kernel Mode |
|---|---|
| Limited privileges | Full privileges |
| Applications run here | OS runs here |
| Cannot access hardware | Can access hardware |
| Safer | Powerful |
Interview Tip
System calls switch execution from User Mode to Kernel Mode.
Q96. What Happens During a System Call?#
-
User process requests service.
-
Trap generated.
-
CPU enters Kernel Mode.
-
Kernel performs operation.
-
CPU returns to User Mode.
Q97. What is fork()?#
Creates a child process.
cpid = fork();
Returns
Parent:
textChild PID
Child:
text0
Q98. What is exec()?#
Replaces current process image with a new program.
Example
cexec("chrome");
Current program disappears.
New program starts.
Q99. fork() vs exec()#
| fork() | exec() |
|---|---|
| Creates process | Replaces process |
| New PID created | Same PID |
| Copies address space | Loads new program |
Common Linux Pattern
cfork(); exec();
Used by shell commands.
Q100. What is Copy-On-Write (COW)?#
Optimization used with fork().
Without COW
Entire memory copied.
With COW
Memory shared initially.
Copy created only when modification occurs.
Benefits
-
Faster fork()
-
Less memory usage
17. Kernel#
Q101. What is a Kernel?#
Kernel is the core component of the Operating System.
Responsibilities
-
Process Management
-
Memory Management
-
Scheduling
-
Device Management
-
File Management
Q102. Types of Kernel#
Monolithic Kernel
All services run in kernel space.
Examples:
-
Linux
-
UNIX
Microkernel
Only essential services run in kernel space.
Examples:
-
QNX
-
MINIX
Hybrid Kernel
Combination of Monolithic and Microkernel.
Examples:
-
Windows
-
macOS
Q103. Monolithic vs Microkernel#
| Monolithic | Microkernel |
|---|---|
| Faster | More secure |
| Large kernel | Small kernel |
| Less modular | Highly modular |
| Failure may crash system | Better fault isolation |
Interview Favorite
Linux → Monolithic
MINIX → Microkernel
18. Multiprocessing & Advanced Systems#
Q104. What is SMP (Symmetric Multiprocessing)?#
Multiple processors share:
-
Same Memory
-
Same OS
Benefits
-
Parallelism
-
Better Throughput
-
Reliability
Q105. What is Asymmetric Multiprocessing?#
One processor controls the system.
Other processors execute assigned tasks.
Less common today.
Q106. What is a Real-Time Operating System (RTOS)?#
OS designed to meet strict timing deadlines.
Examples
-
Airbag Systems
-
Medical Equipment
-
Aircraft Control Systems
Q107. Hard RTOS vs Soft RTOS#
| Hard RTOS | Soft RTOS |
|---|---|
| Missing deadline unacceptable | Missing deadline acceptable |
| Airbags | Video Streaming |
| Mission Critical | User Experience |
19. Linux & Miscellaneous#
Q108. What is a Daemon Process?#
A background process running continuously.
Examples:
textsshd httpd crond
Linux Hint
Most daemon names end with:
textd
Q109. What Happens During Booting?#
Steps
-
BIOS/UEFI starts.
-
Bootloader loads.
-
Kernel loads.
-
Drivers initialize.
-
Services start.
-
Login screen appears.
Memory Trick
textBIOS → Bootloader → Kernel → Services
Q110. Throughput vs Turnaround Time vs Waiting Time vs Response Time#
Throughput
Processes completed per unit time.
Turnaround Time
textCompletion Time - Arrival Time
Total time spent in system.
Waiting Time
textTurnaround Time - Burst Time
Time spent waiting in ready queue.
Response Time
textFirst Response - Arrival Time
Important for interactive systems.
OS Interview Rapid Fire (Must Memorize)#
Top 25 Questions#
text1. Process vs Program 2. Process vs Thread 3. User Thread vs Kernel Thread 4. PCB 5. Context Switching 6. Zombie Process 7. Orphan Process 8. Race Condition 9. Critical Section 10. Mutex vs Semaphore 11. Deadlock 12. Four Deadlock Conditions 13. Banker's Algorithm 14. Starvation vs Deadlock 15. Aging 16. Paging 17. Segmentation 18. Page Fault 19. Thrashing 20. FIFO vs LRU 21. Belady's Anomaly 22. TLB 23. fork() vs exec() 24. User Mode vs Kernel Mode 25. Monolithic vs Microkernel
1-Day OS Revision Sheet#
textOS = Resource Manager Process = Program in Execution Thread = Smallest Unit of Execution PCB = Stores Process Information Context Switch = Save + Load Process State Zombie = Dead Child, PCB Exists Orphan = Parent Dead, Child Alive Mutex = Lock Semaphore = Counter Deadlock Conditions: 1. Mutual Exclusion 2. Hold and Wait 3. No Preemption 4. Circular Wait Paging = Pages + Frames Segmentation = Logical Division Virtual Memory = Illusion of Large Memory Page Fault = Page Not in RAM Thrashing = Excessive Swapping FIFO → Belady's Anomaly LRU → Most Common TLB = Cache for Page Table fork() = Create Process exec() = Replace Process Kernel = Core of OS Linux = Monolithic Kernel Interrupt = Device Notifies CPU DMA = Device ↔ Memory Direct Transfer RTOS = Deadline-Oriented OS
[!tip]
If you master Q1–Q110, you can comfortably answer around 90–95% of Operating System questions asked in:
✓ Internship Interviews
✓ Service Companies (TCS, Infosys, Wipro, Accenture)
✓ Product Companies (Amazon, Microsoft, Atlassian, Walmart, Adobe)
✓ College Viva
✓ GATE/University Exams
✓ Backend & Systems Interviews