我用Xenomai API編寫了一個無限循環的Hello World程序,如下所示: 這會很快結束。如何實時運行無限循環 - Linux?
我其實想通過latencytop
來測試這個程序的實時延遲。
如何實時運行無限循環?
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);
}