cvs commit: src/sys/kern kern_proc.c

Julian Elischer julian at elischer.org
Wed Jun 9 17:50:50 GMT 2004



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 at 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 at FreeBSD.org
> FreeBSD committer
> 



More information about the cvs-src mailing list