Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Jun 2004 18:28:57 +0200 (CEST)
From:      Lukas Ertl <le@FreeBSD.org>
To:        Poul-Henning Kamp <phk@phk.freebsd.dk>
Cc:        "M. Warner Losh" <imp@bsdimp.com>
Subject:   Re: cvs commit: src/sys/kern kern_proc.c 
Message-ID:  <20040609182606.X707@korben.in.tern>
In-Reply-To: <55929.1086798000@critter.freebsd.dk>
References:  <55929.1086798000@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 9 Jun 2004, Poul-Henning Kamp wrote:

> Assume foo->refcount = 2;
>
> 	thread1 (low priority)	thread2 (high priority)
> 	----------------------	-----------------------
>
> 	...			...
> 	LOCK(foo->lock)		...
> 	i = --foo->refcount;	LOCK(foo->lock)
> 	# i == 1, refcount == 1
> 	UNLOCK(foo->lock)
> 				i = --foo->refcount;
> 				# i == 0, refcount == 0
> 				UNLOCK(foo->lock)
> 				if (i == 0) # true
> 					destroy(foo)
> 				...
>
> 	if (i == 0) # false
> 		destroy(foo)

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?

cheers,
le

-- 
Lukas Ertl                         http://homepage.univie.ac.at/l.ertl/
le@FreeBSD.org                     http://people.freebsd.org/~le/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040609182606.X707>