Re: inter-process mutexes
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed
On Fri, 20 Mar 2009, firstname.lastname@example.org wrote:
hmm.. that explains why there isn't a standard, but I would think that
you could have something close by deciding that you will implement your
mutex/semaphore based on something lowest common denominator like files
(which would be fine for my purposes). Scalability and multiple box
handlings could be done by relying on a SAN or other such high speed
I realize that this would be relatively slow, but it would be effective.
Using an RDBMS would be fine too.
Anyways, I'm hesitant to program anything like this if it exists, so let
me rephrase the question - is there a pragmatic, open platform that does
something like this, which is mostly free of warts and supports a large
subset of OSes?
You may want a lock manager:
There are a couple in Linux, but i can't vouch for their suitability for
your purposes. In particular, i have no idea if there's a java interface.
If you wanted to work on a single machine, and didn't need the complex
behaviour you mentioned (like being able to see where you were in the
queue), then i'd say use file locks; file locks vary a lot across systems,
but all modern OSs, including Windows, support lock semantics sufficient
to implement read/write locks between cooperating processes. A solution
using file locks would be simple, efficient and robust.
As soon as you want to go over a network, though, you're shafted. You
could do file locks on an NFS-shared volume, but i wouldn't want to rely
on it. I guess you could use the same approach on a WebDAV server, using
its file locks as mutexes.
As Mark mentioned, there's Terracotta:
Which looks a bit scary.
On Mar 20, 3:26?pm, Mark Rafn <da...@dagon.net> wrote:
I was wondering if there was a nice, standard, open, inter-process
mutex that I could grab for java (rather than needing to programming
Can't be done in pure Java - there's too much OS variation. ?You're looking at
JNI, and picking a system that works for the set of OSs you care about.
HOWEVER, this is very often the wrong granularity; almost as soon as
you've got inter-process working on the same box, you'll be asking to
synchronize across machines in a network. ?
Which leads to using even heavier-weight solutions, very often a transactional
RDBMS or something like terracotta. ?Most of the time, I'd recommend starting
with a multi-machine plan rather than coding up a multi-VM-one-machine
solution and realizing later you need to scrap it.
Big Bang. No god. Fadeout. End. -- Stephen Baxter