LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-26-2005, 01:29 AM   #1
rajsun
Member
 
Registered: Mar 2005
Posts: 61

Rep: Reputation: 15
Pthread.... stuffs ... onwer of mutex


Hi all,
I m using pthread library in Linux platform using C. Is there any way to finout who is current the onwer of the mutex? If the mutex is locked by some thread.

Like : Let we have "threadA", "threadB" and "threadC". threadA locked the mutex. Now is it possible to find out the from threadC that the mutex has been locked by threadA?

Plz help me .........

Thanking U all,
With Regard
Rajesh.
 
Old 07-26-2005, 07:40 AM   #2
vladmihaisima
Member
 
Registered: Oct 2002
Location: Delft, Netherlands
Distribution: Gentoo
Posts: 196

Rep: Reputation: 33
One possible way:

Code:
lock(mutex);

lock(mutex_owner);
mutex_owner_string=current_thread;
unlock(mutex_owner);

... work

lock(mutex_owner);
mutex_owner_string=NULL;
unlock(mutex_owner);

unlock(mutext);
For query:

Code:
lock(mutex_owner);
if(mutex_owner_string!=NULL) {
   ... some work
}
unlock(mutex_owner);
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How does pthread_mutex_lock() lock mutex in pthread icoming Programming 0 12-04-2004 08:54 AM
E stuffs boolim Slackware 1 05-09-2004 02:16 PM
pthread mutex issue gauge73 Programming 6 04-20-2004 05:29 PM
Networking stuffs absolut Mandriva 2 01-30-2004 10:25 AM
What are your preferences on stuffs like.... chingasman Linux - General 3 02-01-2003 02:55 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration