Semaphores removed from the rtl?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Semaphores removed from the rtl?

Anthony Walter-3
When and why were semaphores removed from the rtl?

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Semaphores removed from the rtl?

Karoly Balogh (Charlie/SGR)
Hi,

On Wed, 19 Jul 2017, Anthony Walter wrote:

> When and why were semaphores removed from the rtl?

They are removed from trunk since Sept 2016, and I think they were
deprecated for a while now, although I cannot confirm this. But what's
sure, they were only implemented and used interally for Unix. Affected
revisions:

https://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&revision=28965
https://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&revision=34542

The commit messages should explain the whys, I think.

Although the code still has some leftovers here and there, and what's
sure, they weren't deprecated with a warning period :(, although I'm not
sure they were ever intended for public use... The documentation knows
about them at least, and they were public since 2014, but I think even
back then this was debated.

Charlie
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Semaphores removed from the rtl?

Anthony Walter-3
Thanks for that bit of information Charlie. I should have searched the svn logs.

As a note to this, I am using semaphores quite a bit in SDL2 to guard against things like changes to audio banks in the ui thread and reading audio sample bits in the audio mixer thread, which SDL2 sets up whenever you play audio. There are other places where I use semaphores, but the point is SDL2 implements semaphores across all platforms and they work consistently.


It just seems to me like the concept of a semaphore has been well established in CS for decades and it's a bit weird to remove them from the rtl. They are native to all platforms (I just checked). Sure they we not used by any rtl internal functions/objects (in TThread for example), but I don't believe that should have been reason enough to get rid of them.

In other words, just because a one group of developers don't use a tool, that shouldn't dictate its removal.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Semaphores removed from the rtl?

Benjamin Jan Alexander Rosseaux-2
In reply to this post by Anthony Walter-3
You could use TPasMPSemaphore from my PasMP project ( https://github.com/BeRo1985/pasmp/ and respectively https://github.com/BeRo1985/pasmp/blob/master/src/PasMP.pas ) which is also cross-platform-capable.

On Wed, Jul 19, 2017 at 6:29 PM, Anthony Walter <[hidden email]> wrote:
Thanks for that bit of information Charlie. I should have searched the svn logs.

As a note to this, I am using semaphores quite a bit in SDL2 to guard against things like changes to audio banks in the ui thread and reading audio sample bits in the audio mixer thread, which SDL2 sets up whenever you play audio. There are other places where I use semaphores, but the point is SDL2 implements semaphores across all platforms and they work consistently.


It just seems to me like the concept of a semaphore has been well established in CS for decades and it's a bit weird to remove them from the rtl. They are native to all platforms (I just checked). Sure they we not used by any rtl internal functions/objects (in TThread for example), but I don't believe that should have been reason enough to get rid of them.

In other words, just because a one group of developers don't use a tool, that shouldn't dictate its removal.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Semaphores removed from the rtl?

Anthony Walter-3
Nah thanks, I can implement them with native functions on windows, mac, and linux easily enough and with $ifdefs. I am just surprised by the thought process involved in removing them.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Semaphores removed from the rtl?

Karoly Balogh (Charlie/SGR)
In reply to this post by Anthony Walter-3
Hi,

On Wed, 19 Jul 2017, Anthony Walter wrote:

> Thanks for that bit of information Charlie. I should have searched the
> svn logs.
>
> (...)
>
> It just seems to me like the concept of a semaphore has been well
> established in CS for decades and it's a bit weird to remove them from
> the rtl. They are native to all platforms (I just checked). Sure they we
> not used by any rtl internal functions/objects (in TThread for example),
> but I don't believe that should have been reason enough to get rid of
> them.
They weren't implemented for all platforms in our RTL. Among others, using
FPC's Semaphore functions on Windows were resulting in no-ops or Runtime
errors (probably the later, I don't have Windows at hand to verify). This
is what I mean. I'm not saying they were impossible to implement, just
that they never were implemented in FPC RTL, for any platforms except
Unices. And they were never intended to appear in the System unit public
interface either. (Sadly they have, but that's a different story.)

> In other words, just because a one group of developers don't use a tool,
> that shouldn't dictate its removal.

In this case, those tools were incomplete and unfinished. But I am not
arguing against Semaphores as a concept. You are free to implement
Semaphore-alike behavior using CriticalSections for example, which are
implemented on all platforms which support Threading in the FPC RTL.

Charlie
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Semaphores removed from the rtl?

Free Pascal - General mailing list
In reply to this post by Anthony Walter-3

Am 19.07.2017 18:45 schrieb "Anthony Walter" <[hidden email]>:
>
> Nah thanks, I can implement them with native functions on windows, mac, and linux easily enough and with $ifdefs. I am just surprised by the thought process involved in removing them.

As Charlie said, that functionality was never intended for public use and only available for a specific use case.

For cross platform use the Delphi compatible TSemaphore in the SyncObjs unit should be implemented...

Regards,
Sven


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Semaphores removed from the rtl?

Michael Schnell
In reply to this post by Anthony Walter-3



On 19.07.2017 18:29, Anthony Walter wrote:

As a note to this, I am using semaphores quite a bit in SDL2 ...
Do you use Jedi-SDL to combine fpc and SDL ?

-Michael

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Semaphores removed from the rtl?

Michael Schnell
In reply to this post by Karoly Balogh (Charlie/SGR)
On 19.07.2017 18:58, Karoly Balogh (Charlie/SGR) wrote:
> You are free to implement Semaphore-alike behavior using
> CriticalSections for example, which are implemented on all platforms
> which support Threading in the FPC RTL.

CriticalSection is the windows-name for Futex, and in Windows (10) the
appropriate Library  call in fact is a hight performance user space Mutex.

In other environments TCriticalSection is implemented by a "Mutex"
system call (supposedly because not all archs / OSes provide "Futex"),
and seemingly pthreadlib in Linux (AFAIK) is not intended to be used  
for this.

Hence, generally, CriticalSection can only be used to construct
inter-Thread Semaphores not inter-Process Semaphores.

-Michael
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Semaphores removed from the rtl?

Anthony Walter-3
In reply to this post by Michael Schnell

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Loading...