blob: e691d6f0bb784cae0196abca826725bdf37cbbb0 (
plain) (
tree)
|
|
#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("(test) args");
for (a = args; *a != 0; a++) {
printk(" - ");
printk(*a);
}
printk("\n");
}
printk("(test) Creating thread cascade (total 2**6 = 64 threads)\n");
thread_new(thread_cascade, (void*)6);
while (1) {
thread_sleep(100);
if (threads == 0) break;
}
printk("\n(test) Test process exiting. Press the super key to go to the home terminal.\n");
return 0;
}
|