tech-userlevel archive

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

Re: pthread library related

Joerg Sonnenberger <> wrote:
 |On Mon, May 30, 2016 at 02:19:26PM -0700, Charles Cui wrote:
 |> good to know atomic_inc_uint_nv is implemented using cas.
 |No, atomic_inc is *not* necessarily implemented using CAS. There are a

What a pity.

 |couple of different ways to do it ranging from implicit serialisation on
 |UP-only systems over CAS/LL-SC loops to native locked inc instructions.
 |For the application program, it doesn't generally matter which it is.

Remembering some atomic integer (inline) functions seen in the
Linux Kernel (Alpha?) before discovering FreeBSD (v4.7), i'd
rather go with cas (or even locked xchg if not otherwise possible)
spinlocks (or noops without SMP) and a normal integer increment
instead.  You can even PAUSE.  That was a good hardware addition.
(Not that i have any idea of hardware.)


Home | Main Index | Thread Index | Old Index