In a multithreaded computing environment, a hazard pointer is an element used by a method that allows the memory allocated to the nodes of lock-free dynamic shared objects to be reclaimed.
The typical problem with modifying dynamically allocated nodes is the ABA problem: other threads may modify nodes while you are working on them. In this solution, each thread keeps a list of hazard pointers indicating which nodes the thread is currently accessing. This list can only be written to by the owning thread but can be read by any thread. When a thread wishes to remove a node, it places it on a private list and periodically scans the lists of all other threads for pointers referencing that node. If no such pointers are found the memory occupied by the node can be safely freed.
Hazard pointer basically is a mechanism for a thread to declare to other threads it has to 'look-out' for them. Dr. Michael analyzed a large number of lock-free data structures and found all requires one or two hazard pointers per thread only.
Famous quotes containing the words hazard and/or pointer:
“Who chooseth me must give and hazard all he hath.
Must givefor what? for lead, hazard for lead?
This casket threatens. Men that hazard all
Do it in hope of fair advantages;
A golden mind stoops not to shows of dross.”
—William Shakespeare (15641616)
“The hardiest skeptic who has seen a horse broken, a pointer trained, or has visited a menagerie or the exhibition of the Industrious Fleas, will not deny the validity of education. A boy, says Plato, is the most vicious of all beasts; and in the same spirit the old English poet Gascoigne says, A boy is better unborn than untaught.”
—Ralph Waldo Emerson (18031882)