All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] High CPU Load
@ 2009-09-25 19:27 Felipe Castro
  2009-09-25 19:36 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 5+ messages in thread
From: Felipe Castro @ 2009-09-25 19:27 UTC (permalink / raw)
  To: xenomai

[-- Attachment #1: Type: text/plain, Size: 1939 bytes --]

Hi guys ...

I wrote a simple code just to learn how to deal with real time tasks, but
there is something wrong .....
the code is working , and my tasks running , but the processor load is to
high 98% ....

#include <stdio.h>
#include <sys/mman.h>
#include <native/task.h>
#include <native/timer.h>

void periodic_1(void *arg);
void periodic_refresh (void *arg);
void refreshScreen();

#define TASK_PRIORITY     99     //Priority
#define TASK_PRIORITY2     95     //Priority
#define TASK_MODE    0
#define TASK_STACKSIZE    0

#define TASK_PERIOD    10 * 1000000 //10ms
#define TASK_PERIOD2    1000 * 1000000 //5ms

RT_TASK td,task2;

void periodic_refresh (void *arg){
    unsigned long over;
    int err2 =
rt_task_set_periodic(NULL,TM_NOW,rt_timer_ns2ticks(TASK_PERIOD2));

    for(;;){
        err2 = rt_task_wait_period(&over);
        if(err2)break;

        }
}

void periodic_1(void *arg){

    unsigned long over1;
    int err1 =
rt_task_set_periodic(NULL,TM_NOW,rt_timer_ns2ticks(TASK_PERIOD));

        for(;;){
        err1 = rt_task_wait_period(&over1);
        if(err1)break;
    }
}

int main (int argc, char *argv[]){

    int err=0,err2=0;

    mlockall(MCL_CURRENT|MCL_FUTURE);

    err=rt_task_spawn(&td,
"serialRead",TASK_STACKSIZE,TASK_PRIORITY,TASK_MODE,&periodic_1,NULL);
    err2=rt_task_spawn(&task2,
"refresh",TASK_STACKSIZE,TASK_PRIORITY2,TASK_MODE,&periodic_refresh,NULL);

    if(!err && !err2){

                refreshScreen();
                for(;;){}
                rt_task_delete(&td);
                rt_task_delete(&task2);

    }

    return 0;
}


 void refreshScreen(void){

    system("reset");

printf("|---------------------------------------------------------------------------------------|\n");
    printf("| Xenomai
Task
|\n");

printf("|---------------------------------------------------------------------------------------|\n\n\n");
    printf("Press ctrl+c to finish ...\n");

 }

Thanks

[-- Attachment #2: Type: text/html, Size: 2427 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-09-25 19:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-25 19:27 [Xenomai-help] High CPU Load Felipe Castro
2009-09-25 19:36 ` Gilles Chanteperdrix
2009-09-25 19:52   ` Felipe Castro
2009-09-25 19:56     ` Gilles Chanteperdrix
2009-09-25 19:58     ` Wolfgang Grandegger

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.