Hi, I want to run a periodic task every 500 us and measure the
performance of the RTLinux scheduler. I've tried to do this in the
following way:
I run a RT-task as shown in the code below and print the deviation
from the previous run to /dev/rtf0. While the task is running I do
'cat /dev/rtf0 > out.hex' to gather the statistics to a file. I then
use a program to analyze this file and make a histogram
representation of the deviations.
Running the code below and "cating" the way mentioned I get the
following with no(!) other CPU load:
[Elements] 9293
[Max] 44992
[Min] -102720
[Mean] -10
[Median] 32
[Std. Deviation] 1696.32108
Low(ns) High(ns) Count(Nr)
-102720 -87948 1
-87948 -73176 0
-73176 -58404 0
-58404 -43632 0
-43632 -28860 2
-28860 -14088 4
-14088 684 7917
684 15456 1363
15456 30228 4
30228 45000 2
I think -100 us to +45 us is a bit too much error, is there any way
to improve this test?
Also when running other Linux tasks to utilize file-system, network
and CPU to the fullest extent I get the following horrible results:
[Elements] 20761
[Max] 5450688
[Min] -485152
[Mean] 1225
[Median] -32
[Std. Deviation] 66455.63542
Low(ns) High(ns) Count(Nr)
-485152 108433 20692
108433 702018 57
702018 1295603 4
1295603 1889188 3
1889188 2482773 0
2482773 3076358 3
3076358 3669943 0
3669943 4263528 1
4263528 4857113 0
4857113 5450698 1
I'm running the RT-task listed below on a 400Mhz Pentium II, 64MB RAM
#include <linux/module.h>
#include <rtl.h>
#include <time.h>
#include <pthread.h>
#include <rtl_fifo.h>
#include "structs.h"
MODULE_LICENSE("GPL");
EXPORT_NO_SYMBOLS;
#define kNrFifos 1
#define kDefaultFifoSize 1024
#define kPeriod 500000
enum {
kDataOut = 0,
kDataIn,
kCtrl
};
pthread_t thread;
static int nrFifos = -1;
static void Msg(int n)
{
long long t, prev=0;
long dt;
while(1)
{
pthread_wait_np();
t = gethrtime();
if(!prev)
{
prev=t-kPeriod;
}
dt=t - prev - kPeriod;
rtf_put(0,&dt,sizeof(dt));
prev=t;
}
}
void * start_routine(void *arg)
{
struct sched_param p;
p . sched_priority = sched_get_priority_max(SCHED_FIFO);
pthread_setschedparam (pthread_self(), SCHED_FIFO, &p);
pthread_make_periodic_np (pthread_self(), gethrtime() + kPeriod, kPeriod);
Msg(1);
return 0;
}
int init_module(void) {
long i=0;
long size;
//Create fifos
for(i = 0; i < kNrFifos; i++) {
size = rtf_create(i, kDefaultFifoSize);
if(size < 0) {
rtl_printf("Error opening fifo\n");
return size
;
}
nrFifos = i;
}
return pthread_create (&thread, NULL, start_routine, 0);
}
void cleanup_module(void) {
for(;nrFifos >= 0; nrFifos--) {
rtf_destroy(nrFifos);
}
pthread_delete_np (thread);
}
/Bishop
_______________________________________________
Rtl mailing list
[EMAIL PROTECTED]
http://www2.fsmlabs.com/mailman/listinfo.cgi/rtl