summaryrefslogtreecommitdiff
path: root/src/user/app/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/app/test')
-rw-r--r--src/user/app/test/Makefile6
-rw-r--r--src/user/app/test/main.c56
2 files changed, 62 insertions, 0 deletions
diff --git a/src/user/app/test/Makefile b/src/user/app/test/Makefile
new file mode 100644
index 0000000..a64af01
--- /dev/null
+++ b/src/user/app/test/Makefile
@@ -0,0 +1,6 @@
+Obj = main.o
+Out = test.elf
+
+include $(SrcPath)/user/app/common.make
+
+LDFLAGS += -Map test.map
diff --git a/src/user/app/test/main.c b/src/user/app/test/main.c
new file mode 100644
index 0000000..5940cae
--- /dev/null
+++ b/src/user/app/test/main.c
@@ -0,0 +1,56 @@
+#include <tce/syscall.h>
+
+int threads = 0;
+
+void thread_cascade(void* d) {
+ int n = (int)d;
+
+ threads ++;
+
+ if (d == 0) {
+ //printk("{#} 0 cascade element started => end\n");
+ printk("*");
+ } else {
+ if (n < 0) {
+ //printk("{#} - cascade element started\n");
+ printk("-");
+ n = 0 - n;
+ } else {
+ //printk("{#} + cascade element started\n");
+ printk("+");
+ }
+ //printk("{#} FORK + ...\n");
+ printk(">");
+ thread_new(thread_cascade, (void*)(n - 1));
+ //printk("{#} FORK - ...\n");
+ printk("<");
+ thread_new(thread_cascade, (void*)(1 - n));
+ //printk("{#} Thread cascade element finished.\n");
+ printk(".");
+ }
+
+ threads--;
+}
+
+int main(char** args) {
+ char**a;
+ if (args != 0) {
+ printk("args");
+ for (a = args; *a != 0; a++) {
+ printk(" - ");
+ printk(*a);
+ }
+ printk("\n");
+ }
+
+ printk(" -> Creating thread cascade (total 2**4 = 16 threads)\n");
+ thread_new(thread_cascade, (void*)4);
+
+ while (1) {
+ thread_sleep(100);
+ if (threads == 0) break;
+ }
+ printk("\n -> Test process exiting. Press the super key to go to the home terminal.\n");
+
+ return 0;
+}