-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
+#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);
+}