On 12/30/05 9:32 AM, "Steve Garman" <realbasic at garman dot demon dot co dot
uk> wrote:
> In a message regarding Mac OS X File Interlock dated Fri, 30 Dec 2005
> 09:18:31 -0600, Ed Kleban said that ...
>
>> I need to implement a file interlock in MacOS X so that I don't have more
>> than one application.... or more than one instance of that application that
>> are running concurrently trying to open a given file at the same time. It's
>> certainly easy enough for me to create for fileToUse.xxx an interlock file
>> named fileToUse.xxx.lock and then delete that .lock file when the
>> application using fileToUse.xxx closes stops using it or quits. But I'm
>> concerned about handling the case where the application crashes.
>
> Wouldn't it be better to just use a mutex?
>
Uh... Yeah. It very well might. This is a new toy that wasn't in RB last
time I messed with such things. Very interesting. Thanks for the referral.
One concern with the Mutex, is that it appears it only works for cooperating
RB applications however. But I guess that would be true for my approach as
well... so no loss there.
The other big concern is what happens to the Mutex if the application dies?
The whole trick here is to find some mutual exclusion technique that won't
get wedged if the process that reserves the resource dies in a manner that
prevents it from releasing it. The approach I'm proposing would allow
another program that wanted to use the resource to figure out if it's safe
to conclude that the locked resource can be closed, or repaired, or whatever
and the unlocked for use.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|