Solved

lock

Posted on 2011-02-24
4
431 Views
Last Modified: 2012-05-11
I have a c executable running as daemon on linux

The code I have is:

mutex_lock
......
....
mutex_unlock


Here's the problem,
1. aplication A , enters criticla section. It does Ctrl^C before lock is released
2. application B tries to acquire lock and waits forever since the lock is never release by appln A and it was killed.

Is there a way to overcome this problem?
0
Comment
Question by:learningunix
4 Comments
 
LVL 32

Expert Comment

by:sarabande
ID: 34971126
you may have a signal_handler for ctrl-c which unlocks the mutex.

Sara
0
 
LVL 32

Accepted Solution

by:
phoffric earned 500 total points
ID: 34973374
See robust mutexes that may interest you. The option PTHREAD_MUTEX_ROBUST may handle the problem you are talking about.

Now, this isn't perfect in the most general case, but may be fine for your application. In general, there is no guarantee that the mutex will even exist by the time B gets the notification that the critical region is in an inconsistent state. Another process may come in and unmap or clobber the region.
0
 
LVL 1

Expert Comment

by:mbkirk
ID: 34975967
Like they said, depends on the environment.  The locks are not actually internal to the app?  
0
 

Author Closing Comment

by:learningunix
ID: 34976775
thx
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now