Date: Mon, 24 Mar 2003 11:48:10 -0500 (EST) From: John Baldwin <jhb@FreeBSD.org> To: Craig Rodrigues <rodrigc@attbi.com> Cc: freebsd-smp@freebsd.org Subject: RE: atomic_dec_and_test() in FreeBSD? Message-ID: <XFMail.20030324114810.jhb@FreeBSD.org> In-Reply-To: <20030323074119.GA43849@attbi.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 23-Mar-2003 Craig Rodrigues wrote: > Hi, > > Is there a way that I can use the existing <machine/atomic.h> > 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 <jhb@FreeBSD.org> <>< 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20030324114810.jhb>