473,769 Members | 4,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reclaiming locks

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?

Oct 29 '07 #1
6 1322
CJ <di*********@in valid.invalidwr ites:
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.progr ammer as this is not directly related
to the C language.

--
Måns Rullgård
ma**@mansr.com
Oct 29 '07 #2
CJ <di*********@in valid.invalidwr ites:
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.progr ammer (not that it
will do any good), but comp.programmin g.threads might also be a good
place to ask.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Oct 29 '07 #3
CJ
On 29 Oct 2007 at 21:05, Måns Rullgård wrote:
CJ <di*********@in valid.invalidwr ites:
>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.
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?

Oct 29 '07 #4
On Oct 29, 4:24 pm, CJ <diespamm...@in valid.invalidwr ote:
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

Oct 30 '07 #5
CJ wrote:
Måns Rullgård wrote:
>CJ <di*********@in valid.invalidwr ites:
>>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.

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.progr ammer.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Oct 30 '07 #6
On Oct 29, 4:24 pm, CJ <diespamm...@in valid.invalidwr ote:
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

Oct 30 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2085
by: aswinee | last post by:
I am running Microsoft SQL Server 2000 - 8.00.760 Enterprise Edition on Windows 2003 Enterprise Edition (NT 5.2 Build 3790:) I have 4CPU and 8GB of RAM. I have AWE enabled, /pae /3gb switch is on in boot.ini, In my errorlog I have noticed few times error messages as "The SQL Server cannot obtain a LOCK resource at this time. Rerun your statement when there are fewer active users or ask the system administrator to check the SQL Server lock...
17
12831
by: Dr NoName | last post by:
Help! I have a table that multiple processes must be able to write to concurrently. However, it for some reason gets locked in exclusive mode. I narrowed it down to one SQL statement + some weirdness with foreign keys. To debug this, I opened two psql sessions and typed in the sql statements manually. Here is the situation: CREATE TABLE take2
6
20627
by: John Carroll | last post by:
Is there a SQL query that can be run against a database that will give me all the details on any locks that are in place at the given time? I am interested in find the lock type and owner. Thank you, John
0
3389
by: Bruce Pullen | last post by:
DB2 v7.2 (FP7 - DB2 v7.1.0.68) on AIX 5.2.0.0. We're seeing unexpected single row (then commit) insert locking behaviour. We're seeing Applications that already hold row-level W locks in lock-wait, waiting to acquire row-level X locks. The lock-waits are behind applications that have row-level X locks on different rows (honestly). Both executing and lock-waiting applications have been granted IX table locks.
4
1912
by: Alex Callea | last post by:
Hi there, We have a web application handling thousands of requests per seconds reading sql server data which is heavily updated. We are generally experiencing no performance problems. On some occasions we get an increase of the traffic of about 15% for short periods. In this case we observe something really strange: our webserver CPU goes from about 40% usage to 100%, with memory usage keeping low (about 50%). We see at the same time...
22
18812
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4. The system is client/server, multiusers based. The MDBs are using record locking. Here is part of the code: Dim wkSpace As Workspace, db As Database Dim rstTrans As DAO.Recordset Set wkSpace = DBEngine.Workspaces(0)
0
1147
by: pigeonrandle | last post by:
Hello! Does anyone have any thoughts on the best way to go about reclaiming dormant connections? I see people using timers in examples, but their implementations vary from using a separate class to using a function within the server class. If anyone has done this successfully, i would love to hear their thoughts on the matter. As always, thanks,
1
2894
by: shenanwei | last post by:
I have db2 v8.2.5 on AIX V5.3 with all the switches on Buffer pool (DFT_MON_BUFPOOL) = ON Lock (DFT_MON_LOCK) = ON Sort (DFT_MON_SORT) = ON Statement (DFT_MON_STMT) = ON Table (DFT_MON_TABLE) = ON Timestamp (DFT_MON_TIMESTAMP) = ON Unit of work ...
7
6496
by: praveen | last post by:
Hi When does DB2 go for an IS (Intent Share) lock? IS mode is defined as a mode in which "The lock owner can read data in the locked table, but cannot update this data. Other applications can read or update the table." Why are concurrent applications allowed to update the table but the lock owner is not? In a normal SELECT query, it is observed that DB2 goes for NS (Next
0
9586
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10210
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3956
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.