From owner-freebsd-smp Mon Mar 24 8:48:18 2003 Delivered-To: freebsd-smp@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ABDBC37B401 for ; Mon, 24 Mar 2003 08:48:16 -0800 (PST) Received: from mail.speakeasy.net (mail16.speakeasy.net [216.254.0.216]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1AEAC43F85 for ; Mon, 24 Mar 2003 08:48:16 -0800 (PST) (envelope-from jhb@FreeBSD.org) Received: (qmail 9248 invoked from network); 24 Mar 2003 16:48:19 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) by mail16.speakeasy.net (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 24 Mar 2003 16:48:19 -0000 Received: from laptop.baldwin.cx (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.8/8.12.8) with ESMTP id h2OGmAOv092536; Mon, 24 Mar 2003 11:48:11 -0500 (EST) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.4 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20030323074119.GA43849@attbi.com> Date: Mon, 24 Mar 2003 11:48:10 -0500 (EST) From: John Baldwin To: Craig Rodrigues Subject: RE: atomic_dec_and_test() in FreeBSD? Cc: freebsd-smp@freebsd.org X-Spam-Status: No, hits=-19.5 required=5.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On 23-Mar-2003 Craig Rodrigues wrote: > Hi, > > Is there a way that I can use the existing > FreeBSD macros to achieve the equivalent of atomic_dec_and_test which > is mentioned here for Linux: > > http://kernelnewbies.org/documents/kdoc/kernel-api/r287.html If you strictly need decrement and test, you can use a while loop with atomic_cmpset(), e.g. do { x = foo; } while (atomic_cmpset_int(&foo, x, x - 1) == 0); if (x == 1) /* foo just dropped to zero */ What task are you trying to accomplish though? -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message