Help with SMP aware modules.

Rafael E. Herrera (raffo@neuronet.pitt.edu)
Fri, 17 Dec 1999 17:11:57 -0500


Hello,

I'm porting a driver for a DAC board from 2.0 to 2.2. Since I'm learning
kernel programming as I do this, I have some questions about how to make
this driver SMP aware.

After reading this article,
http://news.tucows.com/ext2/99/11/articles/ext2112919991.shtml, I was
left wondering about when to use the spinlocks.

A piece of code like this:

for (i=0;i<count;i++)
outb(*buf++, addr);

should be protected in all SMP instances? As in:

spin_lock(&lock);
for (i=0;i<count;i++)
outb(*buf++, addr);
spin_unlock(&lock);

How about:

for (i=0;i<count;i++)
*dest++ = inb(addr);

should a spinlock be placed here too?

Thanks.

-- 
Rafael Herrera
Laboratory for Computational Neuroscience
University of Pittsburgh
http://www.neuronet.pitt.edu/~raffo

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/