OS_Interview_Notes
OS_Interview_Notes
OPERATING SYSTEMS
Complete Interview-Ready Notes
Core Concepts · Diagrams · Comparison Tables · Quick-Fire Q&A
WHAT'S INSIDE
30 original lectures reorganized into 6 units — Foundations, Processes & Scheduling, Concurrency & Synchronization,
Deadlocks, Memory Management, and Virtual Memory — plus an added Interview Quick-Fire chapter covering the
questions most commonly asked in entry-level OS interviews.
Page 1 of 50
OS Interview Notes
TABLE OF CONTENTS
UNIT 1 Foundations of Operating Systems
UNIT 2 Processes & CPU Scheduling
UNIT 3 Concurrency & Synchronization
UNIT 4 Deadlocks
UNIT 5 Memory Management
UNIT 6 Virtual Memory
UNIT 7 Interview Quick-Fire Q&A (Added)
Page 2 of 50
OS Interview Notes
UNIT 1
Foundations of Operating Systems
Application software performs a specific task for the user. System software operates and controls the computer system
and provides a platform to run application software.
DEFINITION
An operating system is software that manages all the resources of a computer system — both hardware and
software — and provides an environment in which the user can execute programs conveniently and efficiently, by
hiding the underlying complexity of the hardware and acting as a resource manager.
Core Functions of an OS
● Provides access to computer hardware.
● Acts as the interface between the user and the hardware.
● Resource management (a.k.a. Arbitration) — memory, device, file, security, process.
● Hides underlying hardware complexity (a.k.a. Abstraction).
● Facilitates execution of application programs by providing isolation and protection.
The OS sits between the user's applications and the raw hardware
Page 3 of 50
OS Interview Notes
OS Goals
● Maximum CPU utilization
● Less process starvation
● Higher priority job execution
Single-Process OS
Only one process executes at a time from the ready queue. This is the oldest model (e.g., MS-DOS, 1981).
Batch-Processing OS
● User prepares a job (historically via punch cards).
● Job is submitted to the computer operator.
● Operator collects jobs from different users and sorts them into batches with similar needs.
Page 4 of 50
OS Interview Notes
● Batches are submitted to the processor one at a time; all jobs in a batch run together.
● Limitation: priorities can't be set for jobs that arrive later with higher priority.
● Limitation: may lead to starvation — a batch may take a long time to complete.
● Limitation: CPU may idle during I/O operations.
Multiprogramming OS
Increases CPU utilization by keeping multiple jobs (code + data) in memory, so the CPU always has something to execute if
the current job blocks on I/O.
● Single CPU; context switching between processes.
● Switch happens when the current process moves to the wait state.
● Reduces CPU idle time.
Multitasking OS
A logical extension of multiprogramming.
● Single CPU, but able to run more than one task simultaneously (via time-sharing).
● Uses context switching and time-slicing.
● Increases responsiveness; further reduces CPU idle time.
Multi-Processing OS
More than one CPU exists in a single computer.
● Increases reliability — if one CPU fails, others keep working.
● Better throughput.
● Lesser process starvation — work can shift to an idle CPU.
Distributed OS
● Manages many bunches of resources: ≥1 CPUs, ≥1 memory units, ≥1 GPUs, etc.
● Loosely connected, autonomous, interconnected computer nodes.
● A collection of independent, networked, communicating, and physically separate computational nodes.
Page 5 of 50
OS Interview Notes
Real-Time OS (RTOS)
● Guarantees error-free computation within tight time boundaries.
● Examples: air traffic control systems, robotics.
Page 6 of 50
OS Interview Notes
Concept More than 1 process being context-switched. More than 1 thread being context-switched.
Isolation & memory protection exist — OS No isolation — threads of a process share the
Isolation
allocates separate memory to each program. same memory & resources.
Thread Scheduling
Threads are scheduled based on priority. Even though threads run within a process's runtime, the OS still assigns them
processor time slices.
Saves thread state, switches to another thread of Saves process state, switches to another process
What's saved
the same process. by restoring its state.
Page 7 of 50
OS Interview Notes
LEC 4 · COMPONENTS OF AN OS
Spooling Between two jobs of differing speed. Print spooling, mail spooling.
Caching Storing frequently used data for faster access. Memory caching, web caching.
Types of Kernels
Aspect Monolithic Micro Kernel Hybrid Kernel
High — fewer user/kernel mode Slower — overhead from Speed of monolithic + modularity
Performance
overheads. user/kernel mode switching. of micro.
Examples Linux, Unix, MS-DOS L4 Linux, Symbian OS, MINIX macOS, Windows NT/7/10
Page 8 of 50
OS Interview Notes
DEFINITION
A system call is a mechanism through which a user program requests a service from the kernel that it doesn't itself
have permission to perform (e.g., accessing I/O devices or communicating with other programs). System calls are the
only way a process can go from user mode into kernel mode.
Example — mkdir: mkdir is just a wrapper around the actual system call; it interacts with the kernel to ask the file
management module to create a new directory.
Example — process creation flow: User executes a process (user space) → gets a system call → exec system call creates
the process (kernel space) → control returns to user space. The transition from user space to kernel space is done via
software interrupts. System calls are implemented in C.
Layered view: user app down to hardware, crossing the user/kernel boundary via a software interrupt
Process Control end/abort, load/execute, create/terminate process, get/set process attributes, wait for time,
Page 9 of 50
OS Interview Notes
Category Examples
Information Maintenance get/set time or date, get/set system data, get/set process/file/device attributes
CreateProcess(), ExitProcess(),
Process Control fork(), exit(), wait()
WaitForSingleObject()
SetConsoleMode(), ReadConsole(),
Device Management ioctl(), read(), write()
WriteConsole()
CreatePipe(), CreateFileMapping(),
Communication pipe(), shmget(), mmap()
MapViewOfFile()
Page 10 of 50
OS Interview Notes
5. Bootloader loads
2. CPU loads firmware 3. POST — Power-On 4. BIOS/UEFI reads 6. Kernel boots,
1. Power ON (GRUB / Bootmgr /
(BIOS / UEFI) Self Test MBR / EFI partition then User Space
[Link])
5. PC powers on.
6. CPU initializes itself and looks for firmware (BIOS) stored in the BIOS chip — a ROM chip on the motherboard used to
access & set up the system at the most basic level. Modern PCs load UEFI (Unified Extensible Firmware Interface)
instead.
7. CPU runs the BIOS, which tests and initializes system hardware and loads configuration settings. If something is
wrong (e.g., missing RAM), an error is thrown and boot stops. This is the POST (Power-On Self-Test) process. UEFI
can do much more than BIOS — e.g., Intel's Management Engine is a tiny embedded OS enabling remote
management features.
8. BIOS/UEFI hands off responsibility for booting to the OS's bootloader. It looks at the MBR (Master Boot Record) — a
special boot sector at the start of a disk — or an EFI system partition, finds a small program, and runs it.
9. The bootloader is a small program with the large task of booting the rest of the OS — it boots the kernel, then user
space. Windows uses Windows Boot Manager ([Link]), most Linux systems use GRUB, and Macs use [Link].
Page 11 of 50
OS Interview Notes
Data per instruction cycle Processes 4 bytes of data per cycle Processes 8 bytes of data per cycle
Compatibility 32-bit CPU can only run 32-bit OS 64-bit CPU can run both 32-bit and 64-bit OS
Page 12 of 50
OS Interview Notes
Memory hierarchy — fastest & most expensive at top, slowest & cheapest at bottom
Access speed Higher (Registers > Cache > Main Memory) Lower
Page 13 of 50
OS Interview Notes
UNIT 2
Processes & CPU Scheduling
Attributes of a Process
● A process needs a unique identifying feature.
● Process table: all processes are tracked by the OS in a table-like data structure; each entry is a Process Control Block
(PCB).
● PCB: a data structure storing a process's info/attributes — process ID, program counter, state, priority, etc.
Page 14 of 50
OS Interview Notes
Page 15 of 50
OS Interview Notes
Process States
● New: OS is about to pick the program and convert it into a process (process being created).
● Ready: the process is in memory, waiting to be assigned to a processor.
● Running: instructions are being executed; CPU is allocated.
● Waiting: the process is waiting for I/O.
● Terminated: execution finished; PCB entry removed from the process table.
Process Queues
Queue Contains Location Managed by
● Degree of multi-programming: the number of processes in memory at once — controlled by the LTS.
● Dispatcher: the OS module that gives control of the CPU to the process selected by the STS.
Page 16 of 50
OS Interview Notes
Swapping
● Time-sharing systems may have a Medium-Term Scheduler (MTS) that removes processes from memory to reduce
the degree of multi-programming.
● Removed processes can be reintroduced into memory and continue where they left off — this is Swapping. Swap-out
and swap-in are both done by the MTS.
● Needed to improve process mix, or when memory requirements have overcommitted available memory.
Context-Switching
● Switching the CPU to another process requires a state save of the current process and a state restore of a different
one.
● The kernel saves the old process's context in its PCB and loads the saved context of the new process.
● Pure overhead — no useful work happens while switching. Speed depends on memory speed and register count.
Orphan Process
A process whose parent has terminated while it's still running. Orphan processes are adopted by the init process — the
first process of the OS.
Page 17 of 50
OS Interview Notes
Process Scheduling
● The basis of multi-programming OS.
● By switching the CPU among processes, the OS keeps the computer more productive.
● Many processes sit in memory; when one must wait or its time quantum expires, the OS takes the CPU away and
gives it to another — repeating continuously.
Process keeps CPU until it terminates or switches CPU taken away when time quantum expires, or
CPU release
to wait-state. process terminates/waits.
Arrival Time (AT) Time when the process arrives in the ready queue.
Burst Time (BT) Time required by the process for its execution.
Response Time Time between entering ready queue and getting the CPU for the first time.
CONVOY EFFECT
Page 18 of 50
OS Interview Notes
If one process has a much longer burst time, it has a major (negative) effect on the average wait time of the other,
shorter processes — this is the Convoy Effect. Many short-resource-need processes get blocked behind one long-
running process, causing poor resource management.
Page 19 of 50
OS Interview Notes
Priority Scheduling
● Non-preemptive: priority assigned at process creation. SJF is really a special case of priority scheduling, with priority
inversely proportional to burst time.
● Preemptive: the currently running job is preempted if a new job with higher priority arrives.
● Both variants risk indefinite waiting (starvation) for low-priority jobs.
SOLUTION: AGEING
Gradually increase the priority of a process that has waited a long time — e.g., bump priority by 1 every 15 minutes
— to guarantee it eventually runs.
Page 20 of 50
OS Interview Notes
Page 21 of 50
OS Interview Notes
● System process (created by the OS) has highest priority; Interactive/foreground processes need user I/O;
Batch/background processes run silently.
● Scheduling between queues is fixed-priority preemptive — e.g., the foreground queue has absolute priority over the
background queue.
● Problem: lower-level queues are only scheduled after the top-level queue is fully drained — causing starvation for
lower-priority processes, and the Convoy Effect reappears.
Page 22 of 50
OS Interview Notes
Page 23 of 50
OS Interview Notes
UNIT 3
Concurrency & Synchronization
Concurrency is the execution of multiple instruction sequences at the same time — it happens whenever several process
threads run in parallel.
Threads Recap
● A single sequence stream within a process; an independent, light-weight path of execution.
● Used to achieve parallelism by dividing a process's independent tasks.
Benefits of Multi-Threading
● Responsiveness.
● Resource sharing — efficient sharing of resources.
● Economy — cheaper to create and context-switch threads than processes (allocating memory/resources for a whole
new process is costly).
● Utilizes multiprocessor architectures to a greater scale and efficiency.
Page 24 of 50
OS Interview Notes
Process synchronization techniques play a key role in maintaining the consistency of shared data.
Critical Section
The segment of code where processes/threads access shared resources (common variables, files) and perform writes on
them. Since processes/threads execute concurrently, any process can be interrupted mid-execution.
RACE CONDITION
Occurs when two or more threads access shared data and try to change it at the same time. Because the scheduler
can swap between threads at any moment, the order of access is unpredictable — so the result depends on the
scheduling algorithm; both threads are "racing" to access/change the data.
Mutex / Locks
Locks implement mutual exclusion, allowing only one thread/process into the critical section at a time.
Disadvantages of Locks
● Contention — while one thread holds the lock, others busy-wait; if the lock-holder dies, others wait forever.
● Deadlocks.
● Harder debugging.
● Starvation of high-priority threads.
Page 25 of 50
OS Interview Notes
Conditional Variable
● A synchronization primitive that lets a thread wait until a certain condition occurs.
● Works together with a lock. A thread can only enter a wait state after acquiring the lock; entering wait releases the
lock, and it re-acquires the lock immediately once notified and running again.
● Used to avoid busy waiting. There is no contention here.
Semaphores
● A synchronization method — an integer equal to the number of available resources.
● Multiple threads can execute the critical section concurrently (up to the resource count).
● Allows multiple threads to access a finite instance of resources, whereas a mutex allows only one thread to access a
single shared resource at a time.
Page 26 of 50
OS Interview Notes
15. There are 5 philosophers, sitting at a circular table with 5 chairs and a bowl of noodles in the center; the table has 5
single forks (one between each pair of philosophers).
16. Each philosopher spends life in two states: Thinking (no interaction with others) and Eating.
17. To eat, a hungry philosopher tries to pick up the 2 forks adjacent to them (left and right), one at a time.
18. A fork can't be picked up if it's already taken.
19. Once a philosopher has both forks, they eat without releasing them.
Conclusion: semaphores alone are not enough to solve Dining Philosophers — additional enhancement rules are required
for a deadlock-free solution.
Page 27 of 50
OS Interview Notes
Page 28 of 50
OS Interview Notes
UNIT 4
Deadlocks
DEADLOCK (DL)
A process requests a resource (R); if R isn't available, the process waits. Sometimes that waiting process can never
proceed because the resource it needs is busy forever — this is a Deadlock. Two or more processes wait on
resources that will never free up, because those resources are held by processes that are themselves waiting.
Page 29 of 50
OS Interview Notes
Page 30 of 50
OS Interview Notes
Use locks only for non-sharable resources (sharable ones, like read-only files, can be accessed by many).
Mutual Exclusion
Can't fully deny this condition since some resources are intrinsically non-sharable.
Protocol A: a process must request & be allocated all its resources before execution begins. Protocol B: a
Hold & Wait process may request resources only when it holds none — it must release everything before requesting
more.
If a process holding resources requests one that can't be granted immediately, all its current resources
No Preemption are preempted; it restarts only once it can regain both old and new resources (risk: Livelock). Alternative:
check if a wanted resource is held by a waiting process, and preempt it for the requester.
Impose a strict global ordering on resource acquisition (e.g., all processes must lock R1 before R2) —
Circular Wait
whoever locks R1 first also gets R2.
Deadlock Avoidance
The kernel is given advance information on which resources a process will use during its lifetime, so the system can decide
— for each request — whether the process should wait. The decision considers currently available resources, resources
currently allocated to each process, and future requests/releases.
● Safe state: a state where the system can allocate resources to each process (up to its max) in some order and still
avoid deadlock — i.e., a safe sequence exists.
● Unsafe state: the OS can't prevent processes from requesting resources in a way that could deadlock. Not all unsafe
states are deadlocks, but an unsafe state can lead to one.
● Key rule: a resource request is only approved if the resulting state is still safe.
BANKER'S ALGORITHM
When a process requests resources, the system checks whether granting them keeps the system in a safe state. If
yes, resources are allocated; if not, the process must wait until other processes release enough resources. This is the
classic algorithm for deadlock avoidance via safe-state checking.
Deadlock Detection
Resource Instances Detection Method
Wait-for graph — a deadlock exists if and only if there's a cycle in the graph. The
Single instance of each resource type
system maintains this graph and periodically searches for cycles.
Multiple instances per resource type Banker's Algorithm (used here for detection too).
Page 31 of 50
OS Interview Notes
Page 32 of 50
OS Interview Notes
UNIT 5
Memory Management
In a multi-programming environment, we keep multiple processes in main memory (ready queue) to maximize CPU
utilization and system responsiveness. This means we must share and manage main memory across many processes.
User CAN access the logical address of a process User can NEVER access the physical address
User access
directly. directly (only indirectly).
Existence Doesn't exist physically — a.k.a. virtual address. A real location in main memory.
MMU
The runtime mapping from virtual to physical address is done by a hardware device called the Memory Management
Unit (MMU). The user's program generates and 'thinks' in logical addresses, but ultimately needs physical memory to
actually execute.
Page 33 of 50
OS Interview Notes
Page 34 of 50
OS Interview Notes
Fixed Partitioning
Main memory is divided into partitions of equal or different sizes, decided in advance.
Dynamic Partitioning
Partition size isn't declared upfront — it's decided at the time a process is loaded (process size = partition size).
Page 35 of 50
OS Interview Notes
Defragmentation / Compaction
● Dynamic partitioning suffers from external fragmentation.
● Compaction moves all loaded partitions together, making the free space contiguous — a.k.a. defragmentation.
● This lets bigger processes be stored, since free partitions are merged.
● Downside: system efficiency drops during compaction, since all free spaces are being physically relocated.
Free holes are represented in the OS as a free list (a linked-list data structure).
First Fit Allocate the first hole that's big enough. Simple, fast, low time complexity.
Page 36 of 50
OS Interview Notes
The main disadvantage of dynamic partitioning is external fragmentation — removable via compaction, but with
overhead. We need something more dynamic/flexible.
Paging
● A memory-management scheme that permits a process's physical address space to be non-contiguous.
● Avoids external fragmentation and the need for compaction.
● Physical memory is divided into fixed-size Frames; logical memory is divided into equal-size Pages (page size = frame
size).
● Page size is usually determined by processor architecture — traditionally 4,096 bytes, though modern processors
often support multiple page sizes.
Page Table
● A data structure that stores which page maps to which frame, holding each page's base address in physical memory.
● Every CPU-generated logical address splits into a page number (p) and a page offset (d); p indexes into the page
table to find the corresponding physical frame.
● The page table is stored in main memory at process creation, with its base address stored in the process's PCB.
● A Page Table Base Register (PTBR) points to the current page table — changing page tables on a context switch only
requires updating this one register.
Page 37 of 50
OS Interview Notes
● On a lookup, if the TLB already has the mapping (a TLB hit), the frame address returns directly — no need to consult
the full page table in main memory.
● On a TLB miss, the actual page table is consulted, and the resulting mapping is cached into the TLB for next time.
Page 38 of 50
OS Interview Notes
An important aspect of memory management that becomes unavoidable with paging is the separation of the user's view
of memory from the actual physical memory.
SEGMENTATION
A memory management technique that supports the user's view of memory. A logical address space is a collection of
segments based on that user view; each segment has a segment number and offset: <segment-number, offset> = {s,
d}. A process is divided into variable-sized segments based on the user's view (e.g., main function in one segment,
library functions in another).
Paging is closer to the OS's view than the user's — it divides a process into uniform pages regardless of logical function
boundaries, and related parts of one function might land in different pages that aren't loaded together, hurting efficiency.
Segmentation instead groups the same type of function into one segment.
Paging Segmentation
Internal
Yes No
fragmentation
External
No Yes
fragmentation
Page 39 of 50
OS Interview Notes
Modern system architectures often implement both segmentation and paging together, in a hybrid approach.
Page 40 of 50
OS Interview Notes
UNIT 6
Virtual Memory
VIRTUAL MEMORY
A technique that allows execution of processes not completely resident in memory — giving the user the illusion of a
very large main memory, by treating part of secondary storage as main memory (swap-space).
Demand Paging
● A popular method of virtual memory management: pages of a process that are least used get stored in secondary
memory.
● A page is copied into main memory only when demanded — a page fault. Page replacement algorithms decide which
pages get swapped out to make room.
● Uses a Lazy Swapper — never swaps a page into memory unless it will actually be needed. (Technically a Pager, since
it works with individual pages rather than whole processes.)
VALID-INVALID BIT
In the page table, this bit distinguishes pages that are in memory from those on disk. Bit = 1 means the page is legal
and in memory. Bit = 0 means the page is either not in the process's logical address space, or is valid but currently
sits only on disk.
Page table when some pages are not in memory — frame number + valid-invalid bit per entry
Page 41 of 50
OS Interview Notes
Page 42 of 50
OS Interview Notes
26. Check an internal table (in the process's PCB) — was the memory reference valid or invalid?
27. If invalid, the process throws an exception. If valid, the pager begins to swap the page in.
28. Find a free frame from the free-frame list.
29. Schedule a disk operation to read the desired page into that newly allocated frame.
30. Once the disk read completes, update the page table to mark the page as now in memory.
31. Restart the instruction that was interrupted by the trap — the process can now access the page as if it had always
been resident.
Increases the degree of multi-programming. System can become slower — swapping takes time.
User can run large apps with less real physical memory. Thrashing may occur (see below).
Page 43 of 50
OS Interview Notes
A page fault means a process tried to access a page not currently in a frame; the OS must bring it in from swap-space. If all
frames are busy, the OS must replace an existing page — the page replacement algorithm decides which one, aiming to
minimize page faults.
FIFO (First-In-First-Out)
● Replaces the oldest page in memory.
● Easy to implement, but performance isn't always good — the replaced page might be a rarely-used initialization
module (good), or a heavily-used variable initialized early (bad — causes another fault immediately).
BELADY'S ANOMALY
For LRU and Optimal replacement, increasing the number of frames always reduces (or holds steady) the page-fault
count. FIFO can break this rule — in some reference-string cases, adding more frames actually increases the number
of page faults. This strange, counter-intuitive behavior is unique to FIFO among the common algorithms.
Associate a time field with each page-table entry; replace the page with the smallest (oldest)
Counters
time value.
Keep a stack of page numbers; whenever a page is referenced, remove it from its position
Stack and push it to the top. Most-recently-used stays on top, least-recently-used sinks to the
bottom. A doubly linked list is used since entries are removed from the middle.
Page 44 of 50
OS Interview Notes
Variant Rule
Actively used pages should have a large reference count; replace the page with the
Least Frequently Used (LFU)
smallest count.
Argues the page with the smallest count was probably just brought in and hasn't
Most Frequently Used (MFU)
been used yet — so replace the most-referenced page instead.
Neither MFU nor LFU is common in practice — LRU and its approximations dominate real systems.
Page 45 of 50
OS Interview Notes
LEC 30 · THRASHING
THRASHING
If a process doesn't have enough frames to support its pages in active use, it page-faults quickly. It must replace
some page — but since all its pages are actively needed, it replaces one it needs again almost immediately, causing
another fault, and another, and another. This high-paging-activity condition is called Thrashing.
A system is thrashing when it spends more time servicing page faults than actually executing processes.
As degree of multiprogramming increases, CPU utilization rises, peaks, then collapses into thrashing
2. Page-Fault Frequency
● Thrashing correlates with a high page-fault rate — so we directly control the page-fault rate instead.
● Too high a rate means the process needs more frames; too low a rate means it may have too many frames.
● We set upper and lower bounds on the desired page-fault rate: if it exceeds the upper limit, allocate another frame;
if it falls below the lower limit, remove a frame.
● Controlling the page-fault rate this way prevents thrashing.
Page 46 of 50
OS Interview Notes
Q. What is a system call, and why can't user programs directly access hardware?
A. A system call is the only mechanism for a user-mode program to request a privileged service from the kernel (e.g., file
I/O, process creation). Direct hardware access is blocked so the OS can enforce protection, isolation, and fairness across
all running programs — otherwise one buggy or malicious program could corrupt others or the system.
Page 47 of 50
OS Interview Notes
Q. Why is Round Robin considered fair, and what's the tradeoff with time quantum size?
A. Every process gets a guaranteed CPU turn within one 'round', which prevents starvation. But if TQ is too small, context-
switch overhead dominates and throughput drops; if TQ is too large, RR starts behaving like FCFS and responsiveness
suffers.
Q. Can SJF ever be truly implemented in a real OS? Why or why not?
A. Not perfectly — SJF requires knowing each process's exact burst time in advance, which is generally impossible. Real
systems approximate future burst time using exponential averaging of past CPU bursts of that process.
Q. Why does Round Robin have no Convoy Effect but FCFS does?
A. In FCFS, a long process at the front blocks everyone behind it for its entire burst. In RR, no process holds the CPU longer
than one time quantum at a time, so short processes behind a long one still get regular turns.
Page 48 of 50
OS Interview Notes
Q. What is a Race Condition, and how would you detect one in code review?
A. It's when the final outcome of concurrent operations depends on unpredictable thread interleaving. Red flags in
review: shared mutable state accessed by multiple threads without any lock, semaphore, or atomic operation guarding
reads and writes to it.
Q. List the 4 necessary conditions for deadlock, and name one way to break each.
A. Mutual Exclusion (make resources sharable where possible), Hold & Wait (require processes to request all resources
upfront), No Preemption (allow forcible resource preemption), Circular Wait (impose a global resource-ordering protocol).
Page 49 of 50
OS Interview Notes
Q. What's the difference between Internal and External Fragmentation, in one line each?
A. Internal fragmentation: wasted space inside an allocated block because the process is smaller than the block. External
fragmentation: wasted space between allocated blocks — total free memory exists but isn't contiguous.
Q. Why does Virtual Memory let you 'run a program bigger than RAM'?
A. Because only the currently needed pages of a process must be resident in physical memory at any moment — the rest
can sit in swap space on disk and get paged in on demand, so a process's logical address space can exceed physical RAM.
Q. Why can Belady's Anomaly happen in FIFO but not in LRU or Optimal replacement?
A. LRU and Optimal are both 'stack algorithms' — the set of pages held with N frames is always a subset of the pages held
with N+1 frames, so adding frames can never increase faults. FIFO has no such subset guarantee, since replacement order
depends only on arrival time, not on usage patterns — so page-fault count can behave non-monotonically as frames
increase.
Page 50 of 50