CS FundamentalsVery hardGATE CS · Amazon/Microsoft SDE MCQ
Pages are 4 KB and a process has 3 frames. It runs `for (i = 0; i < 1024; i++) for (j = 0; j < 1024; j++) A[i][j] = 0;` on an int A[1024][1024] (4-byte ints, row-major, page-aligned), with code in a separate always-resident frame. About how many page faults occur, and how many if the loops are swapped (j outer, i inner)?
- A. 1024 and 1024
- B. 1024 and 1,048,576
- C. 1,048,576 and 1024
- D. 512 and 1,048,576
Correct answer: B. 1024 and 1,048,576
Each row is 4 KB, exactly one page. Row-major order faults once per row: 1024. Column order touches a new row (page) on every access, and 3 frames cannot hold 1024 rows, so nearly every one of the 2²⁰ accesses faults.
More Operating Systems questions
- Which statement about the difference between an unsafe state and a deadlocked state (Banker's algorithm) is correct?
- A 32-bit system uses segmentation with paging. A logical address is (segment s, offset d) with d of 32 bits; within a segment, d is split…
- A thread library offers only kernel-level threads (one-to-one). Which change makes thread creation and switching cheapest without losing…
- A program creates threads with for (i = 0; i < 4; i++) pthreadcreate(&t[i], NULL, work, &i); and each thread reads arg as its index. What…
- In a directory, ln data h and ln -s data s are run, and then mv data data2 renames the original within the same file system. What happens…
- What does it mean that the read() system call on a terminal is 'blocking', and what state does the process enter while no input is…