Reclaiming locks

C

CJ

Hello Friends -

I've run across the following situation. I have two threads, say T1 and
T2 which access shared data - each locks a mutex before doing so.

Now I have a hard-to-find bug which means that periodically T1 gets
killed unexpectedly. But if it holds the mutex at that point, T2 blocks
for ever!

How can I get T1 to release any locks it's holding when it gets killed?
 
?

=?iso-8859-1?Q?M=E5ns_Rullg=E5rd?=

CJ said:
Hello Friends -

I've run across the following situation. I have two threads, say T1 and
T2 which access shared data - each locks a mutex before doing so.

Now I have a hard-to-find bug which means that periodically T1 gets
killed unexpectedly. But if it holds the mutex at that point, T2 blocks
for ever!

How can I get T1 to release any locks it's holding when it gets killed?

Find and fix the bug that gets it killed. Anything else will only
cause you more trouble later on.

Follow-ups set to comp.unix.programmer as this is not directly related
to the C language.
 
K

Keith Thompson

CJ said:
I've run across the following situation. I have two threads, say T1 and
T2 which access shared data - each locks a mutex before doing so.

Now I have a hard-to-find bug which means that periodically T1 gets
killed unexpectedly. But if it holds the mutex at that point, T2 blocks
for ever!

How can I get T1 to release any locks it's holding when it gets killed?

Standard C has no threads, so comp.lang.c isn't the place to ask about this.

I've redirected followups to just comp.unix.programmer (not that it
will do any good), but comp.programming.threads might also be a good
place to ask.
 
C

CJ

Find and fix the bug that gets it killed. Anything else will only
cause you more trouble later on.

I promise you, not fixing the bug is not the result of lack of will! It
basically comes down to some completely unmanageable and unpenetrable
code that we have to work with. We can basically work around the bug,
but the only problem is the dead thread keeping its locks - there must
be a solution to that?
 
D

David Schwartz

I promise you, not fixing the bug is not the result of lack of will! It
basically comes down to some completely unmanageable and unpenetrable
code that we have to work with. We can basically work around the bug,
but the only problem is the dead thread keeping its locks - there must
be a solution to that?

Run the broken code in its own process. Threads are not isolated from
each other. There is no such thing as a "dead thread", only a crashed
process.

DS
 
C

CBFalconer

CJ said:
I promise you, not fixing the bug is not the result of lack of
will! It basically comes down to some completely unmanageable
and unpenetrable code that we have to work with. We can basically
work around the bug, but the only problem is the dead thread
keeping its locks - there must be a solution to that?

I thought you had already been told this is off-topic on c.l.c,
because standard C has no threads. You need a newsgroup that deals
with your system, such as comp.unix.programmer.
 
D

David Schwartz

I promise you, not fixing the bug is not the result of lack of will! It
basically comes down to some completely unmanageable and unpenetrable
code that we have to work with. We can basically work around the bug,
but the only problem is the dead thread keeping its locks - there must
be a solution to that?

Run the broken code in its own process. Threads are not isolated from
each other. There is no such thing as a "dead thread", only a crashed
process.

DS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top