Previous | Next --- Slide 30 of 35
Back to Lecture Thumbnails
msfernan

This case is similar to our implementation of push and pop from a stack. Repeatedly check if the node was not modified and only if it was not modified between the time of getting the old pointer and doing the compare and swap modify the element.

momoda

What if the prev node is deleted by other thread when this function is in while(1) loop? Then the program will reference freed memory, right?

monkeyking

@momoda See the bottom. For simplicity, this slide assumes the only operation on the list is insert.

momoda

@ monkeyking Oh, I see. thx