Re: Spinlocks on Uniprocessor

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

 



Hi,

Le Fri, 21 Sep 2007 17:27:17 +0530,
"Rajendra Stalekar" <rajendra.stalekar@xxxxxxxxx> a écrit :

> [rajendra stalekar] AFAIK, spinlocks anyway disable interrupts,
> however, once it gets unlocked it enables it. The reason why we call
> spin_lock_irqsave could be that , if the interrupt did comes by, it
> would be kept pending and then once it i.e. spin_lock_irqrestore , it
> will invoke the interrupt handler. 

It depends which kind of locking you need. spin_lock() and
spin_unlock() allows to take/release a spinlock, but they do not
disable interrupts. On UP, they only disable preemption (if preemption
is enabled). This is because spin_lock() and spin_unlock() only allows
to protect against mutual access from two process contexts.

On the opposite, spin_lock_irqsave() and spin_unlock_irqrestore()
disable/enable the interrupts, because they are designed to provide
mutual exclusion between process context and interrupt context.

Have a look at
http://free-electrons.com/kerneldoc/latest/DocBook/kernel-locking/index.html.

Sincerly,

Thomas
-- 
Thomas Petazzoni - thomas.petazzoni@xxxxxxxx
http://{thomas,sos,kos}.enix.org - http://www.toulibre.org
http://www.{livret,agenda}dulibre.org

--
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