Synchronization & Concurrency


Answer & solution
Answer: A (no official key was published)
1. P repeatedly atomically exchanges S.value with 1 and succeeds only when the previous value was 0. V releases it by storing 0.
2. On a uniprocessor, a process spinning in P with context switching disabled can prevent the lock owner from running V, so progress can fail. Separate load/store instructions are not atomic and allow two contenders to enter.
3. Thus A is true. This is a busy-wait semaphore using 0 for available and 1 for held; assume the intended atomic shared-memory model.
4. Teaching check: Atomicity prevents two contenders from both observing an available semaphore and entering. It does not guarantee progress if the spinning contender prevents the holder from being scheduled. Thus mutual-exclusion correctness and scheduling/liveness assumptions must be considered separately.