Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!genrad!decvax!ucbvax!sdcsvax!ucsdhub!hp-sdd!hplabs!hpda!hpsal2!hpcupt1!hpindda!daver From: daver@hpindda.HP.COM (Dave Richards) Newsgroups: comp.os.minix Subject: Re: Controlling processer status -- Minix v. Xinu Message-ID: <3580004@hpindda.HP.COM> Date: Sat, 3-Oct-87 18:51:10 EDT Article-I.D.: hpindda.3580004 Posted: Sat Oct 3 18:51:10 1987 Date-Received: Wed, 7-Oct-87 06:38:54 EDT References: <87@rocksvax.UUCP> Organization: Hewlett Packard, Cupertino Lines: 46 > Minix uses two routines -- lock()/restore() which saves the processor > status in a common private variable (lockvar). > If found this way of coding to often leads to problems when you want to > nest subroutines which each require the interrupts be turned off, > and you don't want to write the code assuming the low-level subroutine is > running with the interrupts turned off. > Xinu uses two subroutines -- disable()/restore(). Disable returns the > processor status and restore gets passed the new processor status -- the > psw should be stored in local memory of the calling function. > I've used variants of the lock/restore/unlock variant for several years and > have gotten bitten too many times than I care to remember. I'm going to > change all references of lock/restore to disable/restore (I just got bitten > again doing some hacking). > Any comments? I have Xinu running on a 68000 based system. I found that even disable/ restore was too limiting! I didn't like the idea of turning off my clock interrupts unnecessarily, (since some useful things get done by my clock interrupt routine). So I went to the spl() mechanisms of UNIX. In spl you specified the level of interrupt you want to disable. For example spl4() disables a set of interrupts, LAN card, tty devices while allowing clock interrupts to occur. spl7() turns off everything save the non-maskable interrupt. Like disable/restore you can do the following: s = spl4(); /* critical region */ splx(s); I plan on using this scheme in Minix, as well. The different levels will allow different interrupts (via the interrupt chip). Disable/ restore is definitely cheaper to implement on the 80*86 and for your needs may be exactly what you want. When you start looking at more than a couple interrupting devices you may find that you don't want to lock out all interrupts all the time. Just something to think about. Dave Richards HP Information Networks Division