Re: [fpc-pascal] Counting semaphore for free pascal

2015-07-30 Thread Serguei TARASSOV
On 30/07/2015 12:00, fpc-pascal-requ...@lists.freepascal.org wrote: Date: Wed, 29 Jul 2015 17:05:03 +0200 From: Michael Schnell To:fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] Counting semaphore for free pascal Message-ID:<55b8eb9f.6060...@lumino.de> Content-Type: text

Re: [fpc-pascal] Counting semaphore for free pascal

2015-07-30 Thread Sven Barth
Am 30.07.2015 11:29 schrieb "Michael Schnell" : > > On 07/30/2015 10:50 AM, Michael Van Canneyt wrote: >> >> CriticalSection and TEvent derive their names from Windows OS calls, adopted by Delphi and hence by FPC. >> There is nothing FPC specific about it. >> > OK. Thanks for the clarification. > >

Re: [fpc-pascal] Counting semaphore for free pascal

2015-07-30 Thread Michael Schnell
On 07/30/2015 10:50 AM, Michael Van Canneyt wrote: CriticalSection and TEvent derive their names from Windows OS calls, adopted by Delphi and hence by FPC. There is nothing FPC specific about it. OK. Thanks for the clarification. I understand that the computer science names ate Mutex and Sema

Re: [fpc-pascal] Counting semaphore for free pascal

2015-07-30 Thread Michael Van Canneyt
On Thu, 30 Jul 2015, Michael Schnell wrote: On 07/29/2015 01:06 PM, Michael Schnell wrote: On 07/29/2015 12:35 PM, Serguei TARASSOV wrote: critical sections are not. Hmmm I suppose this is "fpc speak". Thinking about this I feel that "CriticalSection" (the official name of this function

Re: [fpc-pascal] Counting semaphore for free pascal

2015-07-30 Thread Michael Schnell
On 07/29/2015 01:06 PM, Michael Schnell wrote: On 07/29/2015 12:35 PM, Serguei TARASSOV wrote: critical sections are not. Hmmm I suppose this is "fpc speak". Thinking about this I feel that "CriticalSection" (the official name of this functionality is Mutex) and "Event" is "fpc speak". "Eve

Re: [fpc-pascal] Counting semaphore for free pascal

2015-07-29 Thread Michael Schnell
On 07/29/2015 04:47 PM, Serguei TARASSOV wrote: I see you're using two concepts of synchronization (semaphore and events) at the same time. Maybe better to separate them? It is not clear why use events to limit thread access to service. There are several implementation details a semaphore ca

Re: [fpc-pascal] Counting semaphore for free pascal

2015-07-29 Thread Serguei TARASSOV
On 29/07/2015 15:44, fpc-pascal-requ...@lists.freepascal.org wrote: Date: Wed, 29 Jul 2015 13:10:23 +0200 From: kapibara To:fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] Counting semaphore for free pascal Message-ID:<55b8b49f.1070...@aol.com> Content-Type: text/plain; charset=w

Re: [fpc-pascal] Counting semaphore for free pascal

2015-07-29 Thread Serguei TARASSOV
On 29/07/2015 15:44, fpc-pascal-requ...@lists.freepascal.org wrote: Date: Wed, 29 Jul 2015 15:16:13 +0200 From: Sven Barth To: FPC-Pascal users discussions Subject: Re: [fpc-pascal] Counting semaphore for free pascal Message-ID: Content-Type: text/plain; charset="utf-8"

Re: [fpc-pascal] Counting semaphore for free pascal

2015-07-29 Thread Sven Barth
Am 28.07.2015 20:14 schrieb "kapibara" : > > Hi there, > > A counting, or general, semaphore limits simultaneous access to a resource according to the number of permits you specify. On the other hand, a binary semaphore like a critical section limits the access to "one at a time". > > FPC doesn't s

Re: [fpc-pascal] Counting semaphore for free pascal

2015-07-29 Thread Sven Barth
Am 29.07.2015 12:36 schrieb "Serguei TARASSOV" : > > Hello, > > On 29/07/2015 12:00, fpc-pascal-requ...@lists.freepascal.org wrote: >> >> A counting, or general, semaphore limits simultaneous access to a >> resource according to the number of permits you specify. On the other >> hand, a binary sema

Re: [fpc-pascal] Counting semaphore for free pascal

2015-07-29 Thread Martin Schreiber
On Tuesday 28 July 2015 20:07:52 kapibara wrote: > > FPC doesn't seem to have a general semaphore? I recently attempted to > implement one, here is the code, plus a working Lazarus demo attached. MSEgui also has a semaphore implementation, please see sys_sem*() functions in lib/kernel/windows/mse

Re: [fpc-pascal] Counting semaphore for free pascal

2015-07-29 Thread Michael Schnell
On 07/29/2015 01:10 PM, kapibara wrote: In an application you have N number of threads and they all want to access a service. Now, for example, only five threads are allowed to have access at the same time. .. I suppose that easily can be made by two critical sections. One is used to protec

Re: [fpc-pascal] Counting semaphore for free pascal

2015-07-29 Thread kapibara
Hi all, @Serguei Thanks for your reply. What you write is probably right, but let me explain the problem. In an application you have N number of threads and they all want to access a service. Now, for example, only five threads are allowed to have access at the same time. I believe this is a

Re: [fpc-pascal] Counting semaphore for free pascal

2015-07-29 Thread Michael Schnell
On 07/29/2015 12:35 PM, Serguei TARASSOV wrote: In general, semaphores are inter-process but critical sections are not. Hmmm I suppose this is "fpc speak". The "really general" term "semaphore" denotes a kind of for synchronizing means for multiple execution streams, be that Threads or tasks

[fpc-pascal] Counting semaphore for free pascal

2015-07-29 Thread Serguei TARASSOV
Hello, On 29/07/2015 12:00, fpc-pascal-requ...@lists.freepascal.org wrote: A counting, or general, semaphore limits simultaneous access to a resource according to the number of permits you specify. On the other hand, a binary semaphore like a critical section limits the access to "one at a time"