Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!rochester!rocksanne!rocksvax!martyl From: martyl@rocksvax.UUCP Newsgroups: comp.os.minix Subject: Controlling processer status -- Minix v. Xinu Message-ID: <87@rocksvax.UUCP> Date: Thu, 1-Oct-87 08:01:20 EDT Article-I.D.: rocksvax.87 Posted: Thu Oct 1 08:01:20 1987 Date-Received: Sat, 3-Oct-87 06:44:34 EDT Organization: Xerox: Henrietta, NY Lines: 56 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? Here's the code for disable/restore (real simple): ; disable interrupts and return previous flags setting procdef disable pushf cli pop ax ; to return to caller pret pend disable ; restore processor status as it was procdef restore, <> push proc_status popf ; flags are according to proc_status pret pend restore P.S. The above was written using the Aztec assembler (it has a series of macros which knows how to get at arguments. If arguments are passed in, it knows to do a push bp mov bp,sp and pret does a pop bp only if bp was pushed). marty -- marty leisner xerox corp leisner.henr@xerox.com martyl@rocksvax.uucp