removed binary and ex10b
[des2015.git] / mart / ex10 / ex10a.c
1 #include <stdio.h>
2 #include <signal.h>
3 #include <unistd.h>
4 #include <sys/mman.h>
5
6 #include <native/task.h>
7 #include <native/timer.h>
8
9 #include <rtdk.h>
10
11 #define SAMPLES 10000
12 RT_TASK task;
13
14 RTIME times[SAMPLES];
15
16 void taskf(void *arg)
17 {
18 RT_TASK *curtask;
19 rt_task_set_periodic(NULL, TM_NOW, 1e5);
20
21 unsigned int i;
22 for(i = 0; i<SAMPLES; i++){
23 times[i] = rt_timer_read();
24 rt_task_wait_period(NULL);
25 }
26 FILE *file;
27 file = fopen("ex10a.csv", "w");
28 for(i = 0; i<SAMPLES-1; i++){
29 fprintf(file, "%u,%llu\n", i, times[i+1]-times[i]);
30 }
31 fclose(file);
32 }
33
34 void taskw(void *arg)
35 {
36 rt_task_join(&task);
37 }
38
39 int main(int argc, char* argv[])
40 {
41 rt_print_auto_init(1);
42 mlockall(MCL_CURRENT | MCL_FUTURE);
43 rt_task_create(&task, NULL, 0, 50, 0);
44 rt_task_start(&task, &taskf, NULL);
45 sleep(2);
46 }