From: Adrien LECOINTRE <adrien20@domain.hid>
To: xenomai@xenomai.org
Subject: [Xenomai-help] Square wave jitter reduce with cpu load
Date: Fri, 22 May 2009 14:48:17 +0200 [thread overview]
Message-ID: <4A169F11.9000702@domain.hid> (raw)
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);
}
next reply other threads:[~2009-05-22 12:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-22 12:48 Adrien LECOINTRE [this message]
2009-05-22 13:06 ` [Xenomai-help] Square wave jitter reduce with cpu load Gilles Chanteperdrix
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A169F11.9000702@domain.hid \
--to=adrien20@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.