> [[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]
>> I also don't like process level mutexes as there is no graceful way of
>> recovering from process/thread death on orphaned mutex lock.
> Some systems provide "ROBUST" mutex locks, these seem to do what you
> want.
Really could you give me an example?
I am using Solaris and Linux (RedHat 7.0) pthreads and solaris mutex's and
neither of them will survive process death gracefully.
If I could have a mutex that I could release in a controlled fashion that would
be fine. Which is basically my logic of talking somebody's implementation of
pthread mutexes and using the atomic user locking to do what I need to do.
However since I don't understand exactly why it works I am worried about using
it in anger. Hence my require for information.
Quote:> How does your compare and swap approach help you against processes
> dying? (Or are you now updating data this way)?
We basically I use the process identifier as the 32 bit locking value and only
that process can unlock that resource. However since its possible to check that
a process is still alive kill(pid, 0) == 0 or even pthread_kill(tid, 0) == 0 I
can in a controlled way release the lock and continue safely.
Quote:> You could also have some hybrid form of locking, a locking library
> which is implemented on top of both flock/lockf and mutexes; to acquire
> a lock, a thread needs to acquire both a process-private mutex and a file lock.
Trust me on this
lockf() is basically useless in a multi-threaded environment with many threads
accessing different locks due to its process level deadlock checking.
And in any case flock and lock suffer from the major disadvantage that they
require an active filehandle. I need thousands of locks and filehandles are
another scarce resource that I don't need to deplete/run out of.
Basically I am/have developed an ultra fast database module (using mmap()) which
is designed to allow no less than 5000 transactions per second to go through it.
I need to lock parts of the indices and that could mean anything from 1 lock to
a million.
Quote:> When the process goes away, it's file locks are released and the mutexes
> cease to exist
What I need is a graceful mutex.. Its not that I don't understand that if a
thread/process dies with a lock in place that the data is that locked area is
"suspect" but due to the nature of my database it is ok for me to wipe that
memory and stick it back onto my heap for future consumption. However due to the
rather brute force implementation of mutex's once the controlling thread is dead
there is no way I can release other threads locked on that mutex.
Ideally I would gmutex the memory blocks I require and if a thread/process died
in a lock I could then have my overseer process detect its death free off the
block and resume the entire system elegantly.
With standard mutex I would have to restart pretty much the entire system, which
from mine and what it's intended for is unrealistic.
Regards Simon
--
The idle man does not know what it is to enjoy rest.