[Lazarus] semaphores [solved]

Michael Schnell mschnell at lumino.de
Thu Feb 9 11:27:58 CET 2012


On 02/09/2012 10:53 AM, Antonio Fortuny wrote:
>
>
> I've made a test on Win32 and the TEventObject is blocking system wide. 
Great !

If this feature is really usable on all platforms, the documentation 
needs to be updated accordingly.

AFAIK:

System wide inter-process semaphores should be a lot slower than 
in-process inter-thread semaphores. With inter-Thread sync, for 99,99% 
of the calls, expensive OS-Calls (and thus context switches) can be avoided.

On Linux, there is FUTEX vs. MUTEX (I did a lot of research on this 
issue). Regarding Lazarus, for inter-Thread stuff (TCriticalSection and 
friends) Lazarus uses the pthread library which in fact does FUTEX (if 
available for the architecture it runs on, MUTEX otherwise). AFAIK, 
Windows also provides dedicated fast inter-thread mechanisms.

Thus it does make sense to use TCriticalSection for inter-thread stuff 
and those SyncOBJ functions, that are documented to be usable for 
inter-Process work, when necessary.

-Michael

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20120209/b19496dd/attachment-0003.html>


More information about the Lazarus mailing list