CSS Prepare

optional · CSS study notes

Memory Management — Solved Numericals

CSS Optional — Paper-II, Section-A · P-II.III.V (numericals) · Worked past-paper problems for [Memory Management]. Read the concepts page first (fit algorithms, fragmentation, bitmap/linked-list/hash tracking) — this page is pure practice.

Numerical 1 — Bitmap Allocation, First-Fit, Next-Fit, and Alternative Structures (CSS 2021, multi-part, 20 marks total)

(a) Given a 6×6 bitmap (36 allocation units, index 0-35, 1=allocated/0=free), reading row by row:

Row0(0-5): 1 1 1 1 1 0    Row1(6-11): 0 1 1 0 0 0    Row2(12-17): 1 0 0 1 1 1
Row3(18-23): 1 0 0 0 0 0  Row4(24-29): 1 1 0 0 0 0   Row5(30-35): 0 0 0 0 1 1

Free "holes": [5-6] (len 2), [9-11] (len 3), [13-14] (len 2), [19-23] (len 5), [26-29] (len 4), [30-33] (len 4).

(b) Insert page H, size 3, using First-Fit: scan from index 0 — hole [5-6] is too small (len 2 < 3); next hole [9-11] (len 3) is an exact fit → place H at indices 9,10,11. Bitmap row1 (6-11) becomes 0 1 1 1 1 1.

(c) Insert page K, size 2, using Next-Fit: resume scanning from where the previous allocation ended (index 12), not from index 0. First hole found: [13-14] (len 2) — exact match → place K at indices 13,14. Bitmap row2 (12-17) becomes 1 1 1 1 1 1.

(d) Linked-list equivalent of the memory map after (b) and (c):

[P,0,5]→[F,5,2]→[P,7,2]→[H,9,3]→[P,12,1]→[K,13,2]→[P,15,3]→[P,18,1]→
[F,19,5]→[P,24,2]→[F,26,4]→[F,30,4]→[P,34,2]→NULL

Each node's (start, length) matches one maximal run of identical bits from the bitmap; free (F) nodes are exactly what an allocation search scans.

(e) Hash table for active pages: maps each page name directly to its location, e.g. H → (9,3), K → (13,2), giving O(1) lookup of a named page's current position instead of scanning the bitmap/list.

Numerical 2 — Paging Address Translation (CSS 2018, 6 marks)

Q: 32-bit addresses = 20-bit Virtual Page Number (VPN) + 12-bit offset. How many virtual pages, and what page size? Translate virtual address 0x7589; if its page-table entry (PTE) is 0x900DF, find the physical address.

Number of virtual pages = 2^20 = 1,048,576
Page size = 2^12 = 4096 bytes (4 KB)

0x7589 in binary: 0111 0101 1000 1001
  Offset (low 12 bits)  = 0x589 = 1417
  VPN (remaining bits)  = 0x7589 >> 12 = 0x7 = 7

Physical Address = (Frame Number << 12) | Offset
                 = (0x900DF << 12) | 0x589
                 = 0x900DF000 + 0x589
                 = 0x900DF589

Answer: 1,048,576 virtual pages, page size 4 KB, VPN=7, offset=1417 (0x589), Physical Address = 0x900DF589.


🎯 CSS Exam Angle

Memory Management numericals reward showing the bitmap/list transformation step by step, not just the final answer — 2021's question awarded marks separately for parts (a) through (e), each building on the previous part's updated memory state, so an early arithmetic slip cascades. Always redraw (or re-describe) the full structure after each operation rather than jumping to the end state.

⚠️ MCQ Traps

  • Next-Fit resumes from the last allocation point, not from index 0 — the most common error is applying First-Fit logic when the question specifies Next-Fit.
  • Double-check hex/binary bit-splitting on paging translations — miscounting the offset/VPN boundary is the single most common slip.