+#include <stdint.h>
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <rtdk.h>
-RT_TASK task1;
-RT_TASK task2;
-RT_TASK task3;
-RT_TASK task4;
-RT_TASK task5;
+RT_TASK task1, task2, task3;
void demo(void *arg)
{
- int num = *(int *)arg;
+ uint64_t waiting_time = *(int *)arg * 100000000;
+ rt_task_set_periodic(NULL, TM_NOW, waiting_time);
+ rt_printf("Waiting time: %d\n", waiting_time);
RT_TASK *curtask;
RT_TASK_INFO curtaskinfo;
curtask=rt_task_self();
- rt_task_inquire(curtask,&curtaskinfo);
- rt_printf("Task name: %s with num %d \n",
- curtaskinfo.name, num);
+ rt_task_inquire(curtask, &curtaskinfo);
+ while(1){
+ rt_printf("Task name: %s\n", curtaskinfo.name);
+ rt_task_wait_period(NULL);
+ }
}
int main(int argc, char* argv[])
rt_task_create(&task1, "t1", 0, 50, 0);
rt_task_create(&task2, "t2", 0, 50, 0);
rt_task_create(&task3, "t3", 0, 50, 0);
- rt_task_create(&task4, "t4", 0, 50, 0);
- rt_task_create(&task5, "t5", 0, 50, 0);
- int num1 = 42;
- int num2 = 43;
- int num3 = 44;
- int num4 = 45;
- int num5 = 46;
+ int num1 = 1;
+ int num2 = 2;
+ int num3 = 3;
rt_task_start(&task1, &demo, (void *)&num1);
rt_task_start(&task2, &demo, (void *)&num2);
rt_task_start(&task3, &demo, (void *)&num3);
- rt_task_start(&task4, &demo, (void *)&num4);
- rt_task_start(&task5, &demo, (void *)&num5);
+
+ rt_printf("end program with CRTL+C\n");
+ pause();
}