Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Jul 2013 16:01:48 -0400
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        dumbbell@FreeBSD.org, freebsd-arch@FreeBSD.org
Subject:   Re: [PATCH] Atomic swap and test-and-set
Message-ID:  <51F96D2C.6030109@FreeBSD.org>
In-Reply-To: <20130731173247.GK4972@kib.kiev.ua>
References:  <51F81A74.4030009@FreeBSD.org> <20130731173247.GK4972@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2013-07-31 13:32:47 -0400, Konstantin Belousov wrote:
> On Tue, Jul 30, 2013 at 03:56:36PM -0400, Jung-uk Kim wrote:
>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
>> 
>> The attached patch implements atomic_swap_<type>() and 
>> atomic_testandset_<type>() for x86.  <type> is int or long ATM.
>> 
>> The semantics of each operation (in atomic(9) style):
>> 
>> atomic_swap(p, v) r = *p; *p = v; return (r);
>> 
>> atomic_testandset(p, s) v = (<type>)1 << s % (sizeof(<type>) *
>> NBBY); r = (*p & v) != 0; *p |= v; return (r);
>> 
>> Note atomic_readandclear_<type>() is now obsolete and implemented
>> as a macro around atomic_swap_<type>() where the new value v is
>> 0.
>> 
>> Please let me know if you have any objection.
> I think that the atomic.diff is fine.
> 
> You did not documented swap and testandset, which would be good to
> have in the manpage.

Sure.

> I think that constraints for all added inlines contradict the
> explicit requirement in the gcc documentation, which states that
> rmw operands should be specified using the 'same location' output
> operand for the input operand (hopefully this can be parsed).  It
> just happens so that for "m" compiler cannot do anything else then
> passing the address.
> 
> The problem is not specific to the new functions, it seems to be
> present in other functions as well, e.g. cmpset.  This probably can
> be postponed.

What a coincidence!  I was cleaning up the constraints before I read
your e-mail.  Also, I am implementing 64-bit versions for i386 and
moving atomic_cmpset_64 from pmap.h to atomic.h.

I'll post new patches when I am done.

Jung-uk Kim
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (FreeBSD)

iQEcBAEBAgAGBQJR+W0sAAoJECXpabHZMqHOaVsH/1CzPZiPfpWXQefh08wOPSMV
bF/M0UrevFKE72QnRTiB00D6aY9vfNRmpYf3oceyMoZl3iYytRfqmNCawCUwMt+E
suUrIsLNF+Kzjq5EcuZRDztAaphRUbr3CcFQFiE82nD6HE1gcsYmdj8i5e93OPgS
B9MH7mgJGbct5q5eyM6BdJJSMltbKg2JPEWTlcMIly1P5FrHablQd53iqhHIIkwx
JHWJNxcMJsv+EEd8cCHepNSODEI7XoCuiOpkm4Y7k4Ezy/82pWUVG7/WcBvzSNt1
Yxq66TxloJzPzT67bOSvqohTx+9mWX+blPBRJGhZzOloo9KG7sF9IdGoUkwcoqg=
=C2G6
-----END PGP SIGNATURE-----



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