tech-kern archive

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

Re: __{read,write}_once



Maxime Villard <max%m00nbsd.net@localhost> wrote:
> >
> > I suggest __atomic_load_relaxed()/__atomic_store_relaxed().
> 
> What I don't like with "atomic" in the name is that the instructions
> generated are not atomic strictly speaking, and I'd rather avoid the
> confusion with the really atomic instructions.

I see the potential source of confusion, but just think about: what could
"atomic" possibly mean for loads or stores?  A load is just a load, there
is no RMW cycle, conceptually; inter-locking the operation does not make
sense.  For anybody who attempts to reason about this, it should not be
too confusing, plus there are man pages.

> 
> > If these are to be provided as macros, then I also suggest to ensure
> > that they provide compiler-level barrier.
> 
> You mean __insn_barrier(), right? Surrounding the access (one before, one
> after) also, right?

Correct.  Alternatively, they can be provided as real functions.  In C,
function calls generally act as compiler-level barriers (as long as they
are guaranteed to not be optimised out).

-- 
Mindaugas


Home | Main Index | Thread Index | Old Index