The compare and swap() instruction can be used to design lock-free data structures such as stacks, queues, and lists. The program example shown in Figure 6.18 presents a possible solution to a lock-free stack using CAS instructions, where the stack is represented as a linked list of Node elements with the top representing the top of the stack. Is this implementation free from race conditions?
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here