Hello,

I'm working on a driver for data acquisition. Since we'll be using
machines with two processors I wanted to make it SMP safe.

I have segments of code that write/read a block of bytes to/from one of
the DAC's ports. In a fashion like this:

for (i=0;i<Size;i++)
  outw(*buffer++, addr);

or

for (i=0;i<Size;i++)
  *buffer++ = inw(addr);

I some instances these kind of segments are executed in an interrupt
handler, in other instances they are not.

I read an article in
http://news.tucows.com/ext2/99/11/articles/ext2112919991.shtml (which
someone told me is not very good) that I understand to mean that there
is the possibility that more than 'Size' bytes will be writen/read, that
is, the same instruction ( say, a outw() ) may be executed twice in a
two processor system. Can this happen? This could be bad, since I need
write/read the data serially to the ports.

>From a previous communication with someone I was told that within an
interrupt handler that code is 'safe'. How is that so? How about in code
which is not part of an interrupt handler.

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

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

Thanks,
-- 
Rafael Herrera
-
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