Finally, I finished implementing my own version of the Hazard Pointers (HP) according to the original paper . The answer to my question: "No", "t" is safer to use. The reason is that how HP works, * hp protects the node pointed to by t when you declared it a dangerous pointer, so when t moves to the next node, the HP engine retains the protection of the previous node. I must reassign the new * hp value before I can use it safely.
Also, in the sample article, it is not explicit, but when you finish using the hazard pointer, you must free it. This means returning * hp to its original state (NULL). Thus, if another thread wants to delete (delete) this node, it will not be considered as used.
In my example above, I have to free * hp before leaving this method. Inside the loop, this is not necessary because I am rewriting the same * hp (* hp ← t) position, so the previous node is no longer protected.
ees_cu
source share