Re: Can we hold a spin lock and call up() (on a semaphore)

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

 



Please don't do Top-Posting ! see this: http://www.caliburn.nl/topposting.html

On 2/9/06, Naveed Latif <kernelmail.naveed@xxxxxxxxx> wrote:
> Hi,
>   In Process cotext you can hold spin_lock and also you can up()..  And its
> better to use spin_lock_irqsave intead of spin_lock in process context..
>

spin_lock_irqsave is superset of all locks and can be used always, but
its better to use __semphores__ in process context as you don't need
to keep spinning to acquire lock rather can go to sleep !

Can consult "nreliable Guide To Locking" by Rusty Russell
(http://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/index.html)

>
> On 2/8/06, Hareesh Nagarajan <hareesh.nagarajan@xxxxxxxxx> wrote:
> >
> > In process context (and interrupt context, while we are at it) can we
> > hold a spin lock and call up() (on a semaphore)? Apart from the usual
> > issues pertaining with deadlocks - are we guaranteed that an up is a
> > non-blocking operation?
> >

AFAIK, up can be called while holding spin_lock as up wake_ups the
process which is/was waiting on the queue due to call of down and is
non-blocking operation ! (CMIIW)


--
Fawad Lateef

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           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