Sections A–U follow your Unit II syllabus line by line. Every question is tagged with the
paper that actually asked it in 2023–2025 (OS Akash.pdf) or, where the recent papers are silent, with the
older ETCS-304 paper that did. Answers are sized to the marks printed on the question; all arithmetic comes from
the independently re-solved numbers, not from the book's own totals.
How this page is ordered
A–H is the “memory hardware and allocation” half (organization, hierarchy, strategies, partitions, fragmentation,
addresses, swapping). I–M is translation (paging, page table + TLB, segmentation, segmentation with paging).
N–U is virtual memory (demand paging, page faults, replacement, performance, thrashing, demand segmentation,
overlays). Worked numbers for first/best/worst fit and for every FIFO/LRU/Optimal string live on the
Numericals page — they are not repeated here.
A. Memory Organization
Memory
Unit II · Memory Organization
Define the terms Caching and Buffering.
Recent PYQ — must doEnd Term Jan 2024 · Q.1(d)3 MarksHigh
Asked in: End Term Jan 2024 · Q.1(d) (3 marks) — the printed answer is a
two-column table with the feature rows Definition, Basic, Storage, Location. The coverage matrix also lists this
as Oct-2024 Q.1(d); the paper split in the extraction notes puts caching/buffering in the Jan-2024 Q.1 set, so
that is the attribution used here. Older papers: End Term Apr 2016 asked buffering/caching under device
management (out of Unit II scope).
Show answer
What main memory is
Main memory (RAM) is the only storage area the processor can address and read
directly. It is a large array of bytes, each with its own address, and it is random access —
any location takes about the same time to reach as any other. Everything a running process needs —
its instructions, its data and its stack — must be in main memory, because the CPU fetches operands
and instructions from nowhere else. It is volatile: contents disappear on power-off, which is why
permanent copies live on disk.
The operating system’s memory-related job therefore starts at organization level: it must keep
track of which parts of memory are free, which are in use and by whom, decide how much memory each
process gets, and decide what to move in and out of main memory when it fills up.
Memory organization summary
Property
Main memory
Accessed directly by CPU?
Yes — the CPU can only address registers, cache and main memory
Typical technology
Integrated-circuit RAM (DRAM) modules
Volatility
Volatile — loses contents when power is removed
Holds
Parts of the OS plus the currently active processes (code, data, stacks, page tables)
Problem it creates
It is much smaller and much more expensive per bit than disk, so it must be shared carefully
Caching vs buffering (the required table)
Feature
Buffering
Caching
Definition
A buffer is a block of memory used as a temporary holding area for data that is
being moved between two things that work at different speeds (for example a slow device and a
fast CPU).
A cache is a small, fast memory that holds a copy of data which really lives
elsewhere (main memory or disk) so that repeat accesses are served without going to the slow
original.
Basic (purpose / idea)
Smooths out a speed mismatch and lets the producer and consumer work independently;
it is written once and read once — the data then leaves it.
Exploits re-use: the same data is likely to be needed again soon, so a copy is kept
close to the requester and hit rates decide the speed-up.
Storage
A fixed-size area of main memory (or a register/FIFO inside the device controller). Contents
are transient and there is exactly one copy of each item.
High-speed memory (SRAM inside the CPU for a cache line; a reserved region of RAM for a disk
or page cache). Contents are duplicate copies and must be kept coherent with the original.
Location
Between two components in a data path — at the I/O interface, in the OS buffer pool, in the
device controller.
Between the CPU (or requester) and the slower memory it reads from — closest to the requester
in the memory hierarchy.
Managed by
Device driver / OS I/O subsystem
Hardware (CPU cache) or OS (page/file cache)
Example
Keyboard input queue; the block held while a printer is fed a line
TLB holding recent page→frame translations; frequently used disk blocks kept in RAM
Exam tipFor 3 marks write the four required rows only (Definition, Basic,
Storage, Location) and add one line each of example. One sentence worth of difference: a buffer holds data
that is on its way somewhere; a cache holds a copy of data that already exists elsewhere.
B. Memory Hierarchy
Memory
Unit II · Memory Hierarchy
What is the utility of cache memory in the system?
Asked in: End Term May-June 2017 · Q.1(e) (2.5 marks, cache vs main memory).
No 2023–2025 paper asked memory hierarchy at all — the coverage matrix lists it as
“cover for safety”, so the pyramid and the locality argument below are the insurance policy.
Show answer
The trade-off. No single technology can be fast, big and cheap at once. Speed and
cost per bit track each other: the faster a memory is, the more it costs per bit and the smaller it can
practically be. So a system is built as a hierarchy of levels — each level faster, smaller and
dearer per bit than the one below it — with an automatic movement of data between adjacent levels so
that the program sees one large, fast-looking store.
Draw a triangle and cut it into five horizontal bands.
Label from the apex down: Registers · Cache · Main memory · Disk · Tape.
Put an upward arrow on the left edge: “faster, smaller, costlier per bit”.
Write on the right: “as we go down, access time ↑, size ↑, access frequency ↑, cost per bit ↓”.
Finish with one line: the hierarchy works because of locality — see below.
Why the hierarchy works — locality of reference
A program does not touch memory uniformly. During a short window it keeps returning to the same small
region, so a fast, tiny upper level can serve most references:
Temporal locality — items accessed now are likely to be accessed again soon
(loops, the just-executed instruction stream, a hot stack frame).
Spatial locality — items whose addresses are near each other are likely to be used
near each other in time (sequential instructions, array traversal).
Because of this, moving blocks (cache lines, pages) rather than single words up the
hierarchy gives a hit rate high enough that the average access time sits near the fast level while the
capacity and price sit near the cheap level.
Utility of cache memory specifically: it hides the gap between CPU speed and
main-memory speed. A CPU can finish an instruction in a cycle or two but a RAM access costs many such
cycles; a cache keeps the frequently used instructions and data in SRAM so the CPU rarely waits for RAM.
The same principle one level down justifies the TLB (caching page-table entries) and the disk/page cache.
Verification noteThis is the older-paper treatment of the syllabus
point “Memory Hierarchy”. The recent 2023–2025 papers do ask the caching idea, but as Q.1(d) of Jan-2024
(caching vs buffering) and as the TLB in paging
(Dec-2024 Q.5(c)) — never as a pyramid question. Expect it only as a safety answer.
C. Memory Management Strategies
Memory
Unit II · Memory Management Strategies
Explain memory management strategies.
Older PYQ — syllabus gapEnd Term May 2016 · Q.1(c)2 MarksHigh
Asked in: End Term May 2016 · Q.1(c) (2 marks) · End Term May-June 2018
· Q.2(a) “Discuss the various memory management schemes.” (6.5 marks). In the recent papers the same syllabus
point returns as Mid Term Oct 2025 · Q.3(b) on paging and segmentation
(see card K).
Show answer
Main memory must hold both the operating system and the running user processes, and the OS’s job is
to divide it up in the most efficient way possible. Three questions define any strategy: when are
addresses fixed, must a process sit in one连续 block, and how is free space tracked.
1. Contiguous vs non-contiguous allocation
The memory is normally split into two partitions — one for the resident OS (usually low memory, because
the interrupt vector lives there) and one for user processes. Into that user partition the OS places
processes either contiguously (each process gets one single consecutive run of addresses,
so a 20 KB process occupies 20 KB of adjacent memory) or
non-contiguously (a process’s pieces may be scattered anywhere, and a table puts the
pieces back together — this is paging, and in the pure sense segmentation with paging).
2. Absolute code, relocatable code, load-and-go
Kind of code
When addresses are decided
What the compiler/linker produces
Consequence
Absolute code
Compile time — the programmer must already know the
physical load address
Instructions that already contain real memory addresses
No loader work and no hardware support needed, but the program can only ever run at that fixed
address; to move it you must recompile. Used in the earliest simple batch systems.
Relocatable code
Load time — the final start address is known only
when the loader picks a free hole
Addresses relative to a start of 0, plus a relocation
table/bit-map
The loader adds the load address to every relative reference (“relocates” the
module) before starting it; a program can be loaded anywhere without recompiling.
Load-and-go
Load time, but with no separate loading pass
An absolute machine-language object module produced by the assembler/compiler
The loader simply places the object module in memory and jumps to its start address — one step,
hence “load and go”. Typical of systems where the compiler itself produces absolute code.
Run-time (dynamic) binding
Execution time — every address is
translated by hardware
Logical addresses plus an MMU with a base/relocation register
Maximum flexibility: the process can be moved while it runs, swapping and virtual memory become
possible. This is what modern systems use — see
address-binding times.
3. Partitioning — the strategies built on contiguous allocation
Single contiguous allocation — OS in one part, one user process in the rest;
no multiprogramming (MS-DOS).
Multiple fixed (static) partitioning — memory pre-cut into a fixed number of
holes of fixed sizes; a process gets one whole hole. Degree of multiprogramming is capped by the number
of holes and waste is internal fragmentation.
Multiple variable (dynamic) partitioning — holes are created exactly as processes
arrive and leave; the OS keeps a free list. Waste is external fragmentation, cured by compaction.
Paging / segmentation — non-contiguous allocation; no external fragmentation under
paging at all (see section F).
Two basic memory-management strategies are named in the printed May-2016 answer:
paging, which permits the physical address space of a process to be non-contiguous, and
segmentation, which supports the user’s view of memory as a collection of named, variable-length
segments addressed as (segment name, offset).
Exam tipWrite the three headings (contiguous/non-contiguous · kind of code ·
partitioning) with two lines each. Adding the one-line definition of load-and-go usually fetches the last
mark.
D. Contiguous vs Non-Contiguous Allocation
Memory
Unit II · Contiguous Allocation
Compare contiguous versus non contiguous memory allocation techniques.
Older PYQ — syllabus gapEnd Term May 2016 · Q.2(b)6 MarksHigh
Asked in: End Term May 2016 · Q.2(b) (6 marks) only — the recent papers touch it
implicitly in Mid Term Oct 2025 · Q.3(b) (paging and segmentation) but never as a comparison question.
The printed 2016 answer opens with the relocation-register scheme: CPU logical address → compared against the
limit register → added to the relocation register → physical address → memory.
Show answer
In contiguous allocation each process is contained in a single contiguous section of
memory — consecutive blocks with consecutive addresses. In non-contiguous allocation the
logical memory of a process is cut into pieces (pages, or segments-then-pages) and the pieces may be
placed anywhere free; a per-process table records where each piece went.
Basis
Contiguous allocation
Non-contiguous allocation
Placement of one process
One single adjacent block of memory big enough for the whole process
Pieces scattered anywhere there is free space; the table stitches them back together
Unit of allocation
The whole process (or a fixed/variable partition sized to it)
A page of fixed size (paging) or a segment of variable size, itself often paged
Address translation
Base (relocation) register + limit register — one addition per reference
Page table (page number → frame number) and/or segment table (base + limit) — index a table, then concatenate the offset
Hole / free-space management
OS must maintain a free list, merge adjacent holes, and search for a hole that fits (first / best / worst fit)
Only a simple free-frame list is needed; any free frame will do, so allocation is O(1)-ish
Fragmentation
External fragmentation — enough total free memory but not contiguous; cured by compaction
Paging removes external fragmentation entirely and leaves only bounded internal fragmentation in the last page
Process can move while running?
Only with a relocation register scheme; moving a whole process is expensive
Trivially — move one page/frame at a time; this is what makes swapping and virtual memory practical
Compaction cost
High — copying large amounts of memory
Not required (paging) / reduced (segmentation with paging)
Sharing & protection granularity
Whole process, or a single base/limit pair — coarse
Per frame or per segment flags — fine-grained sharing of a single page/segment between processes
Hardware / memory cost
Cheap: two registers per process
Costly: a page table per process, plus TLB for acceptable speed
Typical example
MS-DOS, single-user systems, fixed-partition systems
UNIX/Linux, Windows — paging or segmentation with paging
The contiguous side, in the words of the printed 2016 answer
“The main memory must accommodate both the operating system and the various user processes. We therefore
need to allocate the parts of the main memory in the most efficient way possible … In this contiguous memory
allocation, each process is contained in a single contiguous section of memory … The relocation-register
scheme provides an effective way to allow the operating system to change dynamically.”
Why it matters for the numericalsContiguous allocation is exactly where
first / best / worst fit live, and that is the one place in Unit II where the recent papers do set a
calculation: Numericals · first / best / worst fit
(partitions 100K, 500K, 200K, 300K, 600K · processes 212K, 417K, 112K, 426K).
E. Partition Management Techniques
Memory
Unit II · Partition Management
Describe the function of operating system software in the following memory management scheme: (i) Multiple variable partition (ii) Buddy System (iii) Simple Paging
Older PYQ — syllabus gapEnd Term June 2019 · Q.3(a)5 MarksHigh
Asked in: End Term June 2019 · Q.3(a) (5 marks) · End Term May-June 2018 · Q.2(a)
“Discuss the various memory management schemes.” (6.5 marks). The 2019 answer spans three book pages and lists
the advantages and disadvantages of variable partitioning including both internal and external fragmentation.
Show answer
Fixed vs variable partitioning
Multiple fixed partitioning: memory is divided once, at system generation time, into a
fixed number of partitions whose sizes are then static. Each partition holds at most one process; a
partition is either fully free or fully busy.
Multiple variable (dynamic) partitioning: there are no pre-set holes. The OS keeps a
list of holes and, when a process of size n arrives, gives it a hole of exactly n (or
n+something) and splits the remainder. When a process exits its space becomes a hole again and
adjacent holes are merged.
Basis
Multiple fixed (static) partitioning
Multiple variable (dynamic) partitioning
Number & size of partitions
Fixed at system generation; cannot change without a reboot
Created and destroyed at run time, sized to the process
Degree of multiprogramming
Hard limit = number of partitions
Variable — limited only by how many holes currently fit
Waste
Internal fragmentation — a 6 MB process in a 10 MB partition wastes 4 MB that nobody can use
External fragmentation — many small holes whose total is large but none individually big enough
OS bookkeeping
One status flag per partition — very simple
A free (hole) list plus an allocation policy plus hole merging — much more work
Allocation policy needed?
Choose a free partition; first-fit over partitions is normal
First fit / best fit / worst fit over the hole list (see next card)
Compaction
Meaningless — partitions are fixed
Available cure for external fragmentation, but expensive
Protection
Base + limit per partition is enough
Base + limit per process, changed on every context switch
Used by
Early multiprogrammed batch systems, some embedded/RTOS kernels
Classic time-sharing systems before paging took over
Buddy system (named in the same question)
Memory is repeatedly halved until a block is large enough to satisfy the request: free blocks are always
powers of two, and splitting a block of size 2^U creates two “buddies” of size
2^(U−1). A request S is satisfied by the smallest power-of-two block with
2^(U−1) < S ≤ 2^U (that inequality is exactly as printed in the 2019 answer). When a block is
freed, its buddy is merged back if it is also free. Cost: because the block is rounded up to a power of two,
the wasted space is internal fragmentation.
Exam tipThree headings, three short paragraphs: variable partitioning → holes and
external fragmentation + compaction; buddy → power-of-two splitting and internal fragmentation; simple
paging → equal-size pages into equal-size frames with a page table, no external fragmentation, and the
printed 2019 paging bullet “Due to equal size of the pages and frames, swapping becomes very easy.”
Unit II · Partition Management
Explain the concepts of the Virtual Memory. Describe First fit, Best fit and Worst fit mechanism for memory allocation.
Recent PYQ — must doEnd Term Dec 2025 · Q.5(a)6 MarksVery high
Asked in: End Term Dec 2025 · Q.5(a) (6 marks) as theory · End Term May-June 2018
· Q.1(g) (5 marks) · End Term Jul 2023 · Q.2(b) (6.5 marks),
End Term May-June 2017 · Q.2(b) (4 marks) and the 2016 paper Q.4 as the same data set worked numerically.
Show answer
All three are hole-selection policies used by variable-partition allocation. The OS holds a
list of free holes; a process of size n must be placed in a hole with size ≥ n, and the
policy decides which such hole to take.
Policy
Rule
Advantages
Disadvantages
First fit
Scan the hole list from the beginning and allocate the first hole that is big enough;
split the remainder and return it to the list.
Simplest and fastest search — usually stops early; least likely to break up the largest hole
needlessly.
Produces fragmentation of the low end of memory: repeated first-fit scans bias allocation
towards the start of the list and leave many small unusable holes (external fragmentation).
Best fit
Search the whole list and allocate the smallest hole that is big enough — the hole
whose size is closest to n.
Wastes the least space on any single allocation, so it keeps large holes intact for future big
requests; in practice the most frugal of the three.
Slowest — a full list search every time; and the leftover slivers are so tiny that they are
almost never usable, so it generates the largest number of small, un-reusable holes.
Worst fit
Search the whole list and allocate the largest hole available, on the theory that the
leftover piece is then still large enough to be useful.
Never leaves a tiny, useless remainder from the biggest hole; suits systems where many small
requests must all be served and small remainders can be re-used.
Also needs a full search; rapidly destroys the large holes that a big process would later need,
so in practice it is the worst of the three at admitting large processes.
Which one is best?
Simulation and the papers’ own data agree: first fit and best fit both beat worst fit,
and best fit makes the most efficient use of memory overall — but no policy removes external fragmentation,
because in all three cases a process needs one hole that is already big enough.
Worked placement for the exam-standard data set (partitions 100K, 500K, 200K, 300K, 600K ·
processes 212K, 417K, 112K, 426K): under first fit 212K → 500K, 417K → 600K, 112K → the 288K remainder, and
426K must wait; under worst fit 212K → 600K, 417K → 500K, 112K → the 388K remainder and
426K again must wait; under best fit all four are placed
(212K → 300K, 417K → 500K, 112K → 200K, 426K → 600K, leaving 83K/88K/174K/88K remainders).
→ Full table on Numericals.
Verification noteThe May-June 2017 printing of this same numerical disagrees with
the 2016 and Jul-2023 printings for identical data: it puts 212K into the 500K partition under best
fit and then claims both 112K and 426K cannot be placed. That answer is arithmetically impossible
(300K is a better fit for 212K than 500K, and 600K is still free). Do not copy it — the
2016 / Jul-2023 version, reproduced above, is the correct one, and “best fit is the only policy that places
all four processes” is the conclusion to write.
F. Internal vs External Fragmentation
Memory
Unit II · Fragmentation
Explain the difference between External fragmentation and Internal fragmentation. Explain Paging and how to solve the fragmentation problem using paging.
Recent PYQ — must doMid Term Oct 2024 · Q.3(a)5 MarksVery high
Asked in (merged): Mid Term Nov 2023 · Q.1(b) “Differentiate between internal and
external fragmentation.” (2 marks) · Mid Term Oct 2024 · Q.3(a) (5 marks — same question plus the paging
follow-up) · Mid Term Oct 2025 · Q.1(e) “Explain internal and external fragmentation in memory.” (2 marks) ·
older papers: First Term Feb 2018 · Q.1(b) (2 marks) and End Term May-June 2018 · Q.2(b) (3 marks).
Three of the six recent papers — highest-frequency theory question in Unit II after page replacement.
Show answer
Internal fragmentation is waste inside an allocated block: the OS gave the
process more memory than it asked for, and the extra sliver is unusable by anyone else because it belongs
to that process. External fragmentation is waste between allocated blocks: free
memory exists in plenty but it is chopped into non-adjacent holes, so no single hole is large enough for
the next process.
Basis
Internal fragmentation
External fragmentation
When it occurs
Whenever the allocated unit is fixed in size and larger than the request
Whenever free memory is repeatedly allocated and freed in variable-sized chunks
Where the waste sits
Inside the space already given to a process (the slack in the last
block/page/partition)
Outside every process — in the gaps between allocated blocks
Is the wasted memory usable by someone else?
No — it is owned by that process
Yes in total, but not in any single hole: 5 KB free in total yet a 6 KB process fails
Schemes that suffer
Fixed partitions, paging, buddy system
Variable/dynamic partitioning, pure segmentation, contiguous allocation in general
Schemes that avoid it
Byte-exact variable allocation (no rounding)
Paging (any frame will do — holes need not be adjacent)
Size of the loss
Bounded: at most one page/partition minus one byte per process
Unbounded in principle: it can grow to the whole free memory
Cure
Choose a smaller page size, or use variable-sized allocation
Compaction, or move to non-contiguous allocation (paging)
Cost of the cure
Smaller pages ⇒ bigger page tables and more address-translation work
Compaction costs a full memory copy of every live process
Numeric example
Page size 4 KB, process 9 KB ⇒ 3 pages = 12 KB allocated,
3 KB wasted inside the last page
10 KB free as 2 KB + 5 KB + 3 KB holes; a 6 KB request is refused
although 10 KB is free
How paging solves external fragmentation
Logical memory is cut into equal-sized pages; physical memory is cut into the same
sized frames. Because page size = frame size, any free frame can hold any
page.
A process of 9 KB with 4 KB pages needs three frames — they may be frames 7, 2 and 11, in
any order. Nothing has to be adjacent, so “no hole big enough” simply cannot happen.
The page table turns the scattered frames back into a contiguous-looking address space at run time.
The cost is that external fragmentation is traded for a small, bounded amount of
internal fragmentation in the last page (the Oct-2024 answer names exactly this trade:
paging → fixed-size blocks → internal fragmentation; segmentation → variable-size blocks → external
fragmentation).
How compaction solves external fragmentation
Compaction shuffles the allocated blocks so that all the free holes merge into one
contiguous block at one end of memory. It works only when relocation is possible at execution time —
i.e. with dynamic relocation via a base/relocation register, because then moving a process just means
changing its base value, not rewriting its code. Total free memory does not change; what changes is that it
becomes one hole instead of ten, so the large waiting process can be admitted. The price is that
it is pure overhead: potentially gigabytes copied while the system is otherwise idle.
Exam tipFor 5 marks: table (6–7 rows) + the 4-step paging argument + a two-line
compaction paragraph. Draw one strip of memory with three holes and label the middle-sized gap
“external fragmentation” — diagrams carry the marks on this question.
G. Logical vs Physical Address Space
Memory
Unit II · Address Spaces
Differentiate between Logical and Physical Address with the help of diagram.
Recent PYQ — must doEnd Term Dec 2025 · Q.1(c)5 MarksVery high
Asked in: End Term Dec 2025 · Q.1(c) (5 marks) · Mid Term Nov 2023 · Q.1(c)
“Explain logical and physical address space in paging.” (2 marks) · older papers: End Term May 2016 · Q.1(d)
(2 marks), End Term Jul 2023 · Q.3(a) (3 marks) and a 2016-section item “Logical addresses vs Physical
addresses.” whose marks are not printed.
Show answer
Every instruction that a CPU executes generates an address. The set of all addresses
the CPU can generate is the logical (virtual) address space; the set of addresses the
memory hardware actually sees is the physical address space. The logical space is
normally 0 … 2m−1 for an m-bit address bus, and it is not the same thing as where the
process really sits in RAM.
Basis
Logical (virtual) address
Physical address
Who sees it
The program / the CPU — the value inside the instruction and the registers
The memory bus and the RAM chips
Generated by
CPU at run time while executing instructions
The MMU, after translation, at the moment the reference leaves the CPU
Space name
Logical / virtual address space
Physical address space
Typical range
Always starts at 0 for each process and may be larger than RAM
Sits somewhere inside real RAM, and can be smaller than, equal to, or larger than the logical space
Compile/load time
Fixed by the compiler and the linker, independent of where the process is loaded
Decided by the loader, and may change again while the process runs (swapping / paging)
Do they match?
Identical only in systems with no hardware translation (absolute code,
MS-DOS style). In every paged or MMU-based system they are different values, and the difference is
invisible to the program.
Protection
Cannot by itself stop a program touching another’s memory
Gated by base + limit registers, so a process can be physically fenced in
The MMU, the relocation register, base and limit registers
MMU (memory-management unit) — the hardware device that performs the run-time
mapping from logical to physical addresses. The Dec-2025 answer prints the whole chain explicitly:
CPU → logical address 150 → MMU adds the base address 1000 → physical address 1150 → main memory.
Relocation register = base register — holds the smallest physical address of this
process. Its value is added to every address the CPU generates. If the base is 14000, an attempt
to address location 0 is relocated to 14000, and location 346 becomes 14346 (the May-2016 printed
example).
Limit register — holds the size of the logical address space of the process. Before
adding the base, the MMU compares the generated address with the limit; if the address is greater than or
equal to the limit it is illegal and the CPU traps to the OS —
this is hardware protection with one register pair per process, which is why a context switch only has
to reload two registers.
Changing the base register lets the OS move a running process in memory without touching its code —
the flexibility that makes swapping and compaction possible.
Show the base register as 1000 and state the addition 150 + 1000 = 1150.
Add one sentence on the limit register giving protection.
Address-binding timesCompile-time, load-time and execution-time binding are
asked as their own older question — see card: role of compiler, loader and MMU.
Unit II · Address Binding
Briefly explain the role of compiler, loader and memory management hardware in the following address binding schemes: (i) Compile time binding (ii) Load time binding (iii) Run time binding.
Asked in: End Term May-June 2018 · Q.1(b) (4.5 marks). No 2023–2025 paper asks
binding times directly, but the Dec-2025 Q.1(c) MMU diagram on the previous card is run-time binding in
pictures — the two answers belong together in revision.
Show answer
Binding = deciding which memory address a logical address refers to. If it happens
before the program starts, addresses are fixed; if it happens during execution, they can still change.
Scheme
When the mapping is fixed
Compiler’s role
Loader’s role
MMU hardware’s role
(i) Compile-time binding
During compilation
Must be told the physical start address in advance; it emits absolute code —
instructions already containing real addresses
Reads the binary and places it byte-for-byte at that same address; nothing to relocate
None — no translation hardware needed
(ii) Load-time binding
When the loader picks a free hole, just before
the first instruction
Emits relocatable code — addresses relative to location 0 plus a relocation
table telling which words need adjusting
Adds the chosen load address to every relative address in the module, then produces an
absolute image in memory (load-and-go = the loader places the object module and
jumps to its start address without a separate relocation pass)
None at run time — translation is finished before execution starts
(iii) Run-time / execution-time binding
Every single memory
reference, while the process runs
Emits logical addresses that never resolve to a physical location at all
Loads the program anywhere; keeps only the logical image plus its base/limit values in the PCB
Essential. The MMU adds the base (relocation) register to each address and
checks it against the limit register — see Fig G-1
Why only run-time binding is used today
A process can be moved in physical memory while it is executing — swap-out/swap-in,
compaction, page-level replacement, all need this.
A program larger than RAM can run at all, since its logical space need never be laid down
contiguously — the basis of virtual memory (section N).
Protection and sharing become per-process register settings instead of per-program recompilation.
Cost: an extra hardware step on every memory reference, which is exactly why the
TLB exists.
H. Swapping
Memory
Unit II · Swapping
Swapping — meaning, the medium-term scheduler, and swap cost
Syllabus only — no direct PYQNot asked in either bookSafety
Show answer
Why this section is hereSwapping is a named line of your Unit II syllabus, yet it
is not asked as a question in either book. The coverage matrix marks it “cover for safety”.
The word does appear inside other answers — the May-2016 thrashing answer speaks of a
“swap-in, swap-out level of intermediate CPU scheduling”, and the June-2019 paging answer says “Due to
equal size of the pages and frames, swapping becomes very easy” — so one paragraph plus the scheduler link
is enough insurance.
Swapping is the movement of an entire process (its code, data and stack) out
of main memory onto a bulk storage area called the swap space (or backing store), and later
back into memory so it can continue exactly where it stopped. It is a whole-process operation, unlike paging,
which moves one page at a time.
Why swap at all
To free memory for other processes when main memory is oversubscribed.
To raise or lower the degree of multiprogramming according to load.
Roll out / roll in: a lower-priority process is rolled out so a higher-priority one can be
rolled in and run immediately — the classic priority-based use of swapping.
The medium-term scheduler’s role
The medium-term (intermediate) scheduler is the piece of the OS that decides swapping. The three
schedulers divide the work as printed in the Oct-2024 Q.1(e) table — long term admits processes to the ready
queue, short term chooses which ready process gets the CPU, and the medium term “swaps processes
in/out of memory”, focusing on memory management. Concretely it:
Watches memory pressure and CPU utilisation.
Selects a victim process — usually one that is blocked or low priority — and issues the swap-out,
saving its PCB state.
Later, when a hole large enough exists, swaps it back in and puts it on the ready queue for the
short-term scheduler.
Thereby controls the degree of multiprogramming; the long-term scheduler does the same job at job
entry, but the medium-term does it dynamically.
Swap cost — the number that makes swapping unpopular
Swap time is dominated by transfer, not by the decision. A standard worked case: a
10,000-word process swapped over a device that moves 1,000 words per millisecond needs
10 ms just for the transfer — plus positioning latency. Since swapping moves the whole
process, a large process is expensive to swap, which is why demand-paged systems swap single pages instead
and reserve whole-process swapping for the medium-term scheduler’s load control.
Swapping (whole process)
Paging (one page)
Moves a process’s complete image; must be contiguous when it comes back
Moves one fixed-size page; any frame will accept it
Decided by the medium-term scheduler
Decided by the page-fault handler + replacement algorithm
Cost ∝ process size
Cost ∝ page size, so it is bounded and predictable
Needs a hole the size of the process ⇒ external fragmentation
No external fragmentation
I. Paging
Translation
Unit II · Paging
Why are page sizes always power of 2? Explain.
Recent PYQ — must doEnd Term Dec 2024 · Q.1(d)5 MarksVery high
Asked in: End Term Dec 2024 · Q.1(d) (5 marks) · End Term Jul 2023 · Q.3(b)
(3 marks) · End Term May-June 2018 · Q.2(c) “Why page size is always a power of 2? In paging schemes, what are
pages, frames and page table?” (3 marks) · End Term May-June 2017 · Q.1(i) (2.5 marks) · End Term Jul 2016 ·
Q.1(a) (marks not printed). Paging itself also returns as Oct 2025 · Q.3(b) (5 marks).
Show answer
Page, frame, page size = frame size
Page — a fixed-size block of the logical memory of a process.
Frame — the same fixed-size block of physical memory, i.e. after RAM is cut
into equal chunks.
The two sizes are deliberately made equal, so that any page fits in any frame and
physical memory never has to be searched for a hole of a particular size. External fragmentation
disappears; the only waste is the slack in the last page (internal fragmentation).
Typical page sizes: 512 B, 1 KB, 4 KB (very common), 8 KB, up to 16 MB huge pages.
Larger pages ⇒ smaller page tables but more internal fragmentation; smaller pages ⇒ the reverse.
Logical memory → pages
Page 0
Page 1
Page 2
Page 3
Cut to the same size
page size = 2m words
frame size = 2m words
page size = frame size
so any page fits any frame
Physical memory → frames
Frame 5
Frame 2
Frame 0
Frame 9
The page table
Each process has a page table: one entry per page, mapping page number → frame number
(plus valid bit and protection bits). The physical memory “hole” problem is converted into a table look-up.
The number of entries in a process’s page table equals its number of pages, so a page table can be very
large — which is the price of paging and the reason for the TLB and for inverted page tables.
Why page sizes are powers of 2 — the real reason
Because then splitting an address into page number and offset needs no
division at all — it is a pure bit-field operation. Write the address in binary and cut it after
m bits, where page size = 2m:
the low m bits are the offset — mask them out with AND;
the remaining high bits are the page number — shift them right by m.
page number = address >> log2(page size) /* shift, not divide */
offset = address & (page size - 1) /* mask, not modulo */
physical = (page_table[page number] << log2(page size)) + offset
example, page size 4096 = 2^12, address 8200:
page number = 8200 >> 12 = 2 offset = 8200 & 4095 = 8
check: 2 × 4096 + 8 = 8200 ✔ (a division-free split — just a shift and a mask)
If the page size were, say, 1,000 bytes, the CPU would have to divide by 1000 to get the page
number and take a remainder for the offset on every single memory reference. A division is many
times slower than an AND and a shift, and it would sit on the critical path of every instruction. Making
the page size 2m turns the boundary between the two fields into a fixed bit position, so the
hardware is a wire split — no arithmetic.
The Dec-2024 printed answer says the same thing in one sentence: “it is most efficient to break the
address into X page bits and Y offset bits rather than perform arithmetic on the address to calculate the
page number and offset. Because each bit position represents a power of 2, splitting an address between
bits results in a page size that is a power of 2.”
Address-translation arithmetic you must be able to do
Quantity
Formula
Notes
Offset bits d
log2(page size)
Same number of bits in logical and physical address
Pages in a process
⌈logical address space ÷ page size⌉
Page-table entries = this number
Page-number bits m
logical address bits − d
Logical address space = 2m+d
Frames in memory
physical memory size ÷ frame size
Frame-number bits = log2(frames)
Physical address bits
log2(frames) + d
Always ≥ logical bits? No — smaller, equal or larger
Internal fragmentation
page size − (process size mod page size) when the remainder ≠ 0, else 0
Only ever in the last page
Advantages of paging as printed in the Oct-2025 answer: eliminates external
fragmentation, allows non-contiguous allocation, simplifies memory management, supports virtual memory.
Problems named in the same answer: internal fragmentation, large page tables, an additional memory access
per reference, page faults.
Unit II · Paging Arithmetic
Consider a logical address space of eight pages of 1024 words each, mapped onto a physical memory of 32 frames. (i) How many bits are there in the logical address? (ii) How many bits are there in physical address?
Recent PYQ — must doEnd Term Dec 2024 · Q.5(b)3 MarksVery high
Asked in: End Term Dec 2024 · Q.5(b) (3 marks) · the same shape of arithmetic as
First Term Feb 2019 · Q.4 (10 marks) and First Term Feb 2018 · Q.4 (10 marks, whose printed answer contains two
arithmetic slips — see the verification note).
Show answer
(i) Logical address — 8 pages × 1024 words each = 8192 words of logical address space.
8 pages × 1024 words = 8192 words = 2^13
⇒ logical address = 13 bits (3 bits page number + 10 bits offset)
(ii) Physical address — 32 frames, each of the same 1024 words (frame size = page size)
= 32768 words of physical memory.
32 frames × 1024 words = 32768 words = 2^15
⇒ physical address = 15 bits (5 bits frame number + 10 bits offset)
The same method on the Feb-2019 data (older paper, 10 marks)
Given: logical address space 4096 bytes, main memory 512 bytes, page size 16 bytes.
Asked
Working
Answer
(a) offset / displacement bits
page size 16 = 24 bytes
4 bits
(b) number of pages
4096 ÷ 16 = 212 ÷ 24
256 pages
(c) internal fragmentation
4096 = 256 × 16 exactly, so the last page is full
0 bytes
(d) entries in the (general) page table
one entry per page = 256
256 entries
(e) entries if the page table is inverted
one entry per frame: 512 ÷ 16 = 29 ÷ 24 = 25
32 entries
physical address width
512 bytes = 29
9 bits
Verification noteBoth parts of the Dec-2024 answer above were re-checked and
match the printed solution (13 and 15 bits). Where the older books differ: the Feb-2019 paper prints no
numeric value at all for internal fragmentation — the correct value is 0, because 4096 is
an exact multiple of 16. And the Feb-2018 printing (logical address space 4050 bytes, main memory 1024
bytes, page size 16 bytes) prints “4050/16 = 253.125 = 28” and “16 − 2 = 8 byte”. Both lines are
wrong. Re-solved: pages needed = ⌈4050 ÷ 16⌉ = 254 (not 253, because the 254th page holds
the leftover bytes), frames = 1024 ÷ 16 = 64, and the last page holds 4050 mod 16 = 2 of
its 16 bytes, so internal fragmentation = 16 − 2 = 14 bytes.
J. Page Table and TLB
Translation
Unit II · TLB
Describe the role of TLB in address translation with the help of a suitable diagram?
Recent PYQ — must doEnd Term Dec 2024 · Q.5(c)3 MarksHigh
Asked in: End Term Dec 2024 · Q.5(c) (3 marks) · End Term May-June 2017 · Q.1(d)
“Describe the role of TLB in address translation.” (2.5 marks) — the numerical side of the same topic is on the
next card.
Show answer
The two-step memory access problem
Under run-time mapping with a page table kept in main memory, one logical reference becomes
two physical accesses:
access the page table (using the page number) to obtain the frame number;
access the actual word in that frame using the physical address.
That roughly halves instruction-execution speed — a 100 ns memory turns into an
effective 200 ns per reference. The fix is to cache the translations, not the data.
TLB — what it is
A Translation Look-aside Buffer is a small, fast, hardware cache — typically
64 to 1024 entries — holding the most recent page-number → frame-number translations. It is
associative: the whole page number is compared with all entries in parallel
(which is why the older papers call these registers “associative registers”). It is per-process, so it is
flushed or tag-guarded on a context switch, and the OS must invalidate entries when it changes a mapping.
Its role, step by step (as printed in the Dec-2024 answer)
CPU generates a logical address; its page-number field is searched in the TLB at the same time
as the offset field is held aside.
TLB hit — the frame number is delivered immediately, combined with the offset, and
only one main-memory access is made.
TLB miss — the memory-resident page table is looked up (first memory access) to get
the frame number, the reference itself is then served (second access), and the freshly found translation
is loaded into the TLB, replacing an older entry.
Because of locality, hit ratios of 80–99% are normal, so the average cost falls back to near one
access per reference.
Fig J-1 · Paging address translation: page number + offset → frame number + offset
How to draw this in exam
Top-left box: Logical address, drawn as two cells “page number | offset”.
Page-number line goes to a TLB box above and to the page table box below.
Page table = column of pairs “page → frame”, one row highlighted.
Right side: two cells “frame number | offset”, arrows joining both sources into it.
Below it, box Physical address, with a note that the offset is copied unchanged.
Write the hit/miss line: 1 access on a hit, 2 accesses on a miss.
Effective access time with and without a TLB
Case
Memory accesses per reference
EAT model (α = TLB hit ratio)
No TLB at all — page table lives in RAM
2 always
EAT = 2 × tmem (with tmem = 100 ns → 200 ns)
TLB present, its search time counted separately
1 on a hit, 2 on a miss
EAT = α(tTLB + tmem) + (1 − α)(tTLB + 2·tmem)
— the form used by the Feb-2019 answer on the next card
TLB searched concurrently with main memory, so its time is free
1 on a hit, 2 on a miss
EAT = α·tmem + (1 − α)·(2·tmem) = (2 − α)·tmem
Exam tipThree marks = 3 sentences + the diagram. Say “small hardware cache of
recent page→frame translations, searched by content in parallel”, give hit and miss paths, and finish with
“because of locality the hit ratio is high, so the average cost is close to one memory access”.
Unit II · TLB Numerical
For a paged system, TLB hit ratio is 0.8. Let the RAM access time 't' be 100ns and the TLB access time 'T' be 50 ns. Calculate effective memory access time (with TLB).
Older PYQ — syllabus gapFirst Term Feb 2019 · Q.3(a)5 MarksHigh
Asked in: First Term Feb 2019 · Q.3(a) (5 marks) · End Term Jul 2016 · Q.2(b)
(associative registers 100 ns / page table 180 ns, find the hit ratio for EAT 125 ns — marks not printed, and
its printed answer is impossible, see the note below).
Show answer
Given: hit ratio α = 0.8, main-memory (RAM) access time t = 100 ns, TLB access
time T = 50 ns.
Model. The TLB is read on every reference, so T appears in both branches.
On a hit, one memory access follows. On a miss, the page table is read from memory and then the
word itself is read — two memory accesses.
Sanity check: 170 ns sits between the 1-access cost (150 ns) and the 2-access cost
(250 ns), and it is much better than the 2 × 100 = 200 ns you would pay with no TLB at all.
Verification note170 ns is both the re-solved value and the value printed
in the Feb-2019 answer, so this one is safe to reproduce. The Jul-2016 companion question is not: its
printed working is EAT = [x(100+180)] + [(1−x)(180+100+180)] ⇒ 125 = 460 − 180x ⇒ x = 1.86, i.e. a
“hit ratio” greater than 1, which cannot exist. With the same model re-solved from the given numbers —
100 ns for a reference satisfied by the associative registers and 180 ns for one that must go
through the main-memory page table — the equation is 125 = 100x + 280(1 − x), which gives
x ≈ 0.861. Write the 170 ns answer here and, if the 2016 data appear, write
≈ 0.861 and note that the book’s 1.86 is impossible.
K. Segmentation
Translation
Unit II · Segmentation
Explain paging and segmentation memory management techniques. Also, discuss the problems associated with paging and segmentation.
Recent PYQ — must doMid Term Oct 2025 · Q.3(b)5 MarksVery high
Asked in: Mid Term Oct 2025 · Q.3(b) (5 marks — the segmentation half is answered
here, the paging half in section I, the comparison in
section L) · End Term Jan 2024 · Q.5(a) (7 marks, segmentation with paging) ·
Mid Term Oct 2024 · Q.1(c) · older: End Term May-June 2018 · Q.3(a).
Show answer
Segmentation is a memory-management scheme that supports the user’s view of
memory. A logical address space is a collection of segments — each a named,
variable-length logical unit: the main program, a procedure, a function, an array, a stack, a
symbol table, a set of parameters. A logical address is a two-tuple
<segment-number, offset>: “which piece”, and “how far into it”.
The segment is not a page in disguise: it has meaning to the programmer and the compiler, it
grows and shrinks at run time, and its length is bounded by the address bits (s bits segment number,
d bits offset ⇒ 2s segments of up to 2d bytes each).
The segment table: base + limit
Each process has a segment table holding two numbers per segment:
Base — the starting physical address where that segment lives in memory;
Limit — the length of the segment (its legal offset range).
Translation of logical address <s, d>: index entry s of the segment
table, perform the limit check d < limit; if it passes, physical address =
base(s) + d. If it fails, the reference is illegal and a segmentation-fault trap is raised —
note that this hardware check is nothing to do with the “segmentation fault” of a badly written C program,
it is the OS refusing an out-of-range address.
Protection and sharing fall out for free
Protection: because segments are logical units, per-segment control bits make sense —
code segment read/execute-only, data segment read/write, stack read/write/expand. Any attempt to write the
code segment or to execute the stack faults.
Sharing: two processes that use the same routine need only store the same base
and limit in their segment tables, so a single physical copy is shared with segment-number
agreement. Sharing a page is possible in paging too, but you cannot share “just the code part” of a page
that also holds data.
Two more references on the same table, to show the check: (0, 431) is legal — 431 < 500 — and maps
to 1000 + 431 = 1431; (2, 1400) is illegal because 1400 ≥ limit(2) = 1000, so the
hardware traps instead of producing an address.
Fig K-1 · Segmentation: logical <s, d> → segment table → base + d
How to draw this in exam
Three columns: Logical address space (stacked variable-height segments), Segment table
(three columns: seg · base · limit), Physical memory (segments placed wherever there is room).
Arrow from the segment number into the table, arrow out of the table labelled “base + offset”.
Write the check “d < limit, else trap” beside the table.
Leave a visible unused gap in the memory column and label it external fragmentation.
Problems associated with segmentation (as printed in the Oct-2025 answer)
Problem
Why it happens
External fragmentation
Segments are variable-sized, so free memory breaks into holes that no single segment can use; compaction is needed.
Complex memory allocation
The OS must search the hole list for a block that fits each segment exactly (first / best / worst fit), unlike paging’s “any frame”.
Compaction overhead
Gathering the holes means copying live memory while the system waits.
Variable segment sizes
Different segments grow at run time (stacks, heaps), so their base and limit must be re-checked and re-loaded, and swapping a whole segment is expensive.
Exam tipFor 5 marks on “problems”: one line per row above, and one line naming the
paging problems too (internal fragmentation, large page tables, the extra memory access per reference, page
faults). The worked (1, 200) → 3200 example is worth writing even when the question asks only for theory.
L. Paging vs Segmentation
Translation
Unit II · Paging vs Segmentation
What is the difference between paging and segmentation?
Recent PYQ — must doMid Term Oct 2024 · Q.1(c)Marks: not clearly visibleVery high
Asked in: Mid Term Oct 2024 · Q.1(c) — the marks digit is not legible on the
question line · End Term May-June 2017 · Q.2(a) “Describe working of paging memory management scheme. Compare
paging with segmentation.” (6.5 marks) · End Term Jun 2019 · Q.3(c) “Why is Paging faster than Segmentation?”
(2.5 marks) · the four rows the Oct-2024 answer prints are Basic/Fragmentation, Address, Size, Table.
Show answer
Basis
Paging
Segmentation
Basic idea / fragmentation produced
Memory divided into fixed block size units (pages into frames) → internal
fragmentation only (slack in the last page)
Memory divided along the program’s own variable-size logical units →
external fragmentation
Address
The CPU splits the user’s single linear address into page number + offset; the user never names
a page
The user (compiler/linker) supplies segment number + offset — the address is
explicitly two-dimensional
Size
Page size is decided by the hardware and is a power of 2; identical for every page
Segment size is specified by the user/programmer and varies with the module —
a stack segment can grow at run time
Table
Page table holds the base address (frame number) of each page
Segment table holds segment number + segment length (base and limit) for
each segment
Visible to the programmer?
No — invisible; pages have no meaning to the program
Yes — a programmer naturally thinks in main routine, functions, arrays, stack
Dimension
One-dimensional address space
Two-dimensional address space
Where placed
Any free frame — no adjacency required, no compaction
Each segment needs one contiguous run of free memory — dynamic allocation, compaction
Offset legality
Offset is always < page size by construction, so no size check is needed
Every reference must be checked against the limit: d < limit, or trap
Protection / sharing
Coarse — flags are per page, so code and data can end up in the same page
Natural — per-segment read/execute/write flags, and identical base+limit entries give shared segments
Programming/OS effort
Entirely the OS’s problem; the program needs no changes
Requires the compiler/linker to produce the segment structure
Speed
Faster in practice — fixed sizes make allocation and replacement simple
Slower — variable sizes force a hole search and compaction (Jun-2019 Q.3(c) asks exactly this)
Virtual memory
Directly supports demand paging (the usual route to VM)
Supports VM too, but pure demand segmentation is impractical — hence segmentation with paging
Examples
Paging only: Cray-1, Convex-1 — and any modern x86/ARM kernel running a flat, paged address space
Pure segmentation: Intel 8086 segment registers, iAPX 432. Both together (segmentation with paging): IBM 370/380, DEC VAX, AT&T UNIX System III, SPARC — see section M
The four rows the Oct-2024 answer prints, in its own order
Address — CPU splits the user address into page number + offset vs the user supplying
segment number + offset.
Size — hardware decides the page size vs the user specifies the segment size.
Table — page table holds the base address of each page vs segment table holds segment
number and segment length.
Which one is better, and why — the Dec-2025 Q.4(a) answer
For modern operating systems, paging is generally considered better because:
It eliminates external fragmentation.
Memory allocation is simpler.
It works efficiently with virtual memory.
It is easier for the operating system to manage.
The same answer then adds the honest counterpoint, which is worth one line for full marks:
however, segmentation is better for representing the logical structure of programs
(code segment, data segment, stack segment) and provides more natural protection and sharing
mechanisms — which is why real systems end up using segmentation with
paging rather than choosing between them.
Exam tipWrite the table first — it is the whole answer. Then one summary line:
“Paging is an artifact of the hardware designed to fit memory; segmentation is an artifact of the user’s
view of memory designed to fit the program.” If asked “why is paging faster than segmentation?”
(Jun-2019 Q.3(c), 2.5 marks), the three points are: fixed-size frames need no hole search, no compaction is
ever required, and the offset needs no limit check because it is bounded by the page size by construction.
M. Segmentation with Paging
Translation
Unit II · Segmentation with Paging
Explain with a neat diagram the concept of segmentation with paging in virtual memory. What problem does it solve?
Recent PYQ — must doEnd Term Jan 2024 · Q.5(a)7 MarksVery high
Asked in: End Term Jan 2024 · Q.5(a) (7 marks) · End Term May 2016 · Q.2(c)
“Explain the address generation in segmentation with paging.” (4 marks) · First Term Feb 2018 · Q.3(a)
“Why are segmentation and paging sometimes combined into one scheme? Explain with suitable diagram.” (5 marks) ·
End Term Jun 2019 · Q.2(b) (4 marks, the bit-field numerical solved inside this card).
Show answer
The problem it solves. Pure segmentation gives the user what they want — named,
variable-length, separately protected and shareable logical units — but it inherits every ill of contiguous
allocation: each segment must land in one contiguous run of free memory, so external fragmentation
and compaction come back. Pure paging fixes placement (any frame will do) but destroys the user’s view: a
page is a meaningless fixed-size slice that can straddle the end of one routine and the start of the next,
so per-module protection and sharing get blunt.
The two-level scheme keeps both benefits. The address space is still divided into
segments, but each segment is now paged into fixed-size pages, and those pages are allocated into
any free frames. Segmentation supplies the programming-in-the-large structure; paging supplies the
allocation mechanism underneath it.
In the words of the printed May-2016 answer“Segments can be of different lengths,
so it is harder to find a place for a segment in memory than a page … it is possible to combine segmentation
and paging into a two-level virtual memory system. Each segment descriptor points to a page table for
that segment. This gives some of the advantages of paging (easy placement) with some of the
advantages of segments (logical division of the program).”
Address generation, step by step
The CPU produces a logical address of the form
<segment-number s, page-number p, offset d>.
Entry s of the segment table is fetched. It holds a segment-table entry
(STE): a base that now points at the page table for that segment, plus the
segment limit and protection bits.
Entry p of that segment’s page table is fetched. It holds a page-table entry
(PTE): the frame number (plus a valid bit — the page may be out on disk).
The physical address is formed by concatenating the frame number with the offset:
frame × frame size + d.
Top box: the logical address split into three fields — segment | page | offset.
Left column: segment table whose entries are labelled “STE 0 … STE n → page table for that segment”.
Draw two page tables hanging off the segment table (this is the “two-level” the
examiner looks for) and arrow the chosen STE into its page table.
One PTE carries a frame number; arrow it into a physical-memory column of frames.
Show two frames holding pages of different segments — “frame 1 = page 2 of segment 4”,
“frame 3 = page 0 of segment 0” — that is the whole point of the scheme.
What it buys, and what it costs
Buys
Costs
No external fragmentation — the allocation unit is now a page, and any frame will do
Two-level look-up: segment-table entry plus page-table entry before the data itself
Segments keep their names, their own growth and their own protection/sharing bits
One page table per segment — more memory for tables, especially for tiny segments
A segment can be partially resident: some of its pages in, some on disk
A TLB is effectively mandatory, otherwise the average access becomes three memory references
Only bounded internal fragmentation, in the last page of each segment
More complex OS and hardware than plain paging
Worked bit-field numerical (Jun-2019 Q.2(b), 4 marks)
Given: a system using paging and segmentation with a virtual address space of up to
8 segments, each segment up to 229 bytes long, the hardware
paging each segment into 256-byte pages.
Field asked
Working
Bits
(i) Segment number
8 segments = 23
3 bits
(ii) Page number
pages per segment = 229 ÷ 28 = 221
21 bits
(iii) Offset within page
page size 256 = 28 bytes
8 bits
(iv) Entire virtual address
3 + 21 + 8
32 bits
More page/frame arithmetic (Feb-2019 Q.4, Feb-2018 Q.4, Jun-2019 Q.2(b) variants) is worked
on Numericals.
N. Virtual Memory
Virtual memory
Unit II · Virtual Memory
Write two advantages of virtual memory concept.
Recent PYQ — must doEnd Term Jan 2024 · Q.1(c)3 MarksVery high
Asked in: End Term Jan 2024 · Q.1(c) (3 marks) · Mid Term Oct 2024 · Q.1(c)
(paging/segmentation under virtual memory) · End Term Dec 2025 · Q.5(a) · First Term Feb 2019 · Q.2(b)
“What is Virtual memory and how Overlay concept works, explain in short with example.” (4 marks), whose second
half is answered in section U.
Show answer
Definition. Virtual memory is a memory-management technique that lets a system run a
process even when not all of that process is in main memory. It does this by separating the
logical address space — the program’s own view, which may be enormous — from
physical memory, which is limited, and by bringing pages in from the backing store only
when they are actually referenced (demand paging). The programmer sees
a contiguous address space of 2m words; the hardware only ever holds the active subset.
The two advantages asked for (3 marks)
A program bigger than physical memory can run, and more programs fit at once. Only the
pages currently needed occupy RAM, so the sum of the logical address spaces of all processes may greatly
exceed the size of main memory. Memory that would otherwise sit idle holding not-yet-used parts of a
program is released for other work, which raises the degree of multiprogramming and therefore CPU
utilisation and throughput.
Faster start-up and cheaper, simpler programming. Loading a program no longer waits
for its whole image to be read from disk — execution can begin as soon as the first page(s) are present,
so response and load times drop, and the I/O per job falls too. Programs may also be written against a
large, uniform, private address space, with code, data and stack segments protected and shared through
the MMU, instead of the programmer having to fit inside the RAM that happens to be free.
Verification noteThe Jan-2024 printed answer is very thin and its wording is
garbled in the scan — it reads roughly “allows too fast and easy processes” and “not need more memory
space”. The two advantages above are the same two ideas (speed/ease of execution and not needing the whole
program in memory) stated completely and correctly; the extraction notes flag this answer as “rewrite
clearly”, so the book’s phrasing should not be copied into your paper.
Separation of logical from physical — the mechanism in one paragraph
Compile/link produces a logical address space that starts at 0 and is as large as the
address width allows.
Run-time mapping by the MMU (Fig G-1) turns each reference into a physical
one; with paging the mapping is per page, so a process’s physical footprint can be a scattered, partial
subset of RAM.
A page not present in RAM is not an error — it is a page fault, and the OS brings it in
(section P). That trap-and-fetch behaviour is precisely what makes the
logical space bigger than physical memory without the program noticing.
Consequence for the OS: memory management becomes a policy problem — which pages to bring in
(fetch policy: demand or prepaging) and which to throw out (placement policy: where in memory;
replacement policy: which page).
Exam tip3 marks = one-line definition + two headed advantages + one closing line
(“the logical address space is therefore decoupled from the size of RAM”). Do not spend time on overlays
here — that is a separate 4-mark older question.
O. Demand Paging
Virtual memory
Unit II · Demand Paging
Explain what is Demand Paging? Differentiate between Paging and Segmentation and explain which one is better and why?
Recent PYQ — must doEnd Term Dec 2025 · Q.4(a)4 MarksVery high
Asked in: End Term Dec 2025 · Q.4(a) (4 marks). The second half of this
question is the paging-vs-segmentation table already answered at
Paging vs Segmentation; the book itself sends you there with
“Refer Q.1(c) from Mid Term Exam Oct. 2024 (Pg. 1-2024)”. Older papers touch demand paging only inside
numericals: End Term Jun 2019 · Q.3(b) says “Assuming demand paging with three frames, how many page
faults would occur …” (5 marks).
Show answer
Why this is on the Unit II memory pageThe book files the Dec-2025 demand-paging
question under UNIT-III, but demand paging is explicitly a named line of your Unit II syllabus
(“Virtual Memory: Demand Paging, Page Replacement, …”), and the coverage matrix lists it under Unit II.
It is answered here, immediately before page faults and page replacement, which is where it belongs in the
revision order.
Definition as printed in the Dec-2025 answer
Demand paging is a virtual memory technique in which a page is loaded into main
memory only when it is required by a process. Instead of loading the entire program into
memory at once, pages are brought into RAM on demand.
Working of demand paging (the five steps to write)
A process starts execution.
If the required page is already in memory, execution continues.
If the page is not in memory, a page fault occurs.
The operating system loads the required page from secondary storage (disk) into a free frame in RAM.
The page table is updated and execution resumes.
Demand paging is a lazy form of paging: a process is not loaded page by page in
advance. Only the pages actually needed at this moment are brought into memory, and a page is fetched only
when it is referenced — on demand. The loader never reads the disk blocks of a page that is not yet needed,
so a job can start executing with only its first page (or even nothing) resident. Because it swaps pages
rather than whole processes, demand paging is also called lazy swapping.
The valid / invalid bit
Every page-table entry carries one extra bit: v (valid) or i (invalid).
valid — this page is currently in memory; the frame number in that entry is real and
usable.
invalid — this page is not in memory right now (it was never brought in, or
it was swapped out). Any reference to it must not use that entry’s frame number.
At the very start of a demand-paged process all entries are marked invalid, which is exactly
the trick that allows a program to be “loaded” with zero page reads.
An attempted reference to an invalid page generates a trap to the operating system —
this is the page fault handled in section P. The OS finds a free
frame, reads the page from the backing store, changes the entry to valid with that frame number, and
restarts the instruction.
Once every page of a process is valid, the process’s memory can no longer grow by faulting — that
boundary is what limits a purely paged, non-virtual system.
Pure paging vs demand paging
Basis
Pure paging (load the whole process)
Demand paging
What is brought in at start
Every page of the process, whether it is used or not
Only the page(s) needed now; the rest stay on the backing store and are marked invalid
Startup I/O
Proportional to the full process size — many page reads before the first instruction
Almost none — execution can begin immediately, hence “faster response”
Memory used per process
The process’s complete logical size
Only its active subset (its working set), so it is much smaller
Degree of multiprogramming
Limited by total process sizes
Higher — more processes fit, because each occupies less RAM at any instant
Page faults
None during execution (all pages already valid)
Inherent — every first reference to a page costs one fault, so the fault rate must be kept low
Wasted work
Pages that are never referenced (error handlers, rare branches) still occupy memory
Nothing is loaded that is never used — but the loading cost is paid later, inside execution
Hardware needed
Page table + MMU
Page table with a valid/invalid bit + MMU + a way to trap on an invalid reference + replacement policy
Address space vs RAM
Sum of all processes must fit in RAM
Logical address space may exceed RAM — this is virtual memory
Uses of code
Prepaging: the OS guesses and pre-loads pages (pure paging is prepaging with all pages)
A typical process references a small fraction of its pages most of the time (loops, hot functions, the
active part of the stack). Because of that locality of reference, a modest number of frames can
serve a huge address space with a low fault rate. If the fault rate p is small, the cost of
virtual memory is nearly invisible; if p grows, the system collapses into
thrashing — see the EAT formula in section R.
Exam tipFor 4 marks: definition (2 lines) → valid/invalid bit as its own headed
paragraph with the trap sentence → a 6–8 row comparison table → one closing line on locality. Drawing the
two-state entry (valid with a frame number / invalid pointing at a disk address) is a cheap extra.
P. Page Fault and Page-Fault Handling
Virtual memory
Unit II · Page Fault
What do you mean by a page fault? What actions are taken by the operating system when a page fault occurs?
Asked in: End Term May-June 2017 · Q.3(b) (3.5 marks) — the printed answer gives a
numbered 19-step handling sequence, condensed into the flowchart below · End Term Jun 2019 · Q.1(d) “What is
hard page fault and soft page fault?” (2.5 marks). Demand-paging numericals that depend on this mechanism are on
Numericals.
Show answer
Page fault — in a demand-paged system, an attempted reference to a page whose
page-table entry is marked invalid, i.e. the page is not currently in a physical frame. The
hardware traps to the operating system, which brings the page in from the backing store and then lets the
same instruction run again. A page fault is not an error; it is the normal working mechanism of
virtual memory.
Handling sequence (write these steps in this order)
The CPU generates a logical address and the MMU consults the page table.
The valid/invalid bit for that page is checked. If valid → nothing unusual happens;
the memory reference is completed normally and execution continues.
If invalid → the hardware raises a trap to the OS: the page-fault trap
handler takes over and saves the process state.
The handler examines the trap to confirm it really is a page fault (not an illegal address and not an
I/O trap), and identifies which page is needed.
The handler checks the page is a legal one for this process (in its address space and within its
limits). An illegal reference means the process is terminated; a legal one continues below.
A free frame is taken from the free-frame list. If there is no free frame, the page
replacement algorithm picks a victim page.
If that victim has been modified (its dirty bit is set) it is first written back to
the backing store — one extra swap-out; if it is clean it can simply be overwritten.
The needed page is scheduled for a disk read into the chosen frame; the faulting
process is blocked and the CPU scheduler switches to another ready process (this idle time is what paging
hardware exists to exploit).
On completion of the I/O the frame is filled; if the frame is shared, the OS copies the new page into
each private copy.
The page-table entry (and usually the TLB) is updated: frame number written in and the
valid bit set.
The faulting instruction is restarted exactly where it left off — the program never
learns that a fault happened, and this time the reference hits memory.
Fig P-1 · Page-fault handling flowchart
How to draw this in exam
Start with a box Memory reference, then a diamond Page in memory?.
YES goes right to “normal access”; NO goes down into the OS column.
Below the diamond draw the four OS boxes in a row: find free frame / evict → swap out if modified →
disk read → update page table.
End with Restart the instruction and an arrow back to the top of the diagram.
Label the whole path “trap” on the NO branch — that word carries marks.
Hard vs soft page fault (Jun-2019 Q.1(d), 2.5 marks)
Type
Meaning
What the OS does
Hard page fault (major)
The page is genuinely not in memory — it has to be read in from the backing store / disk.
The whole sequence above, including the disk I/O; costs milliseconds.
Soft page fault (minor)
The page is already somewhere in physical memory (it is in the page cache, or is shared
and already resident) but this process’s page-table entry does not yet point at it.
No disk read — the OS just maps the existing frame and marks the entry valid; costs microseconds.
Verification noteThe May-June 2017 printing expands this answer into 19 numbered
micro-steps (state save, trap-table inspection, legal-address test, free-frame list, disk read, shared-page
copying, table update, restart). The eleven steps written above carry the same content in the order the
examiner can tick; if you can recall the 19-step form, write it — but never omit restart the
instruction, which is the step students most often forget and which is printed explicitly in the
source answer.
Q. Page Replacement
Virtual memory
Unit II · Page Replacement
Explain any two page replacements algorithms. Give an illustration.
Recent PYQ — must doAsked numerically in EVERY recent paperVery high
Asked in: Mid Term Nov 2023 · Q.2(a) (marks not clearly visible) · End Term Jan 2024
· Q.5(b) (8) · Mid Term Oct 2024 · Q.2(b) (5) · End Term Dec 2024 · Q.5(a) (6.5) · Mid Term Oct 2025 · Q.4(b) (5) ·
End Term Dec 2025 · Q.4(b). The wording above is printed verbatim in End Term May 2016 · Q.3(a) (5 marks), where
FIFO and LRU were illustrated. The frame-by-frame tables are solved on
Numericals — this card is the theory only.
Show answer
Why page replacement is needed
A process is given fewer frames than it has pages, and the total demand of all processes exceeds
physical memory. So when a page fault occurs and the free-frame list is empty, the OS
cannot simply read the page in — it must first choose a page that is already resident and evict
it. If the victim is clean it can be discarded and its frame reused; if it is dirty (modified
bit set) it must be written back to backing store first, so a fault costs two memory transfers instead of
one. The rule for picking the victim is the page-replacement algorithm.
The reference-string model
A process’s page accesses are abstracted into a string of page numbers — e.g.
7, 0, 1, 2, 0, 3, 0, 4, … Each number is a reference to that page.
The process is given n frames, all empty to start with (an empty frame is always used first,
and that still counts as a fault).
Walk the string left to right: a reference to a page already in a frame is a hit;
otherwise it is a page fault and, when there is no free frame, the algorithm names the
victim.
The score of an algorithm is the total number of page faults it produces on the
string — fewer faults means a lower effective access time.
The model assumes all frames are empty at the start, references the same string for every algorithm so
the comparison is fair, and ignores the cost of a modified victim (which in reality makes FIFO look worse
than it scores here).
FIFO — First-In, First-Out
Replace the page that has been in memory longest. Keep the resident pages in load order and
evict the head; conceptually it needs one register per page holding its load time, or a queue.
Merits: trivially easy to understand and to implement — a queue or a clock-hand variant is
enough; no per-reference updates, so no extra hardware cost.
Demerits: age is a poor guide to future use — an old page inside a hot loop gets thrown out
and faults straight back; and it suffers Belady’s anomaly (more frames, more faults).
LRU — Least Recently Used
Replace the page that has gone longest without being referenced. It is the reverse of FIFO in
one important respect: it uses the past usage order as a prediction of future use, which is
justified by locality of reference — a page not touched for a long time is unlikely to be touched soon.
Merits: usually far fewer faults than FIFO on real strings; it never suffers Belady’s
anomaly, because it is a stack algorithm — the set of pages LRU would hold in
n − 1 frames is always a subset of the set it holds in n frames, so adding frames can
never increase faults. Implemented by counters (load the smallest counter on a fault), a stack (move the
referenced page to the top), or the clock/second-chance approximation used by real OSs.
Demerits: expensive in pure hardware — every memory reference must reorder the structure, so
it needs special registers or frequent timer updates; OSs therefore approximate it.
Optimal (MIN / Belady’s algorithm) — replace the page used farthest in the future
Look forward along the reference string and evict the page that will not be needed for the
longest time (a page never used again is the perfect victim).
Merits: provably the fewest faults of any algorithm for the same number of frames and the same
string, so it is the benchmark the others are measured against. It also never suffers Belady’s anomaly.
Demerits: requires future knowledge of the reference string, so it is not
implementable in a real OS (only approximable, e.g. by a working-set model).
The ordering rule to remember
On every string re-solved from these papers (3 or 4 frames, all empty)
Result
Faults by Optimal vs LRU vs FIFO
Optimal ≤ LRU ≤ FIFO — Optimal is never
worse than any other algorithm, and LRU is never worse than FIFO on these data
FIFO 9 · LRU 10 · Optimal 7 — this is the one string where
LRU loses to FIFO; Optimal is still the minimum
Dec-2025 Q.4(b), 4 frames (A–G)
FIFO 13 · LRU 10 · Optimal 8
Jan-2024 Q.5(b), 4 frames
FIFO 10 · LRU 8 = Optimal 8 — so the answer to
“which gives the minimum” is both LRU and Optimal, not Optimal alone
So the safe wording is: “Optimal is always ≤ the others; LRU is normally better than FIFO
but not guaranteed — check the string.” The full traces and Gantt-style frame grids are on
Numericals · page replacement.
Verification noteTwo printed totals in the recent papers disagree with the
re-solved traces and must not be copied: Oct-2024 Q.2(b) prints FIFO = 12 although its own step
table lists 13 “Yes” rows (faults land on references 1, 2, 3, 6, 7, 9, 10, 12, 13, 15, 16, 17, 18 =
13), and Jan-2024 Q.5(b) prints a single trace totalling 16 faults although three
algorithms are asked — re-solved with 4 frames the answers are FIFO 10, LRU 8, Optimal 8. Every number in
the table above is the independently re-solved one.
Unit II · Belady’s Anomaly
What is Belady's Anomaly? Explain with the help of suitable examples.
Older PYQ — syllabus gapEnd Term Jul 2016 · Q.2(c)Marks: not clearly visibleMedium
Asked in: End Term Jul 2016 · Q.2(c) (marks not printed on the question line) ·
First Term Feb 2017 · Q.1(d) “What is Belady’s Anomaly.” (2.5 marks). Not asked in any 2023–2025 paper as a
theory question, though the re-solved FIFO numbers in those papers show it in action.
Show answer
Definition.Belady’s anomaly is the counter-intuitive property of some
page-replacement algorithms — FIFO is the classic case — whereby increasing the number of page frames
can increase the number of page faults. It is named after László Bélády, who demonstrated it in 1969.
It should be impossible: more memory ought to mean fewer misses. Its existence proves that FIFO is not a
stack algorithm.
The worked demonstration (the example printed in the Jul-2016 answer)
Loads 3, 2, 1; then 0 pushes out 3; 3 pushes out 2; 2 pushes out
1; 4 evicts 3; … by the end the resident set keeps missing the pages that were evicted in rotation.
9 faults
4 frames
The extra frame changes the eviction order. Every page now
circulates one step later, so the queue positions shift and references that used to hit now miss.
10 faults — MORE, with MORE memory
Why it happens: FIFO evicts by age of loading, and a page’s load order is not related to its
future use. Adding a frame therefore does not simply “keep one more page” — it re-orders the whole eviction
sequence, and the new sequence can evict a page an instant before it is referenced. With LRU this cannot
happen: if a page would be kept in n − 1 frames by recency, it is certainly kept in n
frames, so the resident set for n − 1 frames is a subset of that for n frames
(the stack property) and faults can only fall or stay equal. Optimal has the same guarantee.
Algorithm
Suffers Belady’s anomaly?
Reason
FIFO
Yes
Eviction ignores usage history — not a stack algorithm
LRU
No
Stack algorithm — smaller frame set’s pages are a subset of the larger one’s
Optimal
No
Also a stack algorithm (decisions depend only on future-use distances)
MFU / NRU / Clock
Clock & NRU: not guaranteed; MFU generally behaves like LRU’s opposite
Approximations inherit some of FIFO’s unpredictability
Verification noteThe Jul-2016 printing shows the two frame tables but its
conclusion sentence is garbled as it stands: “In the first example (with fewer pages), there are
9 page faults, there are 10 page faults.” The intended meaning — and the re-checked result
for the string above — is 9 faults with 3 frames and 10 faults with 4 frames, which is
exactly the anomaly. Quote the two numbers as a pair and never as a single total. (A second, longer
demonstration string appears in the recent papers: 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0,
1 with 4 frames gives FIFO 10 vs LRU 8 and Optimal 8 — the same lesson, solved frame by frame on
Numericals.)
R. Performance of Demand Paging
Virtual memory
Unit II · Performance
If the average page fault service time of 25 ms and a memory access time of 100ns. Calculate the effective access time.
Older PYQ — syllabus gapEnd Term June 2019 · Q.1(h)2.5 MarksHigh
Asked in: End Term June 2019 · Q.1(h) (2.5 marks) · End Term Jul 2016 · Q.2(b)
(associative registers 100 ns, page table 180 ns, EAT target 125 ns → find the hit ratio; marks not printed) ·
First Term Feb 2019 · Q.3(a) TLB EAT, answered in section J. The recent papers reach
the same topic through Dec-2024 Q.5(c) (TLB).
Show answer
Factor 1 — page-table size
A page table is another table in memory, and one entry is needed for every page of every
process, so the table is large and must itself be stored in main memory. Its size is fixed by the number of
address bits:
With a 16-bit address and a 1 KB (210) page: 26 = 64 entries —
a few hundred bits per process, easily affordable.
With a 32-bit address and a 4 KB (212) page: 220 = 1,048,576
entries, which at 4 bytes an entry is about 4 MB of page table for one process —
which is why real systems use multi-level, hashed or inverted page tables.
An inverted page table has one entry per frame, not per page, so its size is
fixed by physical memory and is shared by all processes (Feb-2019 Q.4 asked exactly this: 32 frames ⇒
32 entries, versus 256 entries in the ordinary table).
Factor 2 — address-space size
The size of a process’s logical address space is decided by the address width, not by how much
RAM exists: 2m × n bytes for an m-bit logical address with n-byte words. The
physical address space is decided by the number of frames × frame size. Those two are
independent — and in a virtual-memory system the logical space is normally much larger, which is the whole
point (Dec-2024 Q.5(b): 13-bit logical against 15-bit physical; Feb-2019 Q.4: 12-bit logical against 9-bit
physical, where RAM is smaller than the program).
Factor 3 — the effective access time formula
Let p be the page-fault rate (0 ≤ p ≤ 1; p = 0 means no faults, p = 1 means every
reference faults), ma the memory-access time and pf the total fault
overhead. Then:
EAT = (1 − p) · ma + p · (page-fault overhead + swap page out
+ read (swap) page in + swap page in)
= (1 − p) · ma + p · pf
Page-fault overhead = service the interrupt + find a free frame + start the disk read + update the
table + restart the instruction.
“Swap page out” appears only when the victim page is modified; a clean victim is discarded
without a write.
“Read page” is bounded by seek + rotational latency + transfer, and dominates everything else.
The value of p cannot be computed — it is a property of the program’s behaviour, so it is
measured empirically (count faults over an interval and divide by the number of
references), or estimated from the reference string, as in thrashing.
Magnitude check with the numbers from the paper: ma = 100 ns and a fault service time of 25 ms =
25,000,000 ns. Even at p = 0.001, EAT = 0.999(100) + 0.001(25,000,000) ≈ 25,100 ns — a
250-fold slowdown. That is the real lesson of the question: virtual memory is only worth
having while p stays very small.
Verification noteJun-2019 Q.1(h) is printed as
“Effective access time = Page fault service time + memory access time = 25 + 100 = 125 ns”.
That is dimensionally wrong — it adds 25 milliseconds to 100 nanoseconds and then labels
the result ns. 25 ms = 25,000,000 ns. The correct answer to write is: convert both to the
same unit, then apply EAT = (1 − p)·ma + p·pf; with the data given there is no page-fault probability, so
EAT cannot be reduced to a single number and the fault rate must either be stated as a variable or assumed.
If a fault is taken on every reference (p = 1) the EAT is 25,000,000 ns; with p = 0 it is 100 ns.
Never reproduce “125 ns”.
The same caution applies to Jul-2016 Q.2(b), whose printed “hit ratio”
comes out as 1.86 — an impossible probability; the re-solved value from the same model is
x ≈ 0.861 (see section J).
S. Thrashing
Virtual memory
Unit II · Thrashing
Explain the concept of Thrashing in virtual memory.
Recent PYQ — must doMid Term Oct 2025 · Q.1(d)2 MarksVery high
Asked in (merged): Mid Term Oct 2025 · Q.1(d) (2 marks) · Mid Term Nov 2023 ·
Q.2(b) “What is cause of thrashing? What steps are taken to eliminate the problem?” (marks not printed on the
question line — it shares a 10-mark Q.2 with the page-replacement numerical) · End Term May 2016 · Q.3(b)
“Mention the cause that effect thrashing. How does degree of multiprogramming and CPU utilization effect
tracing.” (2+2 marks; the sentence is garbled as printed) · End Term May-June 2017 · Q.2(c) (2 marks) · First
Term Feb 2018 · Q.1(e) (2 marks) · First Term Feb 2019 · Q.1(d) (2 marks).
Show answer
Meaning. A process is thrashing when it is spending more time paging than
executing. It does not have enough frames to hold the pages it is actively using, so it page-faults,
replaces a page that it needs again almost immediately, faults again, and keeps cycling. The system as a
whole looks busy — the paging device queue is full — while doing almost no useful work. The May-2016
printed definition is the one to quote: “A process is thrashing if it is spending more time paging than
executing.”
Cause — the chain the papers ask for
The OS monitors CPU utilisation. If utilisation is too low, it raises the degree of
multiprogramming by admitting another process — without regard to which processes already own frames.
A process enters a new phase of execution and needs more frames. It starts faulting and takes frames
away from other processes.
Those processes need the pages that were taken from them, so they fault too, and steal frames in turn.
All these faulting processes queue for the paging device. While they wait, the ready queue
empties and CPU utilisation falls.
The CPU scheduler sees falling utilisation and reacts the only way it knows — it admits
even more processes, which steals more frames and lengthens the paging queue.
The feedback loop closes: page-fault rate rises tremendously, effective memory-access time rises,
and no work gets done because the processes spend all their time paging. The frame allocation may even
fall below the minimum a low-priority process needs, forcing it to be suspended and paged out entirely —
the “swap-in, swap-out level of intermediate CPU scheduling” named in the May-2016 answer.
Effect
CPU utilisation and system throughput collapse, while paging-device utilisation saturates.
Effective access time explodes — the EAT of section R with p → 1.
Response time and turnaround time become terrible even though the ready queue is short.
The system may appear hung; the swap/paging device is the bottleneck, not the CPU.
Fig S-1 · CPU utilisation vs degree of multiprogramming
How to draw this in exam
Axes: y = CPU utilisation, x = degree of multiprogramming.
Draw a curve that rises gently to a rounded peak about 60% along the x-axis.
After the peak make it fall sharply, then flatten near the bottom.
Shade everything right of the peak and write THRASHING REGION inside it.
Mark the peak “optimum degree of multiprogramming / maximum CPU utilisation” — that single label is
what the 2-mark question is really testing.
Relationship in words
As the degree of multiprogramming increases, CPU utilisation also increases — but more and more slowly —
until a maximum is reached. If the degree of multiprogramming is increased even further, thrashing
sets in and CPU utilisation drops sharply. At that point, to raise CPU utilisation and stop thrashing, the
only remedy is to decrease the degree of multiprogramming. The counter-intuitive part —
that “more processes” must mean “less work done” — is the answer’s centre of gravity.
How to eliminate / prevent it
Reduce the degree of multiprogramming — suspend (swap out) some processes and free
their frames for the ones that remain. This is the direct, printed remedy.
Give each process at least the number of frames it needs for its active pages, instead of spreading
frames evenly; the two standard formulations of “how many that is” are the
working-set model and the page-fault-frequency (PFF) control.
Monitor the page-fault rate per process (counters + a timer, or reference bits) and act on it: raise
a process’s allocation while its fault rate is above target, lower it when below — but never let the sum
of allocations exceed capacity.
Prevent the feedback loop: do not use CPU utilisation alone as the admission signal, because
during thrashing low utilisation is a symptom, not a reason to admit more work.
Exam tipFor 2 marks: the one-line definition + one cause + the graph with the
shaded region. For a 6–8 mark version add the 6-step cause chain and the elimination list; the graph earns
the difference every time.
T. Demand Segmentation
Virtual memory
Unit II · Demand Segmentation
Demand segmentation — segments brought in on demand, segment faults, and why the scheme is rarely used
Syllabus only — no direct PYQNot asked in either bookSafety
Show answer
Why this section is hereDemand segmentation is the last named line of the
“Virtual Memory” part of your Unit II syllabus, and — like swapping — it is not asked as a question
in either book. The extraction notes list it as “NOT FOUND” for every paper from 2016 to 2025, and
the coverage matrix marks it “cover for safety”. One tight paragraph plus the reason it lost is enough
insurance; do not spend a whole evening on it.
Demand segmentation is the application of lazy loading to segments instead of
pages. Not all of a process’s segments are brought into memory when it starts, and — as the Jan-2024
answer to Q.5(a) puts it for virtual-memory segmentation — segments may be “created but not all at once, not
at run time of the program”; a segment is loaded only when the program first references it. Until then its
segment-table entry is marked invalid.
How it works
Each process is divided into logical segments (main routine, procedure, array, stack …) exactly as in
section K.
The segment table entry carries base + limit plus a valid bit. Invalid = not resident.
A reference to an invalid segment causes a segment fault: the OS traps, finds a free
block of memory large enough for the whole segment, reads it in from the backing store, updates
the entry to valid and restarts the instruction.
Advantages are the same ones as for demand paging: startup I/O and memory per process are both
proportional to what is actually used, and the logical address space can be much bigger than RAM.
Why it is rarely used
Problem
Consequence
Segments are variable sized
A segment fault needs one contiguous free block as large as the whole segment — enough free
memory in total is not enough. The fault may fail even though RAM is half empty.
Swapping a segment is expensive
Transfer cost is proportional to the segment, which can be megabytes, and it must be paid as a
single blocking operation rather than page by page.
External fragmentation returns
Loading and removing variable-sized segments chops memory into holes; compaction is needed, and
compaction while other segments are being faulted in is very costly.
Segments grow at run time
Stacks and heaps expand, so a resident segment may outgrow its block and have to be moved —
which demands a relocation mechanism and a bigger hole at exactly the wrong moment.
Replacement is awkward
Evicting one big segment frees a lot at once, but the granularity is coarse, so the OS either
throws out too much or cannot find a victim that fits the hole pattern.
The practical resolution: real systems keep the user-visible segmentation and
put demand paging underneath it — segmentation with paging
(section M), or the pure-virtual-memory-over-segments variant used by the
Intel Core architecture. Then the on-demand unit is a fixed-size page, any free frame will accept it, and the
“find a hole as big as the segment” problem disappears. That single sentence is the answer to “why is demand
segmentation not used?”.
U. Overlay Concepts
Virtual memory
Unit II · Overlays
What is Virtual memory and how Overlay concept works, explain in short with example.
Older PYQ — syllabus gapFirst Term Feb 2019 · Q.2(b)4 MarksMedium
Asked in: First Term Feb 2019 · Q.2(b) (4 marks) — note that this single question
asks virtual memory and overlays together, so the virtual-memory half is answered in
section N. No 2023–2025 paper asks overlays at all; the coverage matrix marks the topic
“cover for safety”.
Show answer
Overlay. An overlay is a program module that is kept on disk and loaded into
main memory only while it is needed, then overwritten by another module when control moves on. The
program is split into pieces that are never required simultaneously, and one fixed region of memory — the
overlay area — is shared by all of them: whatever is needed now occupies it. This lets a
program larger than available memory run on a system with no virtual memory at all, which is exactly what
early compilers, assemblers and linkers did.
Who decides — the key distinction. In overlays the programmer (or the program’s
own structure) decides which routines are mutually exclusive, how big the overlay area must be, and when to
call the overlay driver to load the next module. In swapping and paging the operating system makes
all those decisions, with the program completely unaware. That one difference — programmer-managed versus
OS-managed — is the mark.
Basis
Overlays
Swapping
Paging
Managed by
The programmer — the code must be split and
the load calls written into it
The operating system (medium-term scheduler)
The operating system + MMU hardware
Unit moved
One overlay module (whatever size the programmer chose)
An entire process
One fixed-size page
Program aware of it?
Yes — the program is written around the structure
and calls the overlay loader explicitly
No — the process just disappears and reappears
No — completely invisible to the program
Hardware support
None — works on a plain machine with a loader routine
Relocation register / relocatable code
MMU, page tables, valid bits, trap on invalid page
(TLB for speed)
Address space
Still real addresses; the overlay region is addressed at
run time by fixed offsets
Logical addresses must be relocatable
Logical ≠ physical; virtual address space may exceed RAM
Deciding what is needed
Static, decided at design time from the program’s
control flow
Load and priority driven, dynamic
Demand driven — whichever page is
referenced (dynamic, with a replacement policy)
Overhead
Loading is by explicit call; no page faults, no table look-ups
Whole-process transfer cost
Fault handling + translation on every reference
Where still used
Tiny embedded systems, ROM-limited devices, historical
DOS programs
Controlled real-time / batch systems
Every general-purpose OS today
Overlay structure — a small worked example
Suppose a program whose memory budget is 32 KB consists of a main routine that is
always active plus three branches of which only one runs at a time:
Module
Size
When needed
Main routine (resident)
12 KB
Always
Overlay A — syntax analysis
8 KB
Only during pass 1
Overlay B — code generation
6 KB
Only during pass 2
Overlay C — optimiser
10 KB
Only on request
Overlay driver (resident loader routine)
2 KB
Always
Memory layout (32 KB budget)
0 – 11 KB main routine (resident)
12 – 13 KB overlay driver (resident)
14 – 23 KB OVERLAY AREA = 10 KB ← the biggest single module, A or B or C at a time
24 – 31 KB data area
Without overlays : 12 + 8 + 6 + 10 + 2 = 38 KB → does NOT fit in 32 KB.
With overlays : 12 + 2 + 10 = 24 KB resident, 8 KB spare → fits.
Run sequence
main → driver.load(A) → run A → return → main → driver.load(B) → run B → …
Loading B overwrites the bytes that held A; A is re-read from disk only if needed again.
Three rules the example shows, and the ones worth stating in an answer:
Only mutually exclusive modules may share one overlay area — the split must follow the
program’s control flow, otherwise a needed module gets overwritten.
The overlay area must be at least as large as the largest module that can occupy it
(10 KB above), so a single oversized module ruins the design.
Time is traded for space: every re-load is a disk read, so the frequently needed module should be made
resident and the rarely needed ones overlaid.
Link back to virtual memoryOverlays solve the same problem virtual memory solves —
a program bigger than RAM — but they push the work onto the programmer. Demand paging is the automated,
fine-grained version of the same idea: the “overlay area” becomes all of free memory, the “module” becomes a
page, and the “driver” becomes the page-fault handler (section P). Write that
sentence whenever a question pairs the two, as Feb-2019 Q.2(b) does.
Memory Management Checklist
Track
Ticks are saved in this browser and survive a refresh. Progress also feeds the dashboard.
Two of these are pure insurance items — swapping, demand segmentation and overlays are named in the syllabus but
are not asked as questions in either book — so they are deliberately short on this page.