Speeding up timer

Speeding up timer

Post by ahenri » Tue, 14 Oct 2003 23:06:43

How can I speed up the timer so that my signal handler (on SIGALRM) is
called more often than the default 18.2Hz?

I have tried to reprogram the 8254 PIT, but that doesn't do anything.
Here is my code:

/* timer struct */
struct itimerval timeout;

void tickSignal()

/* set tick interrupt to 200Hz */
outportb(0x43, 0x36);
outportb(0x40, ((1193180L / 200) & 0x00ff));
outportb(0x40, (((1193180L / 200) >> 8) & 0x00ff));

/* Initialise timer structure */
timeout.it_interval.tv_sec = 0;
timeout.it_interval.tv_usec = 5000;
timeout.it_value.tv_sec = 0;
timeout.it_value.tv_usec = 5000;

__djgpp_clock_tick_interval = 5000;

signal(SIGALRM, tickSignal);
setitimer(ITIMER_REAL, &timeout, NULL);


Speeding up timer

Post by Hans-Bernh » Tue, 14 Oct 2003 23:25:11

Depends on what platform(s) your code will / must run on. Real DOS is
reasonably easy, Windows XP or anything like are quite probably
impossible to influence in this regard.

To see what's possible, maybe you should inspect Allegro.
Hans-Bernhard Broeker ( XXXX@XXXXX.COM )
Even if all the snow were burnt, ashes would remain.


Speeding up timer

Post by ahenri » Wed, 15 Oct 2003 15:54:00

I am writing this application for MS-DOS only, and I am using the
DJGPP compiler. Why does the timer not speed up when I change it? Does
the DPMI server somehow prevent the change to the PIT? And from where
is the SIGALRM signal called: from INT 08h or INT 70h?


Speeding up timer

Post by Eli Zarets » Fri, 17 Oct 2003 16:04:34

> From: XXXX@XXXXX.COM (Arne)

The SIGALRM generation code is written to raise the signal once on
each occurence of Int 8. So, if you want SIGALRM and Int 8 to operate
with two different frequencies, you will have to rewrite the itimer.c
code, or use your own customized machanism of raising SIGALRM.