Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 05 Oct 2000 20:52:25 -0700
From:      Mike Smith <msmith@freebsd.org>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org
Subject:   Re: cvs commit: src/sys/alpha/include atomic.h src/sys/i386/incl 
Message-ID:  <200010060352.e963qPh04244@mass.osd.bsdi.com>
In-Reply-To: Your message of "Fri, 06 Oct 2000 14:27:37 %2B1100." <Pine.BSF.4.21.0010061413500.1789-100000@besplex.bde.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
> > >>   Add atomic_readandclear_int and atomic_readandclear_long.
> > > 
> > > Um, isn't this just exchange-with-zero?
> > 
> > That's one way of implementing it, yes.  That is not the method used by the
> > alpha, however.  I chose the name due to prior existence.  The alpha
> > already had an atomic_readandclear_int, albeit buried in the ipl code.
> > The x86 had a similar loadandclear() in cpufunc.h
> 
> It should be named loadandclear().  "load" is more precise than "read".

It should be called "atomic_exchange()", and this specific case should be 

int value = 0;
atomic_exchange(value, othervalue);

since it's otherwise entirely redundant.

> The instruction to do the load is even named "ld" on alphas.  I will
> remove the suffixes on the atomic functions soon.  It should go without
> saying that operations like load and clear, test and set, and compare and
> swap, etc., are atomic.

It doesn't go without saying, and I think it's important from the 
perspective of general code readability that we make it extremely clear 
that these methods are explicitly atomic.

I'm also strongly in favour of the atomic_t proposal that Alfred put 
forwards, since in many cases the atomic_*_int calls are used by default 
where atomic_*_optimal_type would be better.

-- 
... every activity meets with opposition, everyone who acts has his
rivals and unfortunately opponents also.  But not because people want
to be opponents, rather because the tasks and relationships force
people to take different points of view.  [Dr. Fritz Todt]
           V I C T O R Y   N O T   V E N G E A N C E




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200010060352.e963qPh04244>