[Info-vax] writing a lock free linked list

John Reagan johnrreagan at earthlink.net
Fri Oct 2 20:58:14 EDT 2009


"Joshua Lehrer" <usenet_vms at lehrerfamily.com> wrote in message 
news:ef3af335-dd4f-4fca-b608-f9599a497943 at e8g2000yqo.googlegroups.com...
>> Since you asked about memory barriers, I'd read up on the memory ordering
>> rules for Itanium in architecture manuals.  There are sections on Vol 1
>> (read 4.4.6 and 4.4.7) and Vol 2 (read 2.1) about memory ordering and the
>> instructions are listed in Vol 3.
>
> I just spent the last hour reading those sections of the manuals and,
> I can honestly say, I am no closer to any answers to my questions.
> Can anyone else give me a push in the right direction, or point me
> towards an explanation that isn't written for someone with technical
> knowledge far superior to mine?
>
> My remaining questions are:
>
> 1) are memory barriers needed in my code
> and
> 2) is the test for the head of the list of NULL okay?

Memory barriers give an order to your memory reads/writes.  Consider code 
that fills in a buffer and then sets a flag saying the buffer is ready.  If 
you don't use a barrier, the write to the ready-flag might actually be 
visible to others before the last write into the buffer.

Or consider some shared global counter (ie, semaphore) which counts the 
number of threads reading some particular global section.  Of course, you'll 
want some atomic operation to increment/decrement the count, but also code 
that is checking the count prior to reading a buffer.  You might want 
barriers there as well if your algorithm cannot tolerate the read of the 
buffer occurring before the read of the flag.

If the Itanium books are confusing, the memory ordering sections of the 
Alpha SRM might help understanding.

John






More information about the Info-vax mailing list