28.06.2011 19:42, Hans-Peter Diettrich wrote:
Jonas Maebe schrieb:

2.) Blocking access as described in 4.11 does not address execution
order.

It does guarantee that if T1 locks the mutex, changes the value,
unlocks the mutex [...]

Can you explain please, to what "changes the value" applies?
To some variable, not explicitly named here, but not to the mutex.


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.
A mutex is usually treated as opaque. It is only used when entering/leaving critical section, not for storing any user-accessible data.


However I can imagine that some mutex derived *class* (TCriticalSection)
can have additional fields, that are inaccessible until some code
obtains the mutex (similar to TThreadList). Otherwise a mutex cannot
protect anything but itself.
It is responsibility of a programmer to ensure that all accesses to the variable in question is surrounded by proper enter/leave constructs involving some mutex. Such proper constructs are not enforced by pascal language automatically (like say in java), so mistakes are quite possible (and sometimes do happen).

Nikolai


DoDi

_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel



_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to