[fpc-devel] volatile variables

Henry Vermaak henry.vermaak at gmail.com
Tue Jun 28 16:20:57 CEST 2011


On 28/06/11 15:09, Andrew Brunner wrote:
>> Of course it is.  They issue a hardware memory barrier.  This stops the cpu
>> from reordering operations.  How do you think anything using pthreads will
>> work if they didn't?
>
> Documentation please?  If what you are saying is accurate just point
> me to the documentation?

Jonas already pointed you to it:

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_11

"Applications shall ensure that access to any memory location by more 
than one thread of control (threads or processes) is restricted such 
that no thread of control can read or modify a memory location while 
another thread of control may be modifying it."

Please note the "read or modify".  If you fail to understand this, you 
can read the source of a posix threads implementation, e.g. nptl (which 
is part of libc).

Henry



More information about the fpc-devel mailing list