Le 07/12/2011 18:02, Martin Nowak a écrit :
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

When doing so, you should anyway have a local pointer to that data. So it will not be collected until you release that local pointer, when the flagged one is already removed.

Flagged pointer is a temporary state. It is usefull because falgging can be done as an atomic operation. But the flagged pointer is not here to stay. It is here to mention to others thread that an ongoing operation is concurently running.

Reply via email to