Mail Archives: djgpp/2010/03/03/05:45:21
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f
|
From: | philippe <philippe DOT meynard AT vendeeconcept DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | jitter between 2 hardware interrupt
|
Date: | Wed, 3 Mar 2010 02:25:52 -0800 (PST)
|
Organization: | http://groups.google.com
|
Lines: | 269
|
Message-ID: | <bb0fee4c-7ab5-465c-8782-9282cee3e4f1@g10g2000yqh.googlegroups.com>
|
NNTP-Posting-Host: | 80.70.37.40
|
Mime-Version: | 1.0
|
X-Trace: | posting.google.com 1267611952 20751 127.0.0.1 (3 Mar 2010 10:25:52 GMT)
|
X-Complaints-To: | groups-abuse AT google DOT com
|
NNTP-Posting-Date: | Wed, 3 Mar 2010 10:25:52 +0000 (UTC)
|
Complaints-To: | groups-abuse AT google DOT com
|
Injection-Info: | g10g2000yqh.googlegroups.com; posting-host=80.70.37.40;
|
| posting-account=YIu_DQoAAABQWWAQMU9nbFpLINHek5WR
|
User-Agent: | G2/1.0
|
X-HTTP-UserAgent: | Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR
|
| 2.0.50727; InfoPath.1; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
|
Bytes: | 7227
|
X-Original-Bytes: | 7184
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Hi, everybody.
I have a problem with the jitter between hardware interrupt. I use the
real time clock interrupt at 1024 interrupt by second. But I have
jitter between 2 interrupt. Normaly I must have 976us betwwen and i
have 310us to 1641 us occasionally. I have test on multiple PC but its
the same problem. My PC is a Celeron M at 1.6Ghz under FreeDOS without
driver launch at boot.
See my program to test it:
"
#include <dpmi.h>
#include <sys/nearptr.h>
#include <sys/farptr.h>
#include <go32.h>
#include <crt0.h>
#include <io.h>
#include <pc.h>
#include "irq.h"
typedef unsigned long long uint64;
short *ptrbasevid;
uint64
tpsinterclock,tpsinterclockmemo,tpsinterclockmin,tpsinterclockmax,passtpsinterclock;
uint64 debclock_precis,finclock_precis;
long interbcleexpl=0;
long valitexploit=0;
int testtempsbcleit(void);
int proginter0(void);
int proginter1(void);
void miseenplace(void);
int proginteritgen1ms(void);
DECL_END_OF_FUNCTION(proginteritgen1ms);
short affchaine(const char *chaine,short positvid);
short affchaine_2(const char *chaine,short positvid);
short affchiffre2(long chiff,short positvid);
short affchiffre2inch(long chiff,short positch,char *ptrch);
uint64 get_rdtsc (void);
int _crt0_startup_flags=_CRT0_FLAG_LOCK_MEMORY |
_CRT0_FLAG_NONMOVE_SBRK;
int proginter0(void)
{
outportb(0x20,0x20);
return(0);
}
static END_OF_FUNCTION(proginter0);
__dpmi_paddr addr_proginter1;
int proginter1(void)
{
return(0);
}
static END_OF_FUNCTION(proginter1);
int main(void)
{
__djgpp_nearptr_enable();
ptrbasevid=(short *)(0x0b8000 + __djgpp_conventional_base);
affchaine("depart",80);
miseenplace();
return(0);
}
void miseenplace(void)
{
int i;
outportb(0x21,0xFF);
outportb(0xA1,0xFF);
LOCK_FUNCTION(proginter0);
LOCK_FUNCTION(proginter1);
addr_proginter1.selector = _my_cs();
addr_proginter1.offset32 = (long)proginter1;
for(i=0x00;i<=0x07;i++){
__dpmi_set_protected_mode_interrupt_vector(i, &addr_proginter1);
}
_install_irq(0x08,proginter0);
_install_irq(0x09,proginter0);
_install_irq(0x0A,proginter0);
_install_irq(0x0B,proginter0);
_install_irq(0x0C,proginter0);
_install_irq(0x0D,proginter0);
_install_irq(0x0E,proginter0);
_install_irq(0x0F,proginter0);
LOCK_FUNCTION(proginteritgen1ms);
_install_irq(0x70,proginteritgen1ms);
LOCK_VARIABLE(interbcleexpl) ;
outportb(0x70,0x0b);
outportb(0x71,0x42);
outportb(0x70,0x0c);
inportb(0x71);
_install_irq(0x71,proginter0);
_install_irq(0x72,proginter0);
_install_irq(0x73,proginter0);
_install_irq(0x74,proginter0);
_install_irq(0x75,proginter0);
_install_irq(0x76,proginter0);
_install_irq(0x77,proginter0);
for(i=0x10;i<=0x30;i++){
__dpmi_set_protected_mode_interrupt_vector(i, &addr_proginter1);
}
for(i=0x32;i<=0x6F;i++){
__dpmi_set_protected_mode_interrupt_vector(i, &addr_proginter1);
}
for(i=0x78;i<=0xFF;i++){
__dpmi_set_protected_mode_interrupt_vector(i, &addr_proginter1);
}
__dpmi_set_protected_mode_interrupt_vector(0x31, &addr_proginter1);
outportb(0x21,0xFB);//irq 2 valide
outportb(0xA1,0xFE);
testtempsbcleit();
}
int testtempsbcleit(void)
{
tpsinterclockmin=0;
tpsinterclockmax=0;
interbcleexpl=0;
valitexploit=1;
passtpsinterclock=0;
while(1){
if(interbcleexpl>=500){
affchaine(" ",80);
affchiffre2((long)tpsinterclockmin/1000,80);
affchiffre2((long)tpsinterclockmax/1000,160);
interbcleexpl=0;
}
}
return(1);
}
int proginteritgen1ms(void)
{
if(valitexploit){
interbcleexpl++;
debclock_precis=get_rdtsc();
passtpsinterclock++;
if(passtpsinterclock<10000){
tpsinterclockmemo=debclock_precis;
}
else{
tpsinterclock=debclock_precis-tpsinterclockmemo;
tpsinterclockmemo=debclock_precis;
if(!tpsinterclockmin) tpsinterclockmin=tpsinterclock;
if(!tpsinterclockmax) tpsinterclockmax=tpsinterclock;
if(tpsinterclock<tpsinterclockmin) tpsinterclockmin=tpsinterclock;
if(tpsinterclock>tpsinterclockmax) tpsinterclockmax=tpsinterclock;
}
}
outportb(0x70,0x0c);
inportb(0x71);
outportb(0x20,0x20);
outportb(0xA0,0x20);
return 0;
}
END_OF_FUNCTION(proginteritgen1ms);
uint64 get_rdtsc (void)
{
register unsigned long long tsc;
__asm__ __volatile__ (
".byte 0x0F, 0x31;" // rdtsc opcode
: "=A" (tsc) );
return (tsc);
}
short affchaine(const char *chaine,short positvid)
{
return(affchaine_2(chaine,positvid));
}
short affchaine_2(const char *chaine,short positvid)
{
short *ptrvideo;
char att;
ptrvideo=ptrbasevid;
while((att=*chaine)!=0){
*(ptrvideo+positvid)=(unsigned char)att+7*256;
positvid++;
chaine++;
}
return(positvid);
}
short affchiffre2(long chiff,short positvid)
{
char chchiff[10];
short lgchiff;
lgchiff=affchiffre2inch(chiff,0,chchiff);
chchiff[lgchiff]=0;
affchaine_2(chchiff,positvid);
return(lgchiff+positvid);
}
short affchiffre2inch(long chiff,short positch,char *ptrch)
/* position |xx'''''''|*//*or position |-xx''''''|*/
{
short unite,pass;
short positchdep;
int i;
long testdiz=100000000L;
positchdep=positch;
if(chiff<0L){
chiff=-chiff;
*(ptrch+positch)='-';
positch++;
}
pass=0;
for(i=0;i<8;i++){
if(chiff>=testdiz){
unite=(short)(chiff/testdiz);
*(ptrch+positch)=unite+48;
positch++;
chiff-=unite*testdiz;
pass=1;
}
else{
if(pass){
*(ptrch+positch)=48;
positch++;
}
}
testdiz/=10L;
}
*(ptrch+positch)=chiff+48;
positch++;
return(positch-positchdep);
}
"
compile :
gcc -c testit.c -o testit.o
gcc -c irq.c -o irq.o
gcc -Wall -x assembler-with-cpp -O0 -mpentium -c irqwrap.s -o
irqwrap.o
gcc -o calibreu.exe testit.o irq.o irqwrap.o
irq.c and irq.h are the function found with allegro
gcc version 3.4.1
djgpp version 2.03
Why I have this big jitter? I expected to have 10 us maximum !
especially with a processeur to 1.6 Ghz !
suggestions?
- Raw text -