Re: InterlockedExchange And Memory Alignment
- From: "m" <m@xxx>
- Date: Wed, 20 May 2009 20:50:54 -0400
What's to be confused about? There is a Windows API that has an alignment
requirement and a set of instructions for some Intel CPUs that can execute
on arbitrary unaligned data?
The fact that on certain platforms, the API uses one of these instructions
is useful to know, and can help to code better programs, but should not
cause any confusion!
"Patogenx" <patogenx@xxxxxxxxx> wrote in message
news:6631acfa-2711-4587-8ad7-dbaf8a4095ae@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am confused that Microsoft says memory alignment is required for
InterlockedExchange however, Intel documentation says that memory
alignment is not required for LOCK. Am i missing something, or
whatever the problem?
Thanks
from Microsoft MSDN Library
Platform SDK: DLLs, Processes, and Threads InterlockedExchange
The variable pointed to by the Target parameter must be aligned on a
32-bit boundary; otherwise, this function will behave unpredictably on
multiprocessor x86 systems and any non-x86 systems.
from Intel Software Developer?s Manual;
LOCK instruction Causes the processor?s LOCK# signal to be asserted
during execution of the accompanying instruction (turns the
instruction into an atomic instruction). In a multiprocessor
environment, the LOCK# signal insures that the processor has exclusive
use of any shared memory while the signal is asserted.
The integrity of the LOCK prefix is not affected by the alignment of
the memory field. Memory locking is observed for arbitrarily
misaligned fields.
Memory Ordering in P6 and More Recent Processor Families
Locked instructions have a total order.
Software Controlled Bus Locking
The integrity of a bus lock is not affected by the alignment of the
memory field. The LOCK semantics are followed for as many bus cycles
as necessary to update the entire operand. However, it is recommend
that locked accesses be aligned on their natural boundaries for better
system performance: ?Any boundary for an 8-bit access (locked or
otherwise). ?16-bit boundary for locked word accesses. ?32-bit
boundary for locked doubleword accesses. ?64-bit boundary for locked
quadword accesses.
.
- Follow-Ups:
- Re: InterlockedExchange And Memory Alignment
- From: Pavel A.
- Re: InterlockedExchange And Memory Alignment
- References:
- InterlockedExchange And Memory Alignment
- From: Patogenx
- InterlockedExchange And Memory Alignment
- Prev by Date: Re: how to delete a file which is hold up with a different thread
- Next by Date: Re: SetSystemTimeAdjustment() on Vista
- Previous by thread: Re: InterlockedExchange And Memory Alignment
- Next by thread: Re: InterlockedExchange And Memory Alignment
- Index(es):
Relevant Pages
|