CS FundamentalsVery hardGATE CS (PYQ pattern)
Arrays A and B are 128 x 128 int matrices stored row-major, 4-byte ints, 512-byte pages (each row occupies exactly one page, A and B page-aligned). The code is: for (i=0;i<128;i++) for (j=0;j<128;j++) B[j][i] = A[i][j]; (read A[i][j] first, then write B[j][i]). Only 3 frames are available for the data (code is elsewhere), managed by LRU, all initially empty. How many data page faults occur?
- A. 32768
- B. 256
- C. 16512
- D. 16384
Correct answer: C. 16512
Each i-iteration reads one row of A (page i, 1 fault per i) but writes column i of B: B[j][i] touches page j for j = 0..127, a cycle of 128 pages with only 2 frames left, so every one of the 16384 B-accesses faults. Total = 16384 + 128 = 16512.
More Operating Systems questions
- A Unix-like file system has 1 KB blocks, 4-byte pointers, and inodes with 10 direct pointers and one single-indirect pointer. Every…
- Banker's algorithm with 3 resource types. Allocation: P0 (1,0,0), P1 (1,2,0), P2 (0,0,0), P3 (1,4,3), P4 (3,1,1). Maximum: P0 (5,3,2), P1…
- Every fork() succeeds, wait() blocks until some child has terminated (it returns at once if the caller has no un-waited children), and…
- A buddy allocator manages 1024 KB (minimum block 16 KB, requests rounded up to powers of two; the lowest-addressed free block of the…
- A 128 KB physically-tagged, virtually-indexed L1 cache has 64-byte lines and is 16-way set-associative. The system uses 4 KB pages. How…
- A machine has 2 GB of RAM; the OS occupies 512 MB and every user process needs 192 MB, so as many whole processes as fit are kept in…