Question
How does compare-and-swap update a shared variable?
Select an option. Your answer will be checked instantly.
Correct Answer: B. It writes a new value only if the current value equals an expected value
Explanation:
Compare-and-swap atomically verifies that a value has not changed before applying an update.
If the comparison fails, the caller can retry using the newly observed value.
Leave a Reply