Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On x86 if [mem] is not 32-bit aligned, can "lock inc [mem]" still work fine?

On x86, if mem is 32-bit aligned, the mov operation is guaranteed to be atomic.

if [mem] is not 32-bit aligned, can lock inc [mem] sill work fine?

work fine:provide atomicity and not get partial value.

like image 932
Vince Avatar asked Jul 26 '12 05:07

Vince


1 Answers

The Intel Instruction Set Reference for x86 and x64 mentions nothing about alignment requirements for the INC instruction. All it says in reference to LOCK is:

This instruction can be used with a LOCK prefix to allow the instruction to be executed atomically.

The LOCK prefix documentation states:

The integrity of the LOCK prefix is not affected by the alignment of the memory field. Memory locking is observed for arbitrarily misaligned fields.

like image 132
Jonathon Reinhart Avatar answered Sep 28 '22 11:09

Jonathon Reinhart