About the memory barrier in BSD libc

Slawa Olhovchenkov slw at zxy.spb.ru
Mon Apr 23 09:40:19 UTC 2012


On Mon, Apr 23, 2012 at 05:32:24PM +0800, Fengwei yin wrote:

> On Mon, Apr 23, 2012 at 4:41 PM, Slawa Olhovchenkov <slw at zxy.spb.ru> wrote:
> > On Mon, Apr 23, 2012 at 02:56:03PM +0800, Fengwei yin wrote:
> >
> >> Hi list,
> >> If this is not correct question on the list, please let me know and
> >> sorry for noise.
> >>
> >> I have a question regarding the BSD libc for SMP arch. I didn't see
> >> memory barrier used in libc.
> >> How can we make sure it's safe on SMP arch?
> >
> > /usr/include/machine/atomic.h:
> >
> > #define mb()    __asm __volatile("lock; addl $0,(%%esp)" : : : "memory")
> > #define wmb()   __asm __volatile("lock; addl $0,(%%esp)" : : : "memory")
> > #define rmb()   __asm __volatile("lock; addl $0,(%%esp)" : : : "memory")
> >
> 
> Thanks for the information. But it looks no body use it in libc.

I think no body in libc need memory barrier: libc don't work with
peripheral, for atomic opertions used different macros.


More information about the freebsd-threads mailing list