qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 1/2] add a header file for atomic operations


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v3 1/2] add a header file for atomic operations
Date: Thu, 20 Jun 2013 10:03:50 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6

Il 19/06/2013 22:44, Richard Henderson ha scritto:
>>> >> +        /* Data must be read atomically. We don't really need barrier 
>>> >> semantics
>>> >> +         * but it's easier to use atomic_* than roll our own. */
>>> >> +        log = atomic_xchg(from, 0);
>> > 
>> > If you really don't need any ordering guarantees / barriers here, then
>> > using a relaxed load should be fine.  But my gut feeling tells me you
>> > probably do need some barriers; either you are "re-using" another
>> > barrier (and then the comment should probably point out which), or it
>> > must be a case where it's either fine to read any value someone (else)
>> > wrote or there's no concurrent store after all.
>> > 
> There is a store here, before and after.  Read the value, store zero.
> 
> I suppose what the comment is saying is that the atomic operation doesn't need
> to be ordered with respect to the rest of the surrounding code, as the object
> being synchronized is just that one integer.

Exactly.  The items of the array can be read independently.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]