From owner-freebsd-hackers Tue Oct 3 2: 0:15 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from critter.freebsd.dk (flutter.freebsd.dk [212.242.40.147]) by hub.freebsd.org (Postfix) with ESMTP id EC59E37B503; Tue, 3 Oct 2000 02:00:10 -0700 (PDT) Received: from critter (localhost [127.0.0.1]) by critter.freebsd.dk (8.11.0/8.9.3) with ESMTP id e938xuN46870; Tue, 3 Oct 2000 10:59:56 +0200 (CEST) (envelope-from phk@critter.freebsd.dk) To: "Jan Mikkelsen" Cc: "John Baldwin" , "Kevin Mills" , "FreeBSD Hackers" Subject: Re: atomic operations In-Reply-To: Your message of "Tue, 03 Oct 2000 19:51:16 +1100." <005801c02d17$17efc0a0$0901a8c0@haym.transactionsite.com> Date: Tue, 03 Oct 2000 10:59:56 +0200 Message-ID: <46868.970563596@critter> From: Poul-Henning Kamp Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message <005801c02d17$17efc0a0$0901a8c0@haym.transactionsite.com>, "Jan Mikk elsen" writes: >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. That is exactly what atomic_cmpset_int is for, look in sys/fs/devfs/devfs_devs.c for some examples -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD coreteam member | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message