>>>>> "Rafael" == Rafael E Herrera <[EMAIL PROTECTED]> writes:

Rafael> In the last case, will something like this be OK?

Rafael> spin_lock(&lock); for (i=0;i<Size;i++) outw(*buffer++, addr);
Rafael> spin_unlock(&lock);

You are guaranteed that no other CPU will enter the same interrupt
handler while it is being run. Thus if it's only the interrupt handler
which ever accesses those registers, you don't need locks in the first
place. However if the value of 'Size' is large, you probably want to
defer it to a bottom half handler to avoid the interrupt handler
blocking the rest of the system for too long.

If there are more than one place in the code that accesses those
registers and they may try to do it in parallel on an SMP box, then
you need the locks. In parallel could for instance be the interrupt
handler and a read() function. In your case the
spin_lock()/spin_unlock() pair is fine within in the interrupt handler
since you know that it is not going to be interrupted ever. Outside
the interrupt handler you probably want to use spin_lock_irqsave() and
spin_lock_irqrestore() to avoid the function in question from being
interrupted while holding the lock.

Hope this helps.

Jes
-
Linux SMP list: FIRST see FAQ at http://www.irisa.fr/prive/dmentre/smp-howto/
To Unsubscribe: send "unsubscribe linux-smp" to [EMAIL PROTECTED]

Reply via email to