why a higer priority need a long time ?

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 :slight_smile:


Please tell me how does a setprio() works!


Any help will be appreciated!

“ycao” <ycao@mail.ipp.ac.cn> wrote in news:a3inn3$al9$1@inn.qnx.com:


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 > :slight_smile:

Does the time change if you setprio() your program to the priority that it
usually would run at w/o the setprio()?

\

Cheers,
Adam

QNX Software Systems Ltd.
[ amallory@qnx.com ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>

Does the time change if you setprio() your program to the priority that it
usually would run at w/o the setprio()?

Thank you Cheers,but what is the meaning of “w/o the setprio()”?

ycao <ycao@mail.ipp.ac.cn> wrote:


:> Does the time change if you setprio() your program to the priority that it
:> usually would run at w/o the setprio()?

: Thank you Cheers,but what is the meaning of “w/o the setprio()”?

That “w/o” is short for “without.”


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems

1)When i test without a setprio(), the value of the timer is 3320us.
2)Then i add a setprio(0,29) at the begin of the program ,and the value of
the timer
is 4230us.
3)Even set a default priority --10 with a setprio(0,10) ,the value of the
timer is also 4230us.


Why a process with a high priority take a longer time than a low one
Here i mean that why the program with a setprio(0,29) takes longer time to
excute ‘for’ loops >than a program wihout a setprio().

In my opion,the program without a setprio() runs at the default priority of
10 must have the same value with the program of setprio(0,10),but that is
not the fact.

What is more ,the program with a setprio(0,29) have the same value as a
program with a setprio(0,x) ,x ranges from 2 to 29 ,including the 10.

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 set(0,x) ,that is i set
the priority two times .the value of the timer is 4127us.


BYT:My English is so poor that i can’t present the problem concisely and
clearly :slight_smile: