This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: atomic accesses


On Mon, Mar 03, 2008 at 11:08:24PM -0500, Robert Dewar wrote:
> Segher Boessenkool wrote:
> >>>The Linux kernel, and probably some user-space applications and 
> >>>libraries
> >>>as well, depend on GCC guaranteeing (a variant of) the following:
> >>>	"any access to a naturally aligned scalar object in memory
> >>>	that is not a bit-field will be performed by a single machine
> >>>	instruction whenever possible"
> >>>and it seems the current compiler actually does work like this.
> >>Seems a pity to have the bit-field exception here, why is it there?
> >
> >Bit-fields will generally require a read-modify-write instruction,
> >and I don't think we actually guarantee to generate one right now.
> 
> Well if they do require more than one instruction, the rule has
> no effect ("whenever possible"). If they can be done in one
> instruction  (as on the x86), then why not require this, why
> make a special case?

Because for the consumers whether the operation is done using
a single machine instruction is uninteresting.  What matters is
if that instruction is atomic.  x86 read-modify-write instructions
aren't atomic, unless lock prefix is used (and we definitely don't
want to use lock prefix on all bitfield accesses) - it actually
means there are separate read, modify and write uops.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]