Date: Wed, 9 Jun 2004 10:50:20 -0700 (PDT) From: Julian Elischer <julian@elischer.org> To: Ruslan Ermilov <ru@FreeBSD.org> Cc: Garrett Wollman <wollman@khavrinen.lcs.mit.edu> Subject: Re: cvs commit: src/sys/kern kern_proc.c Message-ID: <Pine.BSF.4.21.0406091046360.57882-100000@InterJet.elischer.org> In-Reply-To: <20040609164415.GA59326@ip.net.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 9 Jun 2004, Ruslan Ermilov wrote: > On Wed, Jun 09, 2004 at 12:32:28PM -0400, Garrett Wollman wrote: > > <<On Wed, 9 Jun 2004 18:28:57 +0200 (CEST), Lukas Ertl <le@FreeBSD.ORG> said: > > > > > Is there a possibility that foo->refcount is incremented after both of > > > them left the critical section, so that i is 0, but foo->refcount isn't? > > > > The only way there can be such a possibility is if you haven't counted > > all the references. > > > Are you trying to say that the 0->1 transition isn't possible? yes, in general.. Only the creator of the object can make the 0->1 transition.. then if you put it on a linked list it has 2 references. (possibly 3 if it's a bidirectionally linked list, (depending on how anal you want to get). When the creator releases its reference then teh linked list still ahs a reference. Then when you look it up, you should increment the count, and when you remove it from teh linked list you should decrement the count. Now it has only one reference... yours.. and no-one else can find it to manipulate it because it is not in the linked list any more.. so when you drop its last refernce and it goes to 0, then you KNOW that no-one else can get it to move it back to 1. > > > Cheers, > -- > Ruslan Ermilov > ru@FreeBSD.org > FreeBSD committer >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0406091046360.57882-100000>