Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Jan 2001 10:06:19 +0200
From:      Mark Murray <mark@grondar.za>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org, jake@FreeBSD.org
Subject:   Atomic ops (Was Re: cvs commit: src/sys/i386/include atomic.h)
Message-ID:  <200101160806.f0G86GI31855@gratis.grondar.za>
In-Reply-To: <XFMail.010115230814.jhb@FreeBSD.org> ; from John Baldwin <jhb@FreeBSD.org>  "Mon, 15 Jan 2001 23:08:14 PST."
References:  <XFMail.010115230814.jhb@FreeBSD.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
> > particularly if I just do a
> > 
> > if (mutex_try_enter(foo, ...)) {
> >       /* Harvest */
> >       :
> >       mutex_exit(foo, ...);
> > }
> > 
> > How much of a difference would it make if I were to use atomic ops like
> > 
> > if (atomic_cmpset(foo, 0, 1)) {
> >       /* harvest */
> >       :
> >       foo = 0;
> > }
> 
> You would have to use atomic_store_rel() here.  And you would have to use
> atomic_cmpset_acq() since you are protecting something.

Right. I'm getting a grasp of whats going on here :-)

> Since you are doing atomic operations with memory barriers either way, I'm not
> sure that the mutex is that much slower, to be perfectly honest.

OK. What I needed to know! I'll figure out an alternative logic. Which
are the "cheaper" atomic ops, and which are the ones to avoid?

M
-- 
Mark Murray
Warning: this .sig is umop ap!sdn


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?200101160806.f0G86GI31855>