cvs commit: src/sys/kern kern_proc.c

Poul-Henning Kamp phk at phk.freebsd.dk
Wed Jun 9 16:40:44 GMT 2004


In message <1086798299.12306.3.camel at builder02.qubesoft.com>, Doug Rabson write
s:

>> GOOD:
>> 
>> 	LOCK(foo->lock)
>> 	i = --foo->refcount;
>> 	UNLOCK(foo->lock)
>> 	if (i == 0)
>> 		destroy(foo);
>
>Isn't there still a race in the GOOD case here if somone takes a new
>reference, incrementing refcount after the UNLOCK(foo->lock)?

Convetionally, once the refcount==0 it means that nobody will reference
it anymore.

If you violate this by design (like for instance in the vnode cache),
then you need to cope with that problem, and things get ugly fast
(like for instance in the vnode cache).

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.


More information about the cvs-src mailing list