From mboxrd@z Thu Jan 1 00:00:00 1970 From: compudj@krystal.dyndns.org (Mathieu Desnoyers) Date: Fri, 12 Nov 2010 07:19:00 -0500 Subject: [ltt-dev] [PATCH 2/2] introduce uatomic_and and uatomic_or In-Reply-To: <4CDD2F69.7020407@redhat.com> References: <1289552247-18130-1-git-send-email-pbonzini@redhat.com> <1289552247-18130-3-git-send-email-pbonzini@redhat.com> <20101112120846.GB27929@Krystal> <4CDD2F69.7020407@redhat.com> Message-ID: <20101112121900.GA29642@Krystal> * Paolo Bonzini (pbonzini at redhat.com) wrote: > On 11/12/2010 01:08 PM, Mathieu Desnoyers wrote: >> * Paolo Bonzini (pbonzini at redhat.com) wrote: >>> These are useful to flip single bits. >> >> I'm trying to figure out the semantic of these operations. >> >> are they >> >> uatomic_add / uatomic_or or uatomic_add_return / uatomic_or_return ? > > They return the old value, consistently with their names (see also the > test_uatomic.c change). There are three possibilities: > > - return nothing > > - return the old value > > - return the new value > > Return nothing can be useful because it can be optimized on x86 as "lock > orl (mem), reg/imm". However, there are no other return-nothing atomic > ops in uatomic_*.h so I decided not to provide this. > > Returning the new value doesn't make sense for and/or since you cannot > revert the operation (unlike uatomic_add which can be implemented from > uatomic_add_return). How about we start by implementing uatomic_and/uatomic_or that return void, and if we ever need uatomic_return_and/uatomic_return_or (see my other mail), we add them ? Otherwise we'll be stucked with heavily synchronized operations to return a value people just don't care about. By the way, uatomic_add/uatomic_dec don't return anything. Mathieu > > So I chose the second. > > Paolo > > _______________________________________________ > ltt-dev mailing list > ltt-dev at lists.casi.polymtl.ca > http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev > -- Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com