🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.msdos.programmer
Article #163

Re: Keyboard interrupt conflict?(SOLUTION)

#163
From: Andrew Wang
Date: Thu, 16 Apr 1992 01:01
76 lines
3455 bytes
geeslin@vms.ocom.okstate.edu writes:

>In article <sbe4gINN2a9@agate.berkeley.edu>, andywang@crown.berkeley.edu (Andrew Wang) writes:
>> Hello,
>>     I am having a problem with keyboard interrupts crashing my
>> program.  It is a control program with a real-time hardware interrupt
>> driven at 39 hz. Everything works fine until a) the keyboard buffer
>> fills up and the computer tries to beep or b) sometimes a single keypress 
>> will cause it to crash.
>> 

>	I share your frustration!  I had the same problem with a
>	routine to do reaction times.  In it, the speaker was being
>	driven under program control and as soon as the respondent
>	pressed the key (the object of the whole routine), the 486
>	locked up.  Solution was to replace the keyboard interrupt
>	handler address with an address of my own choosing.  Then I
>	could watch for a keystroke, time it, and not let the system
>	(the buffer) see it.

>	Hope this helps!
>	R*


>-- 
>Robert H. Geeslin, Ed.D.                    | Voice (918) |  Department
>Geeslin@VMS.OCOM.OKSTATE.EDU                | 582-2681 day|      of
>doing EDucational Programming for 20 years  | 224-0065 eve|  P. and B.S.

I'd like to thank you and the several other people who had good
suggestions to help me solve this problem!!! It sure was
frustrating, but all the help allowed me to fix it.

The twist is: The computer did not crash when the keyboard handler
interrupted my interrupt handler, but when my interrupt handler interrupted
the keyboard handler! I stripped out almost everything from my interrupt
handler (except the interrupt reset stuff) and it didn't help. I moved the
outp(control8259,EOI) instruction to the and it didn't help either.

The two scenarios which caused the crash (|as explained above) are
consistent with the diagnosios above. When the keyboard buffer filled
and the keyboard interrupt beeped, my interrupt would always 
interrupt the beep and crash. Also when the keyboard interrupt was
running sometimes my interrupt would occur and cause a crash.

The solution I used (to minimize jitter in my interrupt) was:

my_timer_driven_interrupt()
{
    reset_timer();
    enable_timer_interrupt();    /* On Data Acquisition card */

    ... control routine ....


    _disable();			/* 80x86 CLI */
    outp(mask8259,0xFD & inp(mask8259));   /* enable keyboard intterrupt*/
    _enable();                  /* Now read key from keyboard */
    _disable();
    outp(mask8259,0x02 | inp(mask8259));  /* disable keybd int */
 

    outp(control8259, EOI);
}


The control interrupt cannot interrupt the keyboard interrupt.

Just now, I realize if the keyboard buffer fills up and beeps, 
my interrupt may try to re-enter itself! (It runs at 39 Hz). 
Fortunately I have a loop counter that will spit out an error message
if that occurs.

Again, thanks for everyone's input! It was most helpful!

Andrew
Technical Details
Message-ID: <sijllINNm5@agate.berkeley.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!spool.mu.edu!agate!crown.berkeley.edu!andywang
References: <sbe4gINN2a9@agate.berkeley.edu> <1992Apr13.150233.1@vms.ocom.okstate.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!spool.mu.edu!agate!crown.berkeley.edu!andywang
From: andywang@crown.berkeley.edu (Andrew Wang)
Newsgroups: alt.msdos.programmer
Subject: Re: Keyboard interrupt conflict?(SOLUTION)
Message-ID: <sijllINNm5@agate.berkeley.edu>
Date: 16 Apr 92 01:01:41 GMT
Article-I.D.: agate.sijllINNm5
References: <sbe4gINN2a9@agate.berkeley.edu> <1992Apr13.150233.1@vms.ocom.okstate.edu>
Organization: University of California, Berkeley
Lines: 76
NNTP-Posting-Host: crown.berkeley.edu