locking across multiple computers

  • Thread starter Thread starter Amil Hanish
  • Start date Start date
A

Amil Hanish

I have several computers that I want to synchronize access to a shared
resource. Can a semephore do this? If not, what can I use to synch access
to a shared resource...across computers?

Thanks.

Amil
 
I don't think so, no, named semaphores can be used for inter-process
communication on the same box but not across machines.

It's not recommended (for obvious reasons) but you can do a quick & dirty
lock with the file system using File.Open(<name>, FileMode.CreateNew); This
succeeds if the file doesn't exist, throws an IOException if it does. The
first machine to create the file "owns" the lock. On failure you need to
poll. The owner deletes the file when done with the critical section. Since
this isn't a true blocking lock and "blocked" processes aren't on a system
queue there is a potential for starvation if multiple machines are trying to
access the shared resource too frequently.

Better is to use some form of IPC (e.g. .NET Remoting) and establish one
machine as the resource master. All other machines make Remoting calls into
the master to obtain access to the shared resource. The master should use a
separate thread for each caller and can then block callers by waiting on an
internal semaphore that controls access to the resource.

-- TB
 
Amil said:
I have several computers that I want to synchronize access to a shared
resource. Can a semephore do this? If not, what can I use to synch access
to a shared resource...across computers?

What kind of shared resource is it and how do you access it?

Max
 
Assume it's like a smart device plugged into something; it really doesn't
matter. I'm just wanting to know if the Windows OS supports such a
mechanism. 15 years ago I could easily do this on a VAX/VMS operating
system using a cluster event flag (bit flags). I can't believe a "state of
the art" OS can't do this now :-)

Amil
 
Knowing the exact scheme would be better but I've seen something similar (an
application able to detect another instance on the network, is this similar
?).

IMO it's likely just a network broadcast at startup...
 
Simple scenario. Let's pretend I have a device like a special intelligent
fax that is attached to a network. Only one thing can be talking to it at a
time. If I have several computers that want to use the intelligent fax, I
someone how to synchronize access it to?

How?

Amil
 
Not an expert but IMO it doesn't work this way usually. All requests are
just queued for later processing. Keep in mind that because the fax device
is working doesn't mean network communication are blocked...

Depending on what you are after I would rather suggest a networking group
(or a support for the product tyou are using ?)...
 
Back
Top