summaryrefslogblamecommitdiff
path: root/src/modules/test/main.c
blob: 26ff8409efba227728d44eed9db8d0ad39965c84 (plain) (tree)
1
2
3
4
5
                       
                   
                   
 
                              
















                                                                  

 
            
                                                
 

                                                      
 
                                               
                                     

                 
#include <gc/syscall.h>
#include <gc/mem.h>
#include <stdlib.h>

void thread_cascade(void* d) {
	int n = (int)d;

	if (d == 0) {
		printk("{#} 0 cascade element started => end\n");
	} else {
		if (n < 0) {
			printk("{#} - cascade element started\n");
			n = 0 - n;
		} else {
			printk("{#} + cascade element started\n");
		}
		printk("{#} FORK + ...\n");
		thread_new(thread_cascade, (void*)(n - 1));
		printk("{#} FORK - ...\n");
		thread_new(thread_cascade, (void*)(1 - n));
		printk("{#} Thread cascade element finished.\n");
	}
}

int main() {
	printk("Hi world from test module !\n");

	printk("{1} Creating thread cascade len:1\n");
	thread_new(thread_cascade, (void*)1);

	printk("{1} Thread now sleeping...\n");
	while (1) thread_sleep(1000);
	return 0;
}