spin_lock doesn't work?!?

Wolfgang Reissnegger wolfgang.reissnegger at xilinx.com
Fri Aug 31 01:36:49 EST 2007


Hi Melinda,

I agree with Josh, you should use spin_lock_irqsave(), especially in
your ioctl() routine. spin_lock_irqsave will not compile into a no-op,
even on a single processor machine and will at least disable interrupts.
On SMP machines they will also spin.

Depending on the type of access of the variables in your ioctl()
routine, you might want to consider using read/write spin-locks.

It is not wrong to use spin_locks the way use want to use them.
spin_locks are the right tool to protect a short section in your code.

Cheers,
   Wolfgang

melinda develey wrote:
> 
>     >You should still put the spin_lock calls into your code because >you
>     >never know if someone else will compile it and for another >target. If
>     >someone would, for example, compile the same code for a SMP
>     >machine then
>     >the spin_lock will actually lock.
>     I used the spinlock both in an interrupt handler to protect a group
>     of variables (because in an interrupt I can't use a semaphore) and
>     the same spinlock in a ioctl handler where the same group of
>     variables is accessed. Is this wrong? I have a 2.6.19.2 linux kernel.
>      
>     Thank you,
>     Melinda.
>      
>      
>      
> 
> ------------------------------------------------------------------------
> Ready for the edge of your seat? Check out tonight's top picks
> <http://us.rd.yahoo.com/evt=48220/*http://tv.yahoo.com/> on Yahoo! TV.



More information about the Linuxppc-embedded mailing list