Subject: Re: device driver docs / interrupts
To: None <current-users@NetBSD.ORG>
From: David Jones <>
List: current-users
Date: 02/22/1995 17:31:05
> Could some kind soul (perhaps he who claimed to be working on a
> device driver doc) email me some generals about disabling/enabling
> interrupts?  specifically: is it always best to use splXXX() or
> are there other forms like "disable_intr()" (used in isa/cy.c) which
> are better under some circumstances?  

AFAIK, the ONLY universally-supported way to deal with interrupts is spl*().

> how atomic are assignments?  can "a = 0" be interrupted?  how about
> cp = p -> foo?  

Depends on CPU and compiler.

Assuming ints, a=0 is interruptible if you are writing a longword on a non-long
boundary, and page fault when doing the second part.  Not likely in a
device driver.

cp=p->foo is definitely interruptible on a lot of machines:

  load p(FP),r0
  load foo(r0),cp

Any 2-instruction sequence is interruptible.

To be safe, assume NOTHING atomic.

We are going multiprocessor soon, no? :-)

> In the com.c driver, fairly sweeping segments of code are enclosed in
> spltty()/splx(); was this a quick and dirty thing, or a reasonable use?

Probably reasonable, if you consider the high-level architecture of Unix
device drivers reasonable.