Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

lock

Posted on 2011-02-24
4
Medium Priority
?
440 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 35

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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month13 days, 3 hours left to enroll

971 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