From owner-freebsd-smp Tue Oct 31 12:14:23 2000 Delivered-To: freebsd-smp@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id D195437B479 for ; Tue, 31 Oct 2000 12:14:20 -0800 (PST) Received: from fledge.watson.org (robert@fledge.pr.watson.org [192.0.2.3]) by fledge.watson.org (8.9.3/8.9.3) with SMTP id PAA95404; Tue, 31 Oct 2000 15:14:08 -0500 (EST) (envelope-from robert@fledge.watson.org) Date: Tue, 31 Oct 2000 15:14:08 -0500 (EST) From: Robert Watson X-Sender: robert@fledge.watson.org To: Alfred Perlstein Cc: freebsd-smp@FreeBSD.org Subject: Re: Reference count invariants in a fine-grained threaded environment In-Reply-To: <20001031115506.Y22110@fw.wintelcom.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org > Robert Watson's explanation on how he was going to handle atomic > ops with mutexes rather than discussing my proposed atomic_t (or > atomicref_t) made it pretty clear that either he has somehow missed > (happens to disagree with) my proposals. To be honest, I had forgotten about the atomic operation proposal and was relying only on primitives that we already had. When atomic operations were proposed in the follow-up message I acknowledged that they could be used, but that they didn't meet the needs of the piece of code I was working with. The reason I selected mutexes in the new jail code was the ancillary reason: the same mutex protects the consistency of the data structure the prison structures are linked into, which is a means by which a new reference can be gained. I.e., while atomic operations would work fine for crcopy(), the don't work in environments where new references don't have to be generated by inheritence. For example, in the new prison code, you can either get a reference to a prison by borrowing it from an existing reference, inheritting from an existing reference (i.e., increment the reference count), or by using prison_find() which walks the list of prison structures searching for a particular jailid. If you don't have a mutex protecting the increment there, you can get into a race condition. As I stated in my follow-up e-mail, I'm fine with atomic operations in locations where appropriate. I refuse to comment on the various means by which atomic operations might be implemented, as I am utterly unqualified to comment on that topic. :-) I would be happy with atomic operations in the general case as long as either (a) we provide an alternative that's easy to use for platforms that don't have atomic increment and decrement, or (b) we don't care about platforms without them. This is a moot point if there are no platforms not supporting the atomic operation requirements, but I am not qualified to make statements about that either. :-) Robert N M Watson FreeBSD Core Team, TrustedBSD Project robert@fledge.watson.org NAI Labs, Safeport Network Services To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message