Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2020-08

RTL semaphore supported?

6 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sven Barth
to Ryan Joseph
Ryan Joseph wrote
Are semaphores actually supported in the RTL? I don't see they're available on macOS (compiling with trunk even). https://www.freepascal.org/docs-html/3.0.0/rtl/system/semaphoreinit.html

No, these functions where there only temporary. The RTL functionality for semaphores was only ever implemented for *nix systems, but not for Windows and was only used internally in the System unit, but even that changed some years ago, thus it was decided to remove it.

The way to go with semaphores would be to implement the Delphi compatible TSemaphore in the unit SyncObjs.

Regards,
Sven

Tomas Hajny
to Sven Barth: No, these functions where there only temporary. The RTL functionality for semaphores was…
Sven Barth wrote 13 lines
Am 13.08.2020 um 06:36 schrieb Ryan Joseph via fpc-pascal: > Are semaphores actually supported in the RTL? I don't see they're > available on macOS (compiling with trunk even). > > https://www.freepascal.org/docs-html/3.0.0/rtl/system/semaphoreinit.html No, these functions where there only temporary. The RTL functionality for semaphores was only ever implemented for *nix systems, but not for Windows and was only used internally in the System unit, but even that changed some years ago, thus it was decided to remove it. The way to go with semaphores would be to implement the Delphi compatible TSemaphore in the unit SyncObjs.

Well, there's the functionality related to events (= event semaphores) - BasicEvent* / RTLEvent*, and there's also the functionality of critical sections (*CriticalSection) which is basically a mutex semaphore. Obviously, that doesn't contradict the intention to provide the functionality in SyncObjs in Delphi compatible way.

Tomas

Nico Neumann
to Ryan Joseph: Link? I'm looking at https://www.freepascal.org/docs-html/fcl/syncobjs/index-4.html and I…

It's not implemented yet, see https://bugs.freepascal.org/view.php?id=37440. For unix systems the pthread.inc already contains the API headers for the sem_* functions (
https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/linux/pthread.inc?view=markup&sortby=file#l183) but for Mac OS X 10.4.8 the dynamic loading of sem_init needs to be implemented (
https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/darwin/pthread.inc?view=markup&sortby=file#l71) and also another way to init a semaphore.
For Windows, see
https://docs.microsoft.com/en-us/windows/win32/sync/using-semaphore-objects.

Am Do., 13. Aug. 2020 um 10:05 Uhr schrieb Ryan Joseph via fpc-pascal <

Show quoted text 21 lines
: > On Aug 13, 2020, at 12:42 PM, Sven Barth wrote: > > The way to go with semaphores would be to implement the Delphi compatible TSemaphore in the unit SyncObjs. Link? I'm looking at https://www.freepascal.org/docs-html/fcl/syncobjs/index-4.html and I don't see it. Regards, Ryan Joseph _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Sven Barth
to Ryan Joseph: Link? I'm looking at https://www.freepascal.org/docs-html/fcl/syncobjs/index-4.html and I…

Ryan Joseph via fpc-pascal schrieb am
Do., 13. Aug. 2020, 09:35:

Show quoted text 12 lines
> On Aug 13, 2020, at 12:42 PM, Sven Barth wrote: > > The way to go with semaphores would be to implement the Delphi compatible TSemaphore in the unit SyncObjs. Link? I'm looking at https://www.freepascal.org/docs-html/fcl/syncobjs/index-4.html and I don't see it.

The "would be" referred to "we still need to implement TSemaphore".

Regards,
Sven