hi,
I used a multifunction Counter/Timer and digital I/O card (advantech
PCL-836) under QNX 4.25.
The program is such as follow:
#include"i86.h"
#include “stdlib.h”
#include “conio.h”
#include “string.h”
#include “math.h”
#include “stdio.h”
#include <sys/sched.h>
#define baseadd 0x200
void main()
{
unsigned int time,lowbyte,hibyte;
int i,j;
setprio(0,25);
time=0;
// initiate the timer
outp(baseadd+0x03,0x34); // 10MHZ freqency divided by 10
outp(baseadd+0x00,0x0a);
outp(baseadd+0x00,0x00);
outp(baseadd+0x12,0x02); // set inter clock
outp(baseadd+0x0b,0x30); // set operation mode 0
// set the timer
outp(baseadd+0x08,0x00);
outp(baseadd+0x08,0x00);
for(i=0;i<65500;i++)
for(j=0;j<10;j++)
{
;
}
// delay(1);
// read the timer
outp(baseadd+0x0b,0xd2);
lowbyte=inp(baseadd+0x08);
hibyte=inp(baseadd+0x08);
// stop the timer
outp(baseadd+0x0b,0x30);
hibyte=hibyte<<8;
time=hibyte|lowbyte;
time=(~time)+1;
printf("\n %d us,lowbyte:%x,hibyte:%x",(unsigned int)time,lowbyte,hibyte);
}
Using the program above, I measure the time spended on the excution of the
loops of
the 'for’part.
1.)When i test without a setprio(), the value of the timer is 3320us. Then i
add a setprio(0,29) at the begin of the program ,and the value of the timer
is 4230us.
In QNX ,priorities range from 0 for the lowest to 31 for the higest.The
default priority is 10.
Why a process with a high priority take a longer time than a low one
,furthermore in this program the gap even comes to 928us!
2)If there is one setprio() in the programe ,whatever the priprity level
you set,
the value of the timer got is almost the same.
When i add another setprio(0,29) followed the first one ,the value of the
timer is 4127us.
So you can conclude that the value of the timer depends on the amount of the
setprio() function you have used
Please tell me how does a setprio() works!
Any help will be appreciated!