LinuxQuestions.org
Review your favorite Linux distribution.
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-11-2006, 09:22 AM   #1
rajesh_b
Member
 
Registered: Sep 2004
Location: Hyderabad.
Posts: 83

Rep: Reputation: 15
Question doubt regarding atomic_dec_and_lock kernel function


Hi,
I have a doubt regarding the function atomic_dec_and_lock.
the prototype is int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)

My doubt is whether after returning from this function we will obtain the lock irrespective of the counter value ( zero or not zero).
Or is it like that we will obtain lock only when the counter is zero.

Regards
Rajesh
 
Old 11-28-2006, 07:39 AM   #2
shvechkov
LQ Newbie
 
Registered: Nov 2006
Posts: 1

Rep: Reputation: 0
atomic_dec_and_lock will take a lock only if counter is 0

will take a lock only if counter is 0
(kernel 2.4.22) lib/dec_and_lock.c :

Code:
int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
{
        spin_lock(lock);
        if (atomic_dec_and_test(atomic))
                return 1;
        spin_unlock(lock);
        return 0;
}

Last edited by shvechkov; 11-29-2006 at 03:36 PM.
 
  


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
hash function in kernel vishalbutte Programming 11 02-26-2006 02:30 AM
How to call function in kernel vishalbutte Programming 10 02-07-2006 02:50 AM
Doubt on which architecture to choose for kernel compilation???? tuxfood Linux - Software 1 01-03-2006 10:30 AM
what does this function in mean in kernel frankli Programming 5 07-13-2004 03:34 AM
2.4.20 Kernel has a bug..no doubt bruce1271 Linux - Hardware 1 06-13-2003 02:31 PM

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

All times are GMT -5. The time now is 01:46 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