Solved

lock

Posted on 2011-02-24
4
432 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 33

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
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.

896 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

18 Experts available now in Live!

Get 1:1 Help Now