Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!decwrl!purdue!umd5!uvaarpa!babbage!mac3n From: mac3n@babbage.acc.virginia.edu (Alex Colvin) Newsgroups: comp.sys.ibm.pc Subject: Re: interrupt handling -- more obscure details Summary: intrflag() Message-ID: <309@babbage.acc.virginia.edu> Date: 16 May 88 14:45:51 GMT References: <2045@optilink.UUCP> <539@siemens.UUCP> <2078@homxc.UUCP> <308@babbage.acc.virginia.edu> Organization: University of Virginia Lines: 27 Sorry about the spelling in that last note. Also, what I really wanted to show is how to use such a test-and-set IFLAG routine: For example: /* uninterupted read & clear long * good for counting interrupts, etc. * NOT safe against other processors */ long lreset(long *lp) { long l; /* old value */ int f; /* saved IFLAG */ f = intrflag(0); /* inhibit */ l = *lp; *lp = 0; /* read & clear */ intrflag(f); /* restore flag */ return l; } This can be called with interrupts enabled or disabled. It returns in the same state. In the meantime, it disables ("inhibits") for a while. -- INHIBIT SAVE,ON -- ... -- INHIBIT RESTORE