Solved

lock

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

830 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