Hazard pointers needed with GC ?

Martin Nowak dawg at dawgfoto.de
Wed Dec 7 09:02:06 PST 2011


I implemented a lock-free doubly linked list some time ago.
I omitted the use of hazard lists because flagging the lowest
bit would still make a valid pointer into the list node.
Afterwards I found that http://www.d-programming-language.org/garbage.html  
explicitly states:
   p = cast(void*)(cast(int)p | 1);  // error: undefined behavior

Is this really needed? Guess the current GC would work properly.

Also if a list node were
   Node(T)
   {
     ubyte[2] data;
     T           t;
   }
Than both a pointer to data[0] as well as one to data[1] are valid
and effectively hold the node.

martin


More information about the Digitalmars-d mailing list