<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-text-html" lang="x-western"> How much time to check
a semaphore and a file <br>
<blockquote cite="mid:4F397150.9010801@windstream.net" type="cite">
<br>
you still loose me... they are the same thing (to me) so there
is no difference (to me)... <br>
<br>
what, exactly, are you calling a "semaphore"? where, exactly,
does it reside? how, exactly, is it created/removed? <br>
</blockquote>
Sorry I'll be more specific. <br>
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.<br>
The resource lock has to be as fast as possible.<br>
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.<br>
No other process has to run to guarantee the atomicity of the
lock.<br>
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 <a href="http://62.166.198.202/view.php?id=12974">http://62.166.198.202/view.php?id=12974</a>
and <a href="http://62.166.198.202/view.php?id=17280">http://62.166.198.202/view.php?id=17280</a>).
To be honest I still have to re-test on Linux64.<br>
<br>
Windows:<br>
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 <br>
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.<br>
So, far so good.<br>
<br>
Linux ? <br>
I'm still looking for a solution equivalent to the Windows
mutexes.<br>
Events seem to be local to a process.<br>
Semaphores could be a solution but with Lazarus 0.9.31 on an
OpenSuse 11.4 64 bit, semaphores can only be used unnamed (<b>sem_init</b>
function is available) because function <b>sem_open</b> is not
defined, only on DARWIN OS.<br>
The problem with a file is that I don't know how to use it as a
semaphore with the above constraints.<br>
The problem looks like a token problem.<br>
<br>
Antonio.<br>
<br>
<br>
</div>
</body>
</html>