How much time to check a semaphore and a file

you still loose me... they are the same thing (to me) so there is no difference (to me)...

what, exactly, are you calling a "semaphore"? where, exactly, does it reside? how, exactly, is it created/removed?
Sorry I'll be more specific.
I need to solve a lock of a resource within a system accessed simultaneously by dozens (and hundreds in a near future) of processes. More specific, those processes can be either libraries linked to a program (static and dynamic) or independent programs.
The resource lock has to be as fast as possible.
When the resource is unlocked, one and only one acquiring process can lock the resource again. I don't care about FIFO, LIFO or whatever.
No other process has to run to guarantee the atomicity of the lock.
I cannot rely on try ... except blocks because FPC versions on Win64 and Linux64 fail to keep a good control of exceptions flow (read issues http://62.166.198.202/view.php?id=12974 and http://62.166.198.202/view.php?id=17280). To be honest I still have to re-test on Linux64.

Windows:
Events are not applicable: they help to lock on a system wide basis but fail to make the lock unique because the is no lock Mutexes appear to do the job. I've made a test with a dozen of processes on the same machine and only one of them succeeds to gain control of the mutex when it becomes free. The wait function locks immediately. One process at the time gains control over the resource an all processes do their job on the resource without data mix outide the rules.
So, far so good.

Linux ?
I'm still looking for a solution equivalent to the Windows mutexes.
Events seem to be local to a process.
Semaphores could be a solution but with Lazarus 0.9.31 on an OpenSuse 11.4 64 bit, semaphores can only be used unnamed (*sem_init* function is available) because function *sem_open* is not defined, only on DARWIN OS. The problem with a file is that I don't know how to use it as a semaphore with the above constraints.
The problem looks like a token problem.

Antonio.


--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to