[fpc-pascal] Is TFPList thread safe?

Michael Schnell mschnell at lumino.de
Mon Oct 6 11:46:49 CEST 2014


On 10/02/2014 05:03 PM, Xiangrong Fang wrote:
>
>
>
>     For Windows, critical sections are lighter-weight than mutexes.
>     Mutexes can be shared between processes, but always result in a
>     system call to the kernel which has some overhead. Critical
>     sections can only be used within one process, but have the
>     advantage that they only switch to kernel mode in the case of
>     contention.
>
>
> I only need lock WITHIN my own application, so, it seems that critical 
> sections are better.
>
So it seems that Windows in fact does a kind of FUTEX for inter-Thread 
synchronizing (as does pthredlib, that as it's name says just provides  
POSIX-operation within Threads, not between applications.)

Hence, provided TCrtiticalSections uses the Windows system DLL in 
Windows and the pthreadlib so in Linux, the resulting performance 
should  be very similar.

-Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20141006/7352dc45/attachment.html>


More information about the fpc-pascal mailing list