Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming.threads > #4042
| Newsgroups | comp.programming.threads |
|---|---|
| Date | 2018-02-02 13:16 -0800 |
| References | <57vcfv$s6v@stratus.skypoint.net>#1/1> |
| Message-ID | <8aa2d575-75b9-4bbd-aa75-4dc9605931d2@googlegroups.com> (permalink) |
| Subject | Re: Detecting mutexes owned by dead processes |
| From | gee.akyol@gmail.com |
I have my own lock solution which solves this problem but with some extra work and ONLY for write locking. This is so since my structure stores only the last writer pid & thread in the structure. Unfortunately, since read locks are granted to multiple threads and since I do not store all the threads which have so far acquired the read lock, the mechanism protects only against write locks. If one was to also add code to maintain the entire list of reader threads, it would also work for reader crashes too but that would make the lock object quite complicated. I have a mutex and a bunch of counters & thread ids which are in my own private lock structure. When a read or write lock is requested, the code checks whether there is currently a write lock already granted. If so, AND the pid/thread which currently has the write lock is NOT the same as the requesting pid/thread, there and then a quick check is made using the pid/thread id of the current writer to see if it is alive. If so, no problem, the write lock is not granted. But if the pid/thread has already died, then the lock is granted to the new requester. Basically, what is being done is detecting whether a pid/thread is alive only at the instance when another pid/thread requests the write lock. This limits the liveness checking to be done only when the locks are required and is not important any other times. As I said at the beginning, since write lock is granted only to one thread at a time, it is easy to do. If it is required that "dead" threads be also detected when readers are involved, a list of readers have to be maintained. So make sure you crash only when u have the write lock & not the read lock :-)
Back to comp.programming.threads | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Detecting mutexes owned by dead processes gee.akyol@gmail.com - 2018-02-02 13:16 -0800 Re: Detecting mutexes owned by dead processes Kaz Kylheku <217-679-0842@kylheku.com> - 2018-02-02 23:47 +0000 Re: Detecting mutexes owned by dead processes Steve Watt <steve.removethis@Watt.COM> - 2018-02-06 00:23 +0000
csiph-web