All of lore.kernel.org
 help / color / mirror / Atom feed
* [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, &param) == -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

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.