Port-mips archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: atomic_ops(3) and sync



On Wed Jun 16 2010 at 11:35:05 +0200, Manuel Bouyer wrote:
> hi,
> I just noticed that our atomic_ops(3) don't include a sync instruction.
> >From what I've seen in the mips documents, neither ll nor sc is a memory
> barrier, so our atomic_ops are no memory barrier either, and callers
> have to add a sync instruction before atomic calls.
> Is this the desired behavior, or should a sync be added in atomic_ops ?

This behaviour is documented in atomic_ops(3) (your email does not
provide clear indication as to if you read that part of the manpage,
so I'll just quote it here):

    Atomic operations are strongly ordered with respect to each other.
    The global visibility of other loads and stores before and after an
    atomic operation is undefined.  Applications that require synchro-
    nization of loads and stores with respect to an atomic operation must
    use memory barriers.  See membar_ops(3).

So if you want to impose ordering on other accesses with respect to the
atomic op you need to manually add membars.  Atomic itself does not,
and should not, guarantee it.


Home | Main Index | Thread Index | Old Index