CS FundamentalsVery hardGATE CS
Shared x = 1. Three threads run once each, with no locking: T1 does x = x + 2, T2 does x = x * 3, T3 does x = x − 1. Each statement is a separate load then store. How many distinct final values of x are possible?
- A. 6
- B. 8
- C. 4
- D. 9
Correct answer: B. 8
The 6 serial orders give 8, 6, 4, 2 (two orders give 4 and two give 6), and lost updates add 0, 3, 5 and 9, e.g. T1 and T2 serially (9) with T3's stale write lost. Enumerating all load/store interleavings gives {0, 2, 3, 4, 5, 6, 8, 9}: 8 values.
More Operating Systems questions
- 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…
- 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…