(moved to fpc-other because unrelated to developing FPC)
On 30 Jun 2011, at 14:13, Andrew Brunner wrote:
It remains to be seen/decided
though, who's responsibility is it to ensure/enforce coherency?
Jonas was suggesting that the posix implementation (but he probably
meant kernel) was already doing that via CriticalSection.
There are two separate things:
a) coherency between two threads: here the programmer is responsible.
Either by using mutex primitives from a library (which take care of
the necessary memory barriers behind the scenes), or by manually
inserting the required memory barriers (in combination with spinlocks
or other atomic operations). Using atomic operations inside critical
sections is useless if the data is always accessed from within code
protected by that same mutex/critical section/... (it only makes code
slower).
b) coherency within a single thread that is moved from one core to
another core by the kernel: here the kernel is responsible, and the
programmer nor compiler has to do anything.
As Hans-Peter mentioned in earlier message in this thread: if the
kernel were not responsible for b) or if it had bugs for that
functionality, then even single threaded would regularly crash on
multi-core systems (the kernel tries to keep a single thread/process
on the same cpu for speed reasons, but threads do migrate from time to
time for various reasons).
Jonas
_______________________________________________
fpc-other maillist - fpc-other@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-other