ex10ab done
authorroot <root@xenomailinux.localdomain>
Thu, 1 Oct 2015 18:10:41 +0000 (20:10 +0200)
committerroot <root@xenomailinux.localdomain>
Thu, 1 Oct 2015 18:10:41 +0000 (20:10 +0200)
mart/ex10/Makefile
mart/ex10/ex10a [new file with mode: 0755]
mart/ex10/ex10a.c

index ee6cbef..c931de6 100644 (file)
@@ -3,9 +3,9 @@ LDFLAGS=$(shell xeno-config --xeno-ldflags)\
        -lnative -lrtdk -Xlinker -rpath\
        -Xlinker $(shell xeno-config --libdir)
 
-BINARIES=ex10a ex10b ex10d
+BINARIES=ex10a #ex10b ex10d
 
 all: $(BINARIES)
 
 clean:
-       $(RM) -v $(BINARIES)
+       $(RM) -v $(BINARIES) *.csv
diff --git a/mart/ex10/ex10a b/mart/ex10/ex10a
new file mode 100755 (executable)
index 0000000..74c8dfb
Binary files /dev/null and b/mart/ex10/ex10a differ
index e69de29..c0781f7 100644 (file)
@@ -0,0 +1,46 @@
+#include <stdio.h>
+#include <signal.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+#include <native/task.h>
+#include <native/timer.h>
+
+#include <rtdk.h>
+
+#define SAMPLES 10000
+RT_TASK task;
+
+RTIME times[SAMPLES];
+
+void taskf(void *arg)
+{
+       RT_TASK *curtask;
+       rt_task_set_periodic(NULL, TM_NOW, 1e5);
+
+       unsigned int i;
+       for(i = 0; i<SAMPLES; i++){
+               times[i] = rt_timer_read();     
+               rt_task_wait_period(NULL);
+       }
+       FILE *file;
+       file = fopen("ex10a.csv", "w");
+       for(i = 0; i<SAMPLES-1; i++){
+               fprintf(file, "%u\t%llu\n", i, times[i+1]-times[i]);
+       }
+       fclose(file);
+}
+
+void taskw(void *arg)
+{
+       rt_task_join(&task);
+}
+
+int main(int argc, char* argv[])
+{
+       rt_print_auto_init(1);
+       mlockall(MCL_CURRENT | MCL_FUTURE);
+       rt_task_create(&task, NULL, 0, 50, 0);
+       rt_task_start(&task, &taskf, NULL);
+       sleep(2);
+}