[comp.sys.ibm.pc] MSC 4.0 interrupt

creps@silver.bacs.indiana.edu (Steve Creps) (01/28/88)

   I'm trying to get an interrupt handler to work in MSC 4.0 that will
handle ^C's at any time. The manual isn't a lot of help, giving only
one example with the signal routine. I wrote a test program which is
basically for(i=1;i<100000;i++) if (i % 10000 == 0) fprintf("%d",i);
and it seems to work, except that it waits until it's ready to print the
next number before calling the interrupt routine. However, it does seem
as if it is storing the interrupt until output is done, and not just
waiting until the output before it even recognizes the interrupt.
My interrupt routine was something like
int interrupt()
{
	fprintf("*** int ***");
	signal(SIGINT,interrupt);
	return;
}
   I don't think it was a problem with declarations, since I'm following
the example in the manual. Anyway, that was the program that seemed to
(pretty much) work. 
   In the actual, large program I'm working on, I have things declared the
same way, but I can't get it to recognize the ^C. Actually, sometimes it
will, but only if I hit ^C and/or ^<Brk> about a hundred or more times real
fast. Even though output is being done quite a bit, it still doesn't seem
to push (or queue, whatever) the interrupt. Actually, I don't even want it
to have to wait for output to process the interrupt, but even that would be
a step in the right direction.
   By the way, I AM initializing it with signal(SIGINT, interrupt); so that's
not it.
   Any help on this would be greatly appreciated.

-	-	-	-	-	-	-	-	-
Steve Creps on the VAX 8650 running Ultrix 2.0-1 at Indiana University.
creps@silver.bacs.indiana.edu, ...iuvax!silver!creps, creps@iubacs.bitnet

loafman@convexe.UUCP (01/29/88)

/* Written  7:25 pm  Jan 27, 1988 by creps@silver.Sun.COM in convexe:comp.sys.ibm.pc */
/* ---------- "MSC 4.0 interrupt (^C) handler help" ---------- */

   I'm trying to get an interrupt handler to work in MSC 4.0 that will
handle ^C's at any time. The manual isn't a lot of help, giving only
one example with the signal routine. I wrote a test program which is
basically for(i=1;i<100000;i++) if (i % 10000 == 0) fprintf("%d",i);
and it seems to work, except that it waits until it's ready to print the
next number before calling the interrupt routine. However, it does seem
as if it is storing the interrupt until output is done, and not just
waiting until the output before it even recognizes the interrupt.

...remainder deleted...

/* End of text from convexe:comp.sys.ibm.pc */

Steve,

Your assessment is correct, MSDOS is waiting until the I/O is done (or
until the first i/o system call is done) before recognizing the
interrupt.  Until then, it is just queued (logically) into the first
keyboard buffer position.  If you want more frequent looks at the
state of Ctrl-C, then do a 'break on' in either autoexec.bat, or do
the appropriate system call.  This will cause MSDOS to look at the
state of Ctrl-C on every system call, and not just those specific to
i/o.  Basically Ctrl-C handling is polled, not interrupt driven.

There is a 'user settable' interrupt, 0x1B I think, that gets called
as soon as the keyboard handler sees the Ctrl-C.  If you write your
own interrupt routine, you could do something intelligent then, such
as setting a global flag or such.  Keep it simple though.  Keyboard
interrupt routines are hard to debug without a hardware based
debugger.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kenneth W. Loafman @ CONVEX Computer Corp, Dallas, Texas | All opinions
Voice:	  work: (214) 952-0829  home: (214) 964-1250     | are my own,
USPSnail: 1705 Coit Rd #2101, Plano, Tx 75075		 | of course.
UUCP:	  ihnp4!convex!loafman				 |        ...KWL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~