summaryrefslogtreecommitdiff
path: root/schulung_tools/rtex/main.c
diff options
context:
space:
mode:
authorJohn Ogness <john.ogness@linutronix.de>2017-12-19 10:59:40 +0100
committerJohn Ogness <john.ogness@linutronix.de>2017-12-19 10:59:40 +0100
commit270520b4a2eac8725c8575c3180964289722e191 (patch)
treed9512cd96d0c52e14293c3f8bc19fd168ee14025 /schulung_tools/rtex/main.c
parent27209bb802048f4803d9cd9a5c2f99d613986446 (diff)
schulung_tools: add various demos and tools
Different tools have been used by various trainers as demos. Put all these into master so they are available to all trainers. ipc_pipe: ipc demo using pipes ipc_shm: ipc demo using shared memory libduma: source and instructions for compiling libduma matrix: demo of good and bad cache access mtrace: patch and infos for using mtrace with ASLR rtex: demo of handling page faults Signed-off-by: John Ogness <john.ogness@linutronix.de>
Diffstat (limited to 'schulung_tools/rtex/main.c')
-rw-r--r--schulung_tools/rtex/main.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/schulung_tools/rtex/main.c b/schulung_tools/rtex/main.c
new file mode 100644
index 0000000..a68baf4
--- /dev/null
+++ b/schulung_tools/rtex/main.c
@@ -0,0 +1,60 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+extern void timestamp(const char *msg, int val);
+extern void testfunc_malloc(void);
+extern void testfunc_deepstack(void);
+extern void setup_rt(unsigned int opts);
+
+static void usage(const char *cmd)
+{
+ printf("usage: %s [opts-bitmask]\n", cmd);
+ printf(" opts-bits:\n");
+ printf(" 0x01 = mallopt\n");
+ printf(" 0x02 = mlockall\n");
+ printf(" 0x04 = prefault-stack\n");
+ printf(" 0x08 = prefault-heap\n");
+ printf(" 0x10 = run tests\n");
+ printf("\n");
+ printf(" 0x10 = no rt tweaks + tests\n");
+ printf(" 0x1f = full rt tweaks + tests\n");
+ printf("\n");
+}
+
+int main(int argc, char *argv[])
+{
+ unsigned int i;
+
+ if (argc != 2) {
+ usage(argv[0]);
+ return 1;
+ }
+
+ if (sscanf(argv[1], "%x", &i) != 1) {
+ usage(argv[0]);
+ return 1;
+ }
+
+ printf("options: 0x%x\n", i);
+
+ timestamp("init", -1);
+
+ setup_rt(i);
+
+ timestamp("main setup", -1);
+
+ if (i & 0x10) {
+ for (i = 0; i < 4; i++) {
+ testfunc_malloc();
+ timestamp("testfunc_malloc", i);
+ }
+
+ for (i = 0; i < 4; i++) {
+ testfunc_deepstack();
+ timestamp("testfunc_deepstack", i);
+ }
+ }
+
+ return 0;
+}