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 protect the mutual access to the counter variable (here you could use an atomic operation - provided in the FPC library - as well, this might provide better performance, but does nit seem necessary for that purpose here.

The second is used to provide the actual waiting and is only entered if the count is over the top.

-Michael

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to