Back to Lecture Thumbnails
pizza
martigp
Why for when we make this atomic do we 3rd line in. Does the sentinel node not stay the same (bar changes to its right pointer) for the lifetime of the deque and so getting a pointer to it doesn't really need to atomic.
cassiez
+1 to @martigp's question, I was wondering the same while listening to the lecture - suppose the doubly linked list has an invariant that 1) the q->left sentinel node is created when list is created and 2) the sentinel itself is never changed, but its right pointer value could change, then isn't it safe to leave out the 3rd line from the atomic block? The leftSentinel is just a pointer (address of the left sentinel node) that will never change.
Please log in to leave a comment.
Copyright 2021 Stanford University
To make PushLeft thread safe using atomic(), we would need to put all of the last 6 lines in the atomic region.