[Info-vax] writing a lock free linked list

John Reagan johnrreagan at earthlink.net
Mon Oct 5 07:54:54 EDT 2009


"Joshua Lehrer" <usenet_vms at lehrerfamily.com> wrote in message 
news:23be9a9c-4705-47e3-b795-f5b0421319c4 at j9g2000vbp.googlegroups.com...
> Okay.  I understand what a memory barrier is, and I understand the
> trivial example of when you need them:
>
> g_global1=x;
> mb();
> g_global2=y;
>
> My question is, if my only access to a global is confirmed via calls
> to cmp_swap_quad, do I need a memory barrier in addition?
>
> e.g.
> x=global;
> __cmp_swap_quad(&global,x,y);

If there are no other reads or writes that you want to order with respect to 
each other, then I don't think you need a barrier.

>
> Likewise, if I use atomic operations, like atomic_increment, do I need
> a memory barrier before/after?
>
> atomic_increment_long(&x);
> atomic_increment_long(&y);
>
> is it possible that y is seen as incremented on another processor
> before x?
>

Yes I think it is possible.  If that is something that your algorithm cannot 
tolerate, you'll want a barrier.

John 





More information about the Info-vax mailing list