[fpc-pascal] Multi-Threading and usage of Semaphors under FPC
graemeg at opensoft.homeip.net
Fri Sep 11 16:40:05 CEST 2009
I had a previous discussion about Semaphores. Apparently my usage of
them was not very good, because they were specific to the Linux system
and Posix. Anyway, I was told it is better to use the ThreadManager.
So how do I translate code as show below to using the FPC ThreadManager?
I can see where I can set specific information for the FPC Threadmanager
-> Semaphore compared to the code below...
if FSemaphore <> 0 then
FSemaphore := CreateSemaphore(nil, FMaxPoolSize, FMaxPoolSize, nil);
if sem_init(FSemaphore, 0, FMaxPoolSize) <> 0 then
raise Exception.Create('Failed to create the semaphore');
This is what I tried, but like I said, how to I set the min and max
if not GetThreadManager(FThreadMgr) then
raise Exception.Create('Failed to reach the FPC thread manager');
p := FThreadMgr.SemaphoreInit;
See the problem? SemaphoreInit doesn't take parameters. What am I
missing here? Sorry if this all sounds dumb, but I am not well versed
when it comes the multi-threaded programming.
- Graeme -
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
More information about the fpc-pascal