I wrote a hello world program with an infinite loop with Xenomai API, as follows: This gets terminated soon.
I actually wanted to test this program's real time latency through latencytop
.
How to run an infinite loop in real time?
RT_TASK demo_task;
void demo(void *arg)
{
RT_TASK *curtask;
RT_TASK_INFO curtaskinfo;
curtask=rt_task_self();
rt_task_inquire(curtask,&curtaskinfo);
printf("Task name : %s \n", curtaskinfo.name);
//------------------ hello world --------------------
while (1)
{
printf("Hello World!\n");
}
}
int main(int argc, char* argv[])
{
char str[10];
rt_print_auto_init(1);
mlockall(MCL_CURRENT|MCL_FUTURE);
printf("start task\n");
sprintf(str,"hello");
rt_task_create(&demo_task, str, 0, 50, 0);
rt_task_start(&demo_task, &demo, 0);
}
At the bottom of main, also put an infinite loop. while(1) sleep(10000) is usually good on full-blown linux, don't know about RT-world.
What's happening is that you're spawning off a new task and then main is immediately returning after this, which exits the entire process.