X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fkern%2Fproc.c;h=c422e729c6912963f51bfcd89f75a7cee269e290;hb=ae8a609173e4490fd03875f96e388038053b9288;hp=794918a54447f1f4a85dcfc78d1c6119ba729cc8;hpb=32d1445272120a254d77ce8d1af1f527da7a2c17;p=bertos.git diff --git a/bertos/kern/proc.c b/bertos/kern/proc.c index 794918a5..c422e729 100644 --- a/bertos/kern/proc.c +++ b/bertos/kern/proc.c @@ -60,6 +60,8 @@ #include /* memset() */ +#define PROC_SIZE_WORDS (ROUND_UP2(sizeof(Process), sizeof(cpu_stack_t)) / sizeof(cpu_stack_t)) + /* * The scheduer tracks ready processes by enqueuing them in the * ready list. @@ -83,7 +85,7 @@ static struct Process main_process; /** * Local heap dedicated to allocate the memory used by the processes. */ -static HEAP_DEFINE_BUF(heap_buf, KERN_MINSTACKSIZE * 128); +static HEAP_DEFINE_BUF(heap_buf, CONFIG_KERN_HEAP_SIZE); static Heap proc_heap; /* @@ -137,10 +139,7 @@ void proc_init(void) monitor_init(); monitor_add(current_process, "main"); #endif - -#if CONFIG_KERN_PREEMPT - preempt_init(); -#endif + proc_schedInit(); MOD_INIT(proc); } @@ -163,8 +162,10 @@ static void proc_freeZombies(void) return; if (proc->flags & PF_FREESTACK) + { PROC_ATOMIC(heap_freemem(&proc_heap, proc->stack_base, - proc->stack_size)); + proc->stack_size + PROC_SIZE_WORDS * sizeof(cpu_stack_t))); + } } } @@ -206,7 +207,6 @@ static void proc_addZombie(Process *proc) struct Process *proc_new_with_name(UNUSED_ARG(const char *, name), void (*entry)(void), iptr_t data, size_t stack_size, cpu_stack_t *stack_base) { Process *proc; - const size_t PROC_SIZE_WORDS = ROUND_UP2(sizeof(Process), sizeof(cpu_stack_t)) / sizeof(cpu_stack_t); LOG_INFO("name=%s", name); #if CONFIG_KERN_HEAP bool free_stack = false;