Re: multi-process locking
- From: Chris Friesen <cbf123@xxxxxxxxxxxxx>
- Date: Wed, 29 Aug 2007 13:14:53 -0600
Ivan Novick wrote:
locking a shared resource between multiple processes? I have seenFrom people's experience, what do you think is the best technique for
people use the file system and even some people use a oracle DB.
This is a tricky issue to handle really well.
fcntl() (aka record locks) are automatically freed if the holding process exits. This is both good and bad--it's good because someone else can take the lock, it's bad because the resource could be in a non-consistent state. If you use this type of lock, you should make sure that resource consistency is verified somehow--checksums on shared data, for instance.
Depending on your OS, you could also use process-shared pthread mutexes. These may be faster than the fcntl() locks, but will not be freed on process death, unless you also use the "robust" version.
In either case, if corruption in the shared resource is detected, you need to have some form of reinitialization strategy.
Chris
.
- Follow-Ups:
- Re: multi-process locking
- From: Rainer Weikusat
- Re: multi-process locking
- References:
- multi-process locking
- From: Ivan Novick
- multi-process locking
- Prev by Date: Re: pipes
- Next by Date: Re: pipes
- Previous by thread: Re: multi-process locking
- Next by thread: Re: multi-process locking
- Index(es):
Relevant Pages
|
|