CS FundamentalsVery hardGATE CS (PYQ pattern)
Three threads each execute x = x + 1; twice on a shared int x that starts at 0 (so six increments in all). Each increment is a separate LOAD and STORE with no locking, and the threads may interleave arbitrarily. What are the minimum and maximum possible final values of x?
- A. 3 and 6
- B. 2 and 5
- C. 2 and 6
- D. 1 and 6
Correct answer: C. 2 and 6
Maximum 6 when no increments overlap. Exhaustive enumeration of all interleavings gives every value from 2 to 6; 1 is impossible because the last STORE overall is some thread's second store, which writes a value that is at least 2 (it follows that thread's own first store).
More Operating Systems questions
- A process has a 1 MB address space split into 4 segments, each paged separately; the single-level page tables together need one 8-byte…
- A process owns 100 private writable pages. It calls fork() and both processes use copy-on-write. Before either exits, the child writes to…
- A RAID 5 array has 6 disks, each able to do 150 random I/O operations per second. A small RAID 5 write costs 4 disk I/Os (read old data…
- A 512 x 512 matrix of 4-byte integers is stored row-major, starting at a page boundary, with 4 KB pages (so two rows per page). The code…
- With 3 frames, initially empty, the reference string is 4, 2, 1, 5, 2, 1, 3, 2, 4, 3, 1, 3, 2, 2, 5, 4, 5, 1, 3, 2, 4, 4. How many MORE…
- A 32-bit machine uses two-level paging with 4 KB pages, 4-byte entries and 10 + 10 + 12 address bits, so each page-table page maps 4 MB. A…