Solved

lock

Posted on 2011-02-24
4
437 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 34

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.
Suggested Courses

623 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