LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 01-29-2012, 03:23 AM   #1
rbhsrh
LQ Newbie
 
Registered: Jan 2012
Posts: 4

Rep: Reputation: Disabled
difference between mutex_lock and mutex_lock_nested?


I was going through implementation of mutex. I have not understood when to use mutex_lock and mutex_lock_nested?

Please help me to understand the above mentioned functions.
 
Old 01-29-2012, 06:04 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Stretch (Fluxbox WM)
Posts: 1,389
Blog Entries: 52

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
You will already understand that a mutex cannot be acquired twice (because this would lead to recursion deadlock). In the kernel, the locking correctness validator can be used to check for such errors, as well as other locking errors such as inconsistent order of mutex acquisition.

Now rather than operate on individual mutex objects, the validator instead works with 'classes' of mutexes. This is because there may be thousands of mutexes all operating on the same type of object, and it is the ordering of the acquisitions of the classes that are of most relevance to validation (for example, in general we don't care which inode mutex was acquired when doing validation).

This generalization in the validator works in most cases, but there are some classes of objects where the kernel may acquire multiple mutexes from the same class, and where the ordering does matter. In order to be able to validate these, the mutex_lock_nested was added. One can define a set of subclasses of a class that represent nesting levels, and the order of locking of the subclasses can then be validated (by calling the 'nested' mutex lock with the subclass as a parameter). It is not literally a recursive lock; the nesting occurs at the semantic level, from the point of view of the validator.

Refer to lockdep-design.txt in the kernel documentation for a more detailed explanation.

Last edited by neonsignal; 01-29-2012 at 06:06 AM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
LXer: Making a Difference; Selling a Difference LXer Syndicated Linux News 0 09-23-2010 06:00 AM
shell script to find the difference betwwn two file and place the difference to other kittunot4u Linux - General 3 07-19-2010 05:26 AM
What is the Difference? SpaceCrusader Linux - General 5 07-15-2006 11:43 PM
Difference? Jongi Linux - Newbie 4 08-22-2003 03:21 AM
What is the difference? drewski *BSD 5 05-21-2003 04:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07:00 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration