[fpc-pascal] Thread Safety of String

Michael Schnell mschnell at lumino.de
Thu Jun 5 09:37:57 CEST 2014


On 06/04/2014 08:04 PM, johanns at nacs.net wrote:
>  I would expect shortstring might be thread safe.
Only a simple write (not a modification) of processor-native types is 
inherently atomic and thus really thread save.

So I suspect that even Int64 is not thread save (in this sense) on 32 
bit CPUs: a simple write to a memory based variable is doner in two 
steps and so could be preempted by the other thread, but is on a 64 bit CPU.

A modification of course is even worse (here you can use "atomic" 
functions provided by the RTL).

Obviously a short string can't be re-written in a single instruction.

-Michael



More information about the fpc-pascal mailing list