From owner-cvs-all Tue Jan 16 0: 6:55 2001 Delivered-To: cvs-all@freebsd.org Received: from gratis.grondar.za (grouter.grondar.za [196.7.18.65]) by hub.freebsd.org (Postfix) with ESMTP id EC55837B401; Tue, 16 Jan 2001 00:06:24 -0800 (PST) Received: from grondar.za (root@gratis.grondar.za [196.7.18.133]) by gratis.grondar.za (8.11.1/8.11.1) with ESMTP id f0G86GI31855; Tue, 16 Jan 2001 10:06:19 +0200 (SAST) (envelope-from mark@grondar.za) Message-Id: <200101160806.f0G86GI31855@gratis.grondar.za> To: John Baldwin 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) References: In-Reply-To: ; from John Baldwin "Mon, 15 Jan 2001 23:08:14 PST." Date: Tue, 16 Jan 2001 10:06:19 +0200 From: Mark Murray Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > 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