From: root Date: Fri, 11 Sep 2015 16:08:31 +0000 (+0200) Subject: works, now find out how long a jiffie is X-Git-Tag: assignment2~4 X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=23d371218ef4a688d0bf7e013be17d8c3851d7a1;p=des2015.git works, now find out how long a jiffie is --- diff --git a/mart/ex02/ex02d.c b/mart/ex02/ex02d.c index 8549055..6118113 100644 --- a/mart/ex02/ex02d.c +++ b/mart/ex02/ex02d.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -8,21 +9,21 @@ #include -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[]) @@ -34,18 +35,15 @@ 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(); }