www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/21/02:56:58

From: "Anthony Q. Bachler" <cwhizard AT NOSPAM DOT sockets DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DJGPP gurus: interrupts wrappers are reentrant ?
Date: 20 Mar 1997 14:55:16 GMT
Organization: Apcad Engineering
Lines: 99
Message-ID: <01bc34b3$b02471a0$LocalHost@anthonyb>
References: <332BADAD DOT 63C7A87E AT lmn DOT pub DOT ro>
NNTP-Posting-Host: 208.16.64.196
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Try clearing the interupt enable bit of the MSW as one of the first steps
in the ISR.  This will cause the hardware to store any interupts that occur
and execute them when you reenable them.  To disable them use the CLI
assembly instruction.  To reenable them use the STI instruction.  A word of
caution, STI should be immediately followed by an IRET to prevent the
problem you are experienceing.  The problem you are having is that the
stack is being corrupted.  When you perform an STI, the processor should
hold off executing any pending interupts until after the next command.  I
know for a fact that it works this way on the 8086-80686.  On a different
processor, it may work differently.  The above details are for the intel
CPU's, but the method is the same for most others.

-- 

::-)

----------------------------------------------------------------------------
---
HTTP://vax2.rainis.net/~cwhizard/norn.htm
Home of the Sixpak of Norns.

To reply to a news posting, remove the 
anti-SPAM features from my e-mail address.


Laurentiu Badea <byte AT lmn DOT pub DOT ro> wrote in article
<332BADAD DOT 63C7A87E AT lmn DOT pub DOT ro>...
> I have a problem which those of you who are more experienced 
> in low-level stuff with DJGPP may know the answer:
> 
> My interrupt handler is designed to be "reentrant" (if another
> interrupt arrives while the current one is still served, then
> my handler just counts it), as in the attached simple program.
> Then why it hangs or keeps reporting 0 "lost irqs", at best ?
> 
> What am I missing, and how to make it work ?
> Note: the number used for the wait loop in the main prog takes
> few seconds on a P100. The other is 100 times smaller, still high
> enough to keep the loop more than 55ms.
> 
> Please help me, I'm stuck.
> Laurentiu Badea
> PS. Please email, as I don't get to read the news too often.
> -- 
> ---------------------------------------------------------------------
> | Laurentiu Badea,             byte AT lmn DOT pub DOT ro                      |
> | student at PUB,                                                   |
> | Computer Science Dept.       http://www2.lmn.pub.ro/~byte/        |
> ---------------------------------------------------------------------
> 
> #include <dpmi.h>
> 
> _go32_dpmi_seginfo go32info;
> 
> unsigned timer_ticks = 0;
> unsigned timer_irqs_lost = 0;
> int in_main_timer = 0;
> 
> void main_timer( void ){
> int i;
> disable();   /* interrupts should be have been disabled on entry anyways
*/
>         
>     if ( !in_main_timer++ ){
>         ++timer_ticks;
>         outb( 0x20, 0x20 );
>         enable();
>              /* spend some time around... so that the next irq 
>                 will arrive while we're still here */
>         for ( i = 0; i < 1000000; i++ );
>         in_main_timer = 0;
>     } else {
>         ++timer_irqs_lost;
>         ++timer_ticks;
>         outb( 0x20, 0x20 );
>         enable();
>     }
> }
> 
> void main( int argc, char **argv ){
> _go32_dpmi_seginfo info;
> int i;
>     info.pm_offset = (unsigned) main_timer;
>     info.pm_selector = _my_cs();
>     _go32_dpmi_allocate_iret_wrapper( &info );
>     _go32_dpmi_get_protected_mode_interrupt_vector( 8, &go32info );
>     _go32_dpmi_set_protected_mode_interrupt_vector( 8, &info );
> 
> /* can't use sleep() because it's based on irq 0 */
>     for ( i = 0; i < 100000000; i++ );
>     printf( "Total irqs: %lu, lost: %lu\n", timer_ticks, timer_irqs_lost
);
> 
>     _go32_dpmi_get_protected_mode_interrupt_vector( 8, &info );
>     _go32_dpmi_set_protected_mode_interrupt_vector( 8, &go32info );
>     _go32_dpmi_free_iret_wrapper( &info );
> }
> 
> 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019