Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Jan 2012 08:39:07 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        Andrey Chernov <ache@freebsd.org>
Cc:        svn-src-head@freebsd.org, David Schultz <das@freebsd.org>, src-committers@freebsd.org, Mark Murray <markm@freebsd.org>, svn-src-all@freebsd.org
Subject:   Re: svn commit: r230230 - head/sys/dev/random
Message-ID:  <201201260839.07855.jhb@freebsd.org>
In-Reply-To: <20120126033950.GA80737@vniz.net>
References:  <E1Rny2A-000C3x-O6@groundzero.grondar.org> <20120126030305.GA80493@vniz.net> <20120126033950.GA80737@vniz.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday, January 25, 2012 10:39:50 pm Andrey Chernov wrote:
> On Thu, Jan 26, 2012 at 07:03:05AM +0400, Andrey Chernov wrote:
> > On Wed, Jan 25, 2012 at 07:16:41PM +0000, Mark Murray wrote:
> > > I thought you were going to do this as a function? It would be
> > > slightly neater to do it that way.
> > > 
> > > Looks good! Are you sure this needs no locking or volatile
> > > variables?
> > 
> > Now with function, volatile, atomic and even enum:
> 
> Sorry. Reading of state variable should be atomical too. Fixed version:

What is the purpose of the atomics?  Doing atomic_load/atomic_store
is just as racy as if you had not used atomics at all.  Should you be
using atomic_cmpset instead, e.g.:

	case ARC4_ENTER_HAVE:
		/* XXX: What does it mean for this to fail? */
		atomic_cmpset_int(&iniseed_state, ARC4_ENTER_NONE, ARC4_ENTER_HAVE);
		break;


-- 
John Baldwin



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