CS FundamentalsVery hardGATE CS
Shared x = 1. Thread A executes x = x + 1 twice; thread B executes x = x * 2 once; each statement is a separate load and store and there is no locking. Which set lists exactly the possible final values?
- A. {4, 5, 6}
- B. {2, 4, 5, 6}
- C. {3, 4, 5, 6}
- D. {2, 3, 4, 5, 6}
Correct answer: D. {2, 3, 4, 5, 6}
Serial-like orders give 6, 5 and 4. If B loads 1 and stores 2 after both of A's updates, the result is 2; if A's second update loads before B's store and writes last, it can be 3. So {2, 3, 4, 5, 6}.
More Operating Systems questions
- References at times 1 to 12 are 1, 3, 2, 3, 4, 4, 1, 5, 2, 5, 5, 3. With working-set window Δ = 5 (the last 5 references, including the…
- Three processes share one resource type with identical instances. P1 may need at most 3 instances, P2 at most 4 and P3 at most 5, and each…
- Free holes (in order) are 150, 400, 220, 350 and 500 KB. Requests of 210, 380, 140 and 330 KB arrive in that order. Which placement…
- A buddy allocator manages 1024 KB starting at address 0 and always uses the lowest-addressed free block of the needed size. Requests: A =…
- Periodic tasks (execution time, period = deadline): T1 (1, 4), T2 (2, 6), T3 (3, 12), scheduled by rate-monotonic priorities. Which…
- A Unix-style inode has 10 direct pointers, 1 single-indirect and 1 double-indirect pointer. Blocks are 1 KB and block pointers 4 bytes…