www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/16/04:14:11

From: Laurentiu Badea <byte AT lmn DOT pub DOT ro>
Newsgroups: comp.os.msdos.djgpp
Subject: DJGPP gurus: interrupts wrappers are reentrant ?
Date: Sun, 16 Mar 1997 10:22:05 +0200
Organization: Numerical Methods Laboratory
Lines: 84
Message-ID: <332BADAD.63C7A87E@lmn.pub.ro>
NNTP-Posting-Host: heineken.lmn.pub.ro
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

This is a multi-part message in MIME format.

--------------14B331C6E4D5AA8639598AE
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

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/        |
---------------------------------------------------------------------

--------------14B331C6E4D5AA8639598AE
Content-Type: text/plain; charset=us-ascii; name="timer.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="timer.c"


#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 );
}


--------------14B331C6E4D5AA8639598AE--

- Raw text -


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