X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fkern%2Fproc.c;h=f2054c3991557127a79bb4b1b302b16da5d69f84;hb=e8b0472be10fba4ca6baa62d8d483db90e28c06e;hp=781bd5532ab3846c0b5de51f2a5c2f48283fa09f;hpb=f35b6066ecdeffcc8998dd566b5246bdcf43c548;p=bertos.git diff --git a/bertos/kern/proc.c b/bertos/kern/proc.c index 781bd553..f2054c39 100644 --- a/bertos/kern/proc.c +++ b/bertos/kern/proc.c @@ -183,8 +183,8 @@ static void proc_initStruct(Process *proc) (void)proc; #if CONFIG_KERN_SIGNALS - proc->sig_recv = 0; - proc->sig_wait = 0; + proc->sig.recv = 0; + proc->sig.wait = 0; #endif #if CONFIG_KERN_HEAP @@ -193,6 +193,12 @@ static void proc_initStruct(Process *proc) #if CONFIG_KERN_PRI proc->link.pri = 0; + +# if CONFIG_KERN_PRI_INHERIT + proc->orig_pri = proc->inh_link.pri = proc->link.pri; + proc->inh_blocked_by = NULL; + LIST_INIT(&proc->inh_list); +# endif #endif } @@ -323,8 +329,9 @@ struct Process *proc_new_with_name(UNUSED_ARG(const char *, name), void (*entry) #else // CONFIG_KERN_HEAP /* Stack must have been provided by the user */ - ASSERT_VALID_PTR(stack_base); - ASSERT(stack_size); + ASSERT2(IS_VALID_PTR(stack_base), "Invalid stack pointer. Did you forget to \ + enable CONFIG_KERN_HEAP?"); + ASSERT2(stack_size, "Stack size cannot be 0."); #endif // CONFIG_KERN_HEAP @@ -438,10 +445,33 @@ void proc_rename(struct Process *proc, const char *name) */ void proc_setPri(struct Process *proc, int pri) { +#if CONFIG_KERN_PRI_INHERIT + int new_pri; + + /* + * Whatever it will happen below, this is the new + * original priority of the process, i.e., the priority + * it has without taking inheritance under account. + */ + proc->orig_pri = pri; + + /* If not changing anything we can just leave */ + if ((new_pri = __prio_proc(proc)) == proc->link.pri) + return; + + /* + * Actual process priority is the highest among its + * own priority and the one of the top-priority + * process that it is blocking (returned by + * __prio_proc()). + */ + proc->link.pri = new_pri; +#else if (proc->link.pri == pri) return; proc->link.pri = pri; +#endif // CONFIG_KERN_PRI_INHERIT if (proc != current_process) ATOMIC(sched_reenqueue(proc));