From owner-freebsd-smp Tue Oct 31 11:23:30 2000 Delivered-To: freebsd-smp@freebsd.org Received: from tinker.exit.com (tinker.exit.com [206.223.0.1]) by hub.freebsd.org (Postfix) with ESMTP id 169BF37B479; Tue, 31 Oct 2000 11:23:26 -0800 (PST) Received: from realtime.exit.com (realtime [206.223.0.5]) by tinker.exit.com (8.11.0/8.11.0) with ESMTP id e9VJNGU54541; Tue, 31 Oct 2000 11:23:16 -0800 (PST) (envelope-from frank@exit.com) Received: (from frank@localhost) by realtime.exit.com (8.11.0/8.11.0) id e9VJNG309763; Tue, 31 Oct 2000 11:23:16 -0800 (PST) (envelope-from frank) From: Frank Mayhar Message-Id: <200010311923.e9VJNG309763@realtime.exit.com> Subject: Re: Reference count invariants in a fine-grained threaded enviro In-Reply-To: from John Baldwin at "Oct 31, 2000 11:15:14 am" To: John Baldwin Date: Tue, 31 Oct 2000 11:23:16 -0800 (PST) Cc: Cedric Berger , freebsd-smp@FreeBSD.ORG, Robert Watson Reply-To: frank@exit.com Organization: Exit Consulting X-Copyright0: Copyright 2000 Frank Mayhar. All Rights Reserved. X-Copyright1: Permission granted for electronic reproduction as Usenet News or email only. X-Mailer: ELM [version 2.4ME+ PL68 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org John Baldwin wrote: > They don't. The ia64 has a 'fetchadd' instruction, but x86 and alpha don't > have instructions for this, AFAIK. You can implement it using the > atomic_cmpset() functions however. Of course, what happens if you decrement > a reference and while you are freeing the object someone else obtains a > reference to it? Granted, this shouldn't be possible since if no one can > get to an object, no one should be able to find the object to allocate a > reference to it.... This kind of thing is indeed the gotcha. It takes thinking the problem out well and careful coding to avoid. Of course, avoiding a lock where possible is almost always a win. -- Frank Mayhar frank@exit.com http://www.exit.com/ Exit Consulting http://store.exit.com/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message