From owner-freebsd-hackers Tue Oct 3 1:57:33 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from penfold.transactionsite.com (penfold.transactionsite.com [203.14.245.1]) by hub.freebsd.org (Postfix) with SMTP id F2EBB37B503 for ; Tue, 3 Oct 2000 01:57:27 -0700 (PDT) Received: (qmail 22898 invoked from network); 3 Oct 2000 08:57:24 -0000 Received: from haym.transactionsite.com (HELO haym) (192.168.1.9) by penfold.transactionsite.com with SMTP; 3 Oct 2000 08:57:24 -0000 Message-ID: <005801c02d17$17efc0a0$0901a8c0@haym.transactionsite.com> From: "Jan Mikkelsen" To: "John Baldwin" Cc: "Kevin Mills" , "FreeBSD Hackers" Subject: Re: atomic operations Date: Tue, 3 Oct 2000 19:51:16 +1100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3612.1700 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3612.1700 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG John Baldwin wrote: >On 03-Oct-00 Jan Mikkelsen wrote: >> There shouldn't be a need for a loop like the one you describe for a simple >> atomic increment. > >The trick is that I want to increment and read at the same time. I don't know the exact semantics of atomic_cmpset_int, but it looks like a compare and swap operation which returns zero if the operation failed, some other value on success. Unless I've missed something, the basic operation of your loop can be done (on a '486 or better) without the loop by using the xadd instruction. Of course, if the code needs to run on earlier processors, xadd fails and a loop is necessary. Jan Mikkelsen To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message