Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.msdos.programmer > #1082

Re: 500000 cycles wasted inside interrupt routine

From "Rod Pemberton" <dont_use_email@xnohavenotit.cnm>
Newsgroups comp.os.msdos.programmer
Subject Re: 500000 cycles wasted inside interrupt routine
Date 2013-11-25 21:55 -0500
Organization Aioe.org NNTP Server
Message-ID <op.w64yev2n5zc71u@localhost> (permalink)
References <5290ac42$0$12675$91cee783@newsreader03.highway.telekom.at>

Show all headers | View raw


On Sat, 23 Nov 2013 08:23:13 -0500, Johann Klammer  
<klammerj@nospam.a1.net> wrote:

> I have been measuring interrupt times by repeatedly reading the  
> time-stamp-counter and generating a histogram of the times. Why?
> I would like to receive some bitbanged comms at 100kHz, and for
> that I need quick interrupt response times.
>

Although I do a bit of DOS programming for personal use and
have my own code to track interrupts, I'm not familiar with
how frequently certain interrupts are called or how long they
should take.

So, I was hoping Ross or Rudy etc would have more info for you.
I was also surprised to see James on c.o.m.d.

Things I would look into:
1) the code which reads the time stamps
2) DOS has an idle interrupt
3) disable ACPI and APM in BIOS (as Ross and James mentioned)

First, I'd look into #1 because there are two instructions
for that: RDTSC and RDTSCP.  The latter is to fix problems
with time loss of the former on multiple core processors.
Also, IIRC, RDTSC must be called a multiple times in series
to provide a correct reading.  It must also be called only
after a serializing instruction. There are only a handful
of serializing instructions on the x86.  They only work on
486 or 586 and later.  Some are priviledge too.  Usually,
CPUID is the most frequent instruction used to serialize.

   iret 486+
   rsm 486+ (SMM mode only)
   wbinvd 486+ (privileged)
   mov cr0 486+ (privileged)
   mov crx 586+ (privileged, no CR8, 486 is CR0 only)
   mov drx 486+ (privileged)
   lmsw 486 only (no serialization on 586+)
   cpuid 586+ (no serialization on 486)
   invd 586+ (no serialization on 486)
   invlpg 586+ (no serialization on 486)
   lgdt 586+ (no serialization on 486)
   lidt 586+ (no serialization on 486)
   ltr 586+ (no serialization on 486)
   wsrmsr 586+ (not available on 486)

So, you should have something like CPUID followed by
multiple RDTSC/RDTSCP instructions for each reading
of the timestamp.  Of course, RDTSCP is for multi-core.

Second, IIRC, DOS has an idle interrupt.  When DOS isn't
doing anything - but IS STILL WITHIN a another DOS interrupt -
it calls the DOS idle interrupt.  Are you monitoring the
DOS idle interrupt and removing the time available to it from
your counts?  If not, could this be affecting your timings?
E.g., you start counting upon entry to Int 21h and stop
at exit of Int 21h, but perhaps Int 28h was called during.

See (INT 28h):
http://www.delorie.com/djgpp/doc/rbinter/id/38/41.html

Thirdly, ACPI and APM, and perhaps even PCI BIOS calls, are
likely to switch the processor into SMM mode.  This could
cause time to be consumed while in those "hidden" BIOS routines.

Finally, I think you said this was for FreeDOS.  Have you
tried an MS-DOS, e.g., 6.22 or 7.10 (Win98/SE) too see if
the DOS being used is an issue?  Or, OpenDOS/DR-DOS, IBM DOS?
E.g., anything other than FreeDOS...


Rod Pemberton

Back to comp.os.msdos.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

500000 cycles wasted inside interrupt routine Johann Klammer <klammerj@NOSPAM.a1.net> - 2013-11-23 14:23 +0100
  Re: 500000 cycles wasted inside interrupt routine Ross Ridge <rridge@csclub.uwaterloo.ca> - 2013-11-24 13:01 -0500
    Re: 500000 cycles wasted inside interrupt routine Johann Klammer <klammerj@NOSPAM.a1.net> - 2013-11-25 13:01 +0100
  Re: 500000 cycles wasted inside interrupt routine "James Harris" <james.harris.1@gmail.com> - 2013-11-24 18:24 +0000
    Re: 500000 cycles wasted inside interrupt routine Johann Klammer <klammerj@NOSPAM.a1.net> - 2013-11-24 19:33 +0100
      Re: 500000 cycles wasted inside interrupt routine "James Harris" <james.harris.1@gmail.com> - 2013-11-24 20:21 +0000
        Re: 500000 cycles wasted inside interrupt routine Johann Klammer <klammerj@NOSPAM.a1.net> - 2013-11-24 22:45 +0100
          Re: 500000 cycles wasted inside interrupt routine "James Harris" <james.harris.1@gmail.com> - 2013-11-25 10:38 +0000
            Re: 500000 cycles wasted inside interrupt routine Johann Klammer <klammerj@NOSPAM.a1.net> - 2013-11-25 11:58 +0100
              Re: 500000 cycles wasted inside interrupt routine Johann Klammer <klammerj@NOSPAM.a1.net> - 2013-11-25 14:16 +0100
  Re: 500000 cycles wasted inside interrupt routine "Rod Pemberton" <dont_use_email@xnohavenotit.cnm> - 2013-11-25 21:55 -0500
    Re: 500000 cycles wasted inside interrupt routine Johann Klammer <klammerj@NOSPAM.a1.net> - 2013-11-26 15:01 +0100

csiph-web