delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/02/26/00:00:17

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: Jack Klein <jackklein AT spamcop DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Timer Interrupt ?????
Message-ID: <nl4m7ucpnt79grj0i71pfj6g82o8ffgpfd@4ax.com>
References: <60683970 DOT 0202251956 DOT 22345c04 AT posting DOT google DOT com>
X-Newsreader: Forte Agent 1.9/32.560
MIME-Version: 1.0
Lines: 52
Date: Tue, 26 Feb 2002 04:52:42 GMT
NNTP-Posting-Host: 12.76.49.42
X-Complaints-To: abuse AT worldnet DOT att DOT net
X-Trace: bgtnsc05-news.ops.worldnet.att.net 1014699162 12.76.49.42 (Tue, 26 Feb 2002 04:52:42 GMT)
NNTP-Posting-Date: Tue, 26 Feb 2002 04:52:42 GMT
Organization: AT&T Worldnet
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On 25 Feb 2002 19:56:42 -0800, kgangakhedkar AT yahoo DOT com (Kunal
Gangakhedkar) wrote in comp.os.msdos.djgpp:

> Hi there,
> 
> I'm working on a process simulator right now.
> For that purpose, I need to change the system timer granularity.
> Because, the default granularity of 54926 microsec using a standard
> 18.2Hz clock is quite high for my usage. This time interval is quite
> large for Process CPU/IO Bursts generated in our simulator.
> 
> I know there is one extern long variable "__djgpp_ticks_per_clock" or
> something like that in time.h. But this will work in only DJGPP
> Environment.
> But we're supposed to work on TC or Borland compilers.
> 
> Is there any generic way of changing the system clock granularity??
> 
> One more thing, is there any way of implementing this kinda thing in a
> portable way??
> 
> Kunal Gangakhedkar
> (kgangakhedkar AT yahoo DOT com)
> (kgangakhedkar AT softhome DOT net)

I'm doing this from memory, because it has been many, many years, so
test this to make sure I haven't had a brain fart...

It is based on the fact that the default timing is generated by
setting the 8253/8254 timer compare register to 0, effectively setting
it to the maximum 16 bit value of 65536.

So hook the timer interrupt and reprogram the timer compare register
(if you set it to 0x1000 you will get 16 * 18.2 = 291.2 interrupts per
second, 0x0100 will get 256 * 18.2 = 4659.2 interrupts per second and
so on.

To keep the DOS time accurate, initialize your own unsigned long
variable to 0.  Every time you get a timer interrupt, add the value
you programmed into the timer chip to the unsigned long value.  Every
time the sum goes past 0xffff, subtract 0x10000 and call the original
timer interrupt.

I wish I had some of the old actual source to post.

-- 
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq

- Raw text -


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