Mail Archives: djgpp/2000/06/18/08:00:56
> My references indicate that you need to insert some delay after each
> OUTB (except the last). The delay must be at least 1 microsecond, to
> allow the timer device sufficient time to handle the previous request
> before the next one.
>
> More importantly, note that this code speeds up the system clock, but
> doesn't take care to install a timer interrupt handler so that the
> rest of the system sees the normal 18.2 times-per-second heartbeat.
> That means you are forcing the entire OS to work 4 times faster, which
> might indeed cause reboots if some software that sits on the timer
> interrupt chain doesn't have enough time to do its thing before the
> next timer tick strikes.
Thank you for your help, but now I have another problem.
Here is my timer program:
#include <dos.h>
#include <dpmi.h>
#include <go32.h>
#define DEBUG 1
unsigned long ticks;
unsigned factor;
unsigned countdown;
__dpmi_paddr oldtimer;
__dpmi_paddr newtimer;
void timer(void)
{
ticks++;
countdown--;
if (!countdown)
{
countdown=factor;
asm(
"pushf\n"
"lcall %0\n"
:
:"m"(oldtimer)
);
}
else
{
asm(
"int $1Ch\n"
"movb $20h,%al\n"
"outb %al,$20h\n"
);
}
asm("iret\n");
}
void inittimer(unsigned factor)
{
unsigned short rate=1193180/(18*factor);
::factor=factor;
newtimer.selector=_my_cs();
newtimer.offset32=(unsigned long)timer;
__dpmi_get_protected_mode_interrupt_vector(0x08,&oldtimer);
#ifdef DEBUG
asm("pushf\n");
timer();
#endif
__dpmi_set_protected_mode_interrupt_vector(0x08,&newtimer);
asm("cli\n");
outportb(0x43,0x36);
outportb(0x40,rate&0xFF);
outportb(0x40,rate>>8);
asm("sti\n");
}
void killtimer(void)
{
asm("cli\n");
outportb(0x43,0x36);
outportb(0x40,0);
outportb(0x40,0);
asm("sti\n");
__dpmi_set_protected_mode_interrupt_vector(0x08,&oldtimer);
}
unsigned long timeticks(void)
{
return ticks;
}
int main()
{
inittimer(4);
killtimer();
}
When I run this program, I got a message "General Protection Fault".
I tried to run this program step by step in RHIDE, it returns a message
"Program has received signal: SIGABRT, Aborted" while running the statement
asm("iret\n");
Do you know what problem ?
- Raw text -