* [Xenomai-help] Square wave jitter reduce with cpu load
@ 2009-05-22 12:48 Adrien LECOINTRE
2009-05-22 13:06 ` Gilles Chanteperdrix
0 siblings, 1 reply; 2+ messages in thread
From: Adrien LECOINTRE @ 2009-05-22 12:48 UTC (permalink / raw)
To: xenomai
Hello,
I wrote a simple program toggling a pin of the parallel port every 20
us. I observe with a scope a jitter of 4 us on my square wave. Then I
added a background cpu load task and I expected to observe a bigger
jitter but in fact the jitter becomes inferior than 1 us.
Do you have any explanation of this phenomena ? Do you think that I
missed something in my kernel configuration ?
Thanks and sorry for my english.
int main(int argc, char *argv[]) {
struct sched_param param;
param.sched_priority = 99;
if(sched_setscheduler(0, SCHED_FIFO, ¶m) == -1) {
perror("main: sched_setscheduler failed");
exit(-1);
}
mlockall(MCL_CURRENT | MCL_FUTURE);
iopl(3);
if (argc>1 && strcmp(argv[1],"square")==0)
rt_task_spawn(&square_task, "square", STACK_SIZE, 90, T_JOINABLE | T_SUSP, &square, NULL);
if (argc>2 && strcmp(argv[2],"cpu")==0)
rt_task_spawn(&load_task, "cpu_load", STACK_SIZE, 80, T_JOINABLE | T_SUSP, &cpu_load, NULL);
rt_task_resume(&square_task);
rt_task_join(&square_task);
rt_task_join(&load_task);
return 0;
}
// --s-ms-us-ns
RTIME square_period_ns = 20000llu;
// --s-ms-us-ns
RTIME cpu = 5000000000llu;
void square(void *cookie) {
rt_task_resume(&load_task);
unsigned long overrun;
rt_task_set_periodic(NULL, TM_NOW, rt_timer_ns2ticks(square_period_ns));
int i;
for (i=0;i<NB_LOOP;i++)
{
outb_p(0xFF, PORT);
rt_task_wait_period(&overrun);
outb_p(0x00, PORT);
rt_task_wait_period(&overrun);
}
rt_task_suspend(&load_task);
rt_task_delete(&load_task);
}
void cpu_load(void *cookie)
{
while(1)
rt_timer_spin(cpu);
}
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [Xenomai-help] Square wave jitter reduce with cpu load
2009-05-22 12:48 [Xenomai-help] Square wave jitter reduce with cpu load Adrien LECOINTRE
@ 2009-05-22 13:06 ` Gilles Chanteperdrix
0 siblings, 0 replies; 2+ messages in thread
From: Gilles Chanteperdrix @ 2009-05-22 13:06 UTC (permalink / raw)
To: Adrien LECOINTRE; +Cc: xenomai
Adrien LECOINTRE wrote:
> Hello,
>
> I wrote a simple program toggling a pin of the parallel port every 20
A period of 20us is preposterous, this is not what Xenomai is made for.
> us. I observe with a scope a jitter of 4 us on my square wave. Then I
> added a background cpu load task and I expected to observe a bigger
> jitter but in fact the jitter becomes inferior than 1 us.
Your cpu load task is preposterous too:
- your system remains in the Xenomai domain, which you should never do;
for Linux to work correctly, you have to let Linux run from time to time;
- your cpu load task is a short loop, so it does not have any effect on
the cache, so your square wave task remains in the cache, and when it
needs to run, there is no cache effect.
--
Gilles.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-05-22 13:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-22 12:48 [Xenomai-help] Square wave jitter reduce with cpu load Adrien LECOINTRE
2009-05-22 13:06 ` Gilles Chanteperdrix
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.