CS FundamentalsVery hardGATE CS
Shared x = 1. T1 does `x = x + 1;` T2 and T3 each do `x = x * 2;` (load, compute, store, no locks). How many distinct final values of x are possible, and what is the largest?
- A. 6 values; largest 8
- B. 6 values; largest 6
- C. 3 values; largest 8
- D. 8 values; largest 10
Correct answer: A. 6 values; largest 8
Serial orders give (1+1)×2×2 = 8, 1×2×2+1 = 5, and 1×2+1 then ×2 = 6; lost updates add smaller values. Enumerating all interleavings gives [2, 3, 4, 5, 6, 8], i.e. 6 values with maximum 8.
More Operating Systems questions
- How many of these statements about threads are correct? 1. A thread that calls exit() terminates the whole process. 2. If one thread…
- A server uses a fixed pool of 8 worker threads, and each request does a blocking database call taking 90% of its time. Roughly how many…
- Which statement about user-mode and kernel-mode stacks is correct?
- A process gets SIGSEGV writing to a page marked read-only that belongs to a copy-on-write mapping after fork(). Why is this NOT what…
- A system uses paging with a 2-bit protection field (read, write) in each PTE and the CPU also has an execute-disable bit. Which page…
- Swap space is configured at 2 GB, RAM is 8 GB, and the OS uses overcommit. A process mallocs 20 GB and touches only 1 GB. What happens on…