tech-userlevel archive

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

Re: pthread library related

I am not familiar with _nv() (are there examples in the netbsd code base? I
searched _nv() in nxr, but did not found anything meaningful.),
but if you want to use atomic operations, one possible way is
compare-and-swap (CAS).
it has stronger guarantee than atomic inc or atomic dec, but also larger

2016-05-30 13:30 GMT-07:00 Martin Husemann <>:

> On Mon, May 30, 2016 at 01:25:34PM -0700, Charles Cui wrote:
> > there is one remaining slot. And each of them will increase p_nsem by one
> > using atomic_inc, the results are we have 1 slot overused, but the error
> is
> > never detected.
> You will have to use a _nv() variant and use the return value to
> compare that against the limit, then decrement in the error path.
> Martin

Home | Main Index | Thread Index | Old Index