[fpc-devel] volatile variables

Michael Schnell mschnell at lumino.de
Wed Jun 29 15:07:55 CEST 2011


On 06/28/2011 06:42 PM, Hans-Peter Diettrich wrote:
>
>
> I could not find a definition of the mutex struct, to determine 
> whether it contains any user-alterable values. When "the value" is 
> declared outside the mutex struct, it will be accessible also 
> *without* locking the mutex first.
>
What do you mean by "Mutex struct". The Data structure a Mutex 
internally uses is in Kernel space and invisible to the user program. 
With appropriate archs (such as X86 and modern ARM), in fact pthreadlib 
uses FUTEX instead of MUTEX, here a data structure in user land memory 
is allocated by the library, but a user program never should access it.

When using a MUTEX or FUTEX as a critical section it protects all the 
data that only is accessed by instructions issued after doing the 
"enter" and before doing the "leave" call. So it's entirely up to the 
user program to define what data is protected.

-Michael



More information about the fpc-devel mailing list