[Lazarus] thread safe

Henry Vermaak henry.vermaak at gmail.com
Tue Jun 28 12:24:01 CEST 2011


On 28/06/11 11:13, Henry Vermaak wrote:
> On 27/06/11 23:31, Andrew Brunner wrote:
>> AMD vs Intel. Kernels Linux vs Windows. The only way to make sure
>
> How does the kernel matter?
>
> Other than the cpu, compilers can also reorder instructions. You can use
> __asm__ __volatile__("": : :"memory") in c to stop gcc from screwing
> around with the order, for example. This is of course if a hardware
> memory barrier isn't necessary.
>
>> you can get code in proper order with regard to memory assignments (
>> specifically variables) is to use Interlocked methods. This is why
>> they were designed.
>
> No. You have to use memory barriers for this. Atomic operations are only
> useful for single data elements.

To add to this, on x86 the memory barrier is probably implemented with 
an atomic instruction.

Henry




More information about the Lazarus mailing list