* [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
* Re: [Xenomai-help] High CPU Load
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
0 siblings, 1 reply; 5+ messages in thread
From: Gilles Chanteperdrix @ 2009-09-25 19:36 UTC (permalink / raw)
To: Felipe Castro; +Cc: xenomai
Felipe Castro wrote:
> 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% ....
> for(;;){}
That's why.
--
Gilles.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai-help] High CPU Load
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
0 siblings, 2 replies; 5+ messages in thread
From: Felipe Castro @ 2009-09-25 19:52 UTC (permalink / raw)
To: xenomai
[-- Attachment #1: Type: text/plain, Size: 651 bytes --]
Well , that is what i thought but i need to stop the software otherwise my
tasks will be deleted .... That's the why i put this infinite loop .... how
can i do to keep my tasks running ?
On Fri, Sep 25, 2009 at 4:36 PM, Gilles Chanteperdrix <
gilles.chanteperdrix@xenomai.org> wrote:
> Felipe Castro wrote:
> > 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% ....
>
>
> > for(;;){}
> That's why.
>
>
> --
> Gilles.
>
[-- Attachment #2: Type: text/html, Size: 1061 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai-help] High CPU Load
2009-09-25 19:52 ` Felipe Castro
@ 2009-09-25 19:56 ` Gilles Chanteperdrix
2009-09-25 19:58 ` Wolfgang Grandegger
1 sibling, 0 replies; 5+ messages in thread
From: Gilles Chanteperdrix @ 2009-09-25 19:56 UTC (permalink / raw)
To: Felipe Castro; +Cc: xenomai
Felipe Castro wrote:
> Well , that is what i thought but i need to stop the software otherwise my
> tasks will be deleted .... That's the why i put this infinite loop .... how
> can i do to keep my tasks running ?
for(;;)
pause();
For instance. Or:
while (!finished)
pause();
finished being a variable set to a non zero value by some signal handler.
--
Gilles.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai-help] High CPU Load
2009-09-25 19:52 ` Felipe Castro
2009-09-25 19:56 ` Gilles Chanteperdrix
@ 2009-09-25 19:58 ` Wolfgang Grandegger
1 sibling, 0 replies; 5+ messages in thread
From: Wolfgang Grandegger @ 2009-09-25 19:58 UTC (permalink / raw)
To: Felipe Castro; +Cc: xenomai
Felipe Castro wrote:
> Well , that is what i thought but i need to stop the software otherwise my
> tasks will be deleted .... That's the why i put this infinite loop .... how
> can i do to keep my tasks running ?
Have a look to the example programs, e.g.:
http://www.rts.uni-hannover.de/xenomai/lxr/source/examples/native/trivial-periodic.c#069
Wolfgang.
^ 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.