diff options
author | Alexis211 <alexis211@gmail.com> | 2010-09-10 18:46:00 +0200 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2010-09-10 18:46:00 +0200 |
commit | aba6ed4b91aff5d914be11704e34de75bfd4d003 (patch) | |
tree | 3d5cf90e9ccad09d352c6a61e90027ef552dd87f /src/library/gc/syscall.c | |
parent | 5fc3baaa17a6ffb34490bb8accb86f53ef3d6d15 (diff) | |
download | TCE-aba6ed4b91aff5d914be11704e34de75bfd4d003.tar.gz TCE-aba6ed4b91aff5d914be11704e34de75bfd4d003.zip |
Each thread has its own stack. Added simple unit tests for kmalloc,kfree
Found a bug in heap_contract (not sure) but didn't fix it.
Diffstat (limited to 'src/library/gc/syscall.c')
-rw-r--r-- | src/library/gc/syscall.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/library/gc/syscall.c b/src/library/gc/syscall.c index e7d77a0..b16881e 100644 --- a/src/library/gc/syscall.c +++ b/src/library/gc/syscall.c @@ -1,4 +1,5 @@ #include <gc/syscall.h> +#include <gc/mem.h> static int call(unsigned a, unsigned b, unsigned c, unsigned d, unsigned e, unsigned f) { unsigned ret; @@ -26,8 +27,24 @@ void printk(char* str) { call(4, (unsigned)str, 0, 0, 0, 0); } +//THREAD CREATION +struct thread_start_data { + void (*entry)(void*); + void *data; + void *stack; +}; +void thread_start(void *data) { + struct thread_start_data *tsd = data; + tsd->entry(tsd->data); + free(tsd->stack); + thread_exit(); +} void thread_new(void (*entry)(void*), void *data) { - call(5, (unsigned)entry, (unsigned)data, 0, 0, 0); + struct thread_start_data *tsd = malloc(sizeof(struct thread_start_data)); + tsd->entry = entry; + tsd->data = data; + tsd->stack = malloc(NEW_STACK_SIZE); + call(5, (unsigned)thread_start, (unsigned)tsd, (unsigned)(tsd->stack + NEW_STACK_SIZE), 0, 0); } void irq_wait(int number) { |