For example, the test program below, on my 2.0.27 kernel with rt-linux
0.5 patched in, and using libc 5.4.17 on an Intel Pentium 100 with
PCI/IDE disk, shows an occasional rescheduling delay of up to 30ms.
I run the program from an X-window xterm, an the delays start showing up
if I either manipulate windows, or run an other program (like "ls -lR >
temp") that causes a lot of disk activity.
So, while I realize that this is why they call it _soft_ real-time, I'd
like to ask the following:
1) Is this normal?
2) Is there something in the 1.2.x kernel that would improve things?
3) What actually is likely causing the delays?
4) Is there anything I can do to minimize the delays?
(Yes, I realize I'm not actually making use of rt-linux here, but I
mentioned it in case it might be actually contributing to the problem)
Thanks for listening!
Larry
/*----start-----*/
#include <stdio.h>
#include <sched.h>
#include <sys/time.h>
#include <unistd.h>
struct sched_param par;
struct timeval tv;
/* This is the # of ms to tell usleep() to delay. It will get rounded up
to the next 10ms + another 10ms (see select.c in kernel/fs) */
#define USLEEP_PARM (1)
/* This is the # of ms of actual resulting delay above which or equal
to,
will trigger a printout. Here we allow 1ms of slop before printing */
#define PRINT_LEVEL (10 + 10 + 1)
int main(void)
{
long t0, t1, t2, t;
int i;
par.sched_priority = sched_get_priority_max(SCHED_FIFO);
if( sched_setscheduler(0,SCHED_FIFO,&par) == -1)
{
puts("Unable to set realtime priority");
return -1;
}
printf("Output format will be in the format:\n"
"<time in seconds from start>:<rescheduling delay in ms>\n"
"For example, \"8:37\" means that a rescheduling delay of\n"
"37ms occurred 8 seconds after the program was started.\n\n"
"Here we go!\n\n");
gettimeofday( &tv, NULL );
t0 = tv.tv_sec; /* Start time in seconds */
for( i=0; i < 20000; ++i ) /* set limit in case ^C fails for some
reason*/
{
gettimeofday( &tv, NULL );
t1 = tv.tv_sec*1000 + tv.tv_usec/1000; /* ms */
usleep(USLEEP_PARM*1000);
gettimeofday( &tv, NULL );
t2 = tv.tv_sec*1000 + tv.tv_usec/1000;
t = t2 - t1;
if( t > PRINT_LEVEL )
printf("%d:%d\n", tv.tv_sec - t0, t );
}
printf("done.\n");
return 0;
}
/*-----end------*/
-- Larry Troxler -- lt@westnet.com -- Patterson, NY USA --