a77e783bd6e7b3e57df11426b9e34baeeef12761
6 #include <native/task.h>
7 #include <native/timer.h>
15 RT_TASK_INFO curtaskinfo
;
18 rt_task_sleep(period
);
20 // inquire current task
21 curtask
=rt_task_self();
22 rt_task_inquire(curtask
,&curtaskinfo
);
24 // determine the period
25 int num
= *(int *)arg
;
27 rt_task_set_periodic(NULL
, TM_NOW
, period
);
30 rt_printf("Task name: %s - Period %d\n", curtaskinfo
.name
, num
);
31 rt_task_wait_period(NULL
);
35 int main(int argc
, char* argv
[])
41 rt_print_auto_init(1);
42 mlockall(MCL_CURRENT
| MCL_FUTURE
);
43 rt_printf("start task\n");
47 sprintf(str
, "hello-%d", i
);
49 rt_task_create(&demo_task
, str
, 0, 50, 0);
50 rt_task_start(&demo_task
, &demo
, &periods
[i
]);
53 rt_printf("end program by CTRL-C\n");