Re: recursive locks in linux

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/11/07, Gaurav Dhiman <gaurav.dhiman@xxxxxxxxxxx> wrote:



 ________________________________
 From: kernelnewbies-bounce@xxxxxxxxxxxx 代理 Rajat Jain
Sent: 4/11/2007 (水) 10:18 午前
To: pradeep singh
Cc: kernelnewbies@xxxxxxxxxxxxxxxxx
Subject: Re: recursive locks in linux




On 4/11/07, pradeep singh <2500.pradeep@xxxxxxxxx> wrote:
> Hi All,
> This may sound stupid but how can i implement a recursive lock in Linux
kernel?
> I guess Mutex  and semaphores cannot be used.
>
> Spinlocks can be i guess.
> Can somebody give me some pointers or links for this?
> Googling didn't help much.

Spinlocks, semaphores & Mutexes defnitely can't be used.

Although the RW semaphores and RW spinlocks allow recursive locking
(since multiple threads can simultaneously hold reader locks).


--------------- response from Gaurav Dhiman  starts -----------------------

Rajat read-write locks are not recursive in nature, as the same thread can
not again acquire the lock once it has already acquired the lock. There are
no recursive lock avaialble and should not be avialable, as recursive locks
lead to deadlock. When thread tries to acquire the lock for second time
recursively, it will be put on hold or spin forever waiting for the lock to
be release which the thread has itself acquired, leading it to deadlock.

regards,

Gaurav
------------------- response from Gaurav Dhiman ends --------------------


Just curious, why do you need it?

Thanks,

Rajat


>
> Thank you
>
> ~psr
>
> --
> play the game
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



AFAIK, only the BKL (big kernel lock) is spinning and recursive in
nature, but its use is discouraged. Please google to know why it
should not be used in case you dont know.
--

Regards,
Sandeep.

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux