InterviewSolution
| 1. |
How Can One Ensure Mutual Exclusion Without Locks? |
|
Answer» When references of two (or more) threads (or PROCESSES) may be serialized with respect to a variable, system primitives LIKE compare and swap can help detect the conflict with ANOTHER thread. Lock free implementations of a thread USUALLY detect the conflict atomically (e.g., using compare and swap) and one succeeds while the other BACKS off and retries. When references of two (or more) threads (or processes) may be serialized with respect to a variable, system primitives like compare and swap can help detect the conflict with another thread. Lock free implementations of a thread usually detect the conflict atomically (e.g., using compare and swap) and one succeeds while the other backs off and retries. |
|