blob: 945c530817bcd94d165eb07adfd107b425a5b2f0 (
plain) (
tree)
|
|
#include <tce/syscall.h>
#include <stdlib.h>
void thread_cascade(void* d) {
int n = (int)d;
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(".");
}
}
int main() {
printk("Hi world from test module !\n");
printk(" -> Creating thread cascade (total 2**8 = 256 threads)\n");
thread_new(thread_cascade, (void*)8);
printk(" -> Main thread now sleeping... forever...\n");
while (1) {
thread_sleep(1000);
}
return 0;
}
|