Re: Lock variables between two threads
- From: "Alex Blekhman" <tkfx.REMOVE@xxxxxxxxx>
- Date: Sat, 27 Dec 2008 00:45:17 +0200
"Ben Voigt [C++ MVP]" wrote:
Yes, but can the CPU exchange single bytes with main memory (or
L2/L3 cache shared between cores), or always an entire word (or
more)? I guess the cache coherency protocol guarantees
atomicity of the read/modify/write to the cache line even with
an instruction without LOCK prefix.
Actually, you cannot use LOCK prefix with MOVx instructions. There
is limited set of instructions that can utilize LOCK prefix. Also,
according to Intel SW developer manual, reading and writing a byte
from/to memory is atomic operaton:
<quote>
7.1.1. Guaranteed Atomic Operations
The Intel386T, Intel486T, Pentium®, and P6 family processors
guarantee that the following basic memory operations will always
be carried out atomically:
.. Reading or writing a byte.
.. Reading or writing a word aligned on a 16-bit boundary.
.. Reading or writing a doubleword aligned on a 32-bit boundary.
</quote>
Alex
.
- Follow-Ups:
- Re: Lock variables between two threads
- From: Ben Voigt [C++ MVP]
- Re: Lock variables between two threads
- References:
- Lock variables between two threads
- From: Reve
- Re: Lock variables between two threads
- From: Alex Blekhman
- Re: Lock variables between two threads
- From: Reve
- Re: Lock variables between two threads
- From: Alex Blekhman
- Re: Lock variables between two threads
- From: Ben Voigt [C++ MVP]
- Re: Lock variables between two threads
- From: Alex Blekhman
- Re: Lock variables between two threads
- From: Ben Voigt [C++ MVP]
- Lock variables between two threads
- Prev by Date: Re: strncmp not a member of ''global namespace''
- Next by Date: Re: Class Inheritance vs Interface Inheritance
- Previous by thread: Re: Lock variables between two threads
- Next by thread: Re: Lock variables between two threads
- Index(es):
Relevant Pages
|