X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fkern%2Fproc.c;h=afe9e34a92e5430a9832d2d76a0d2ce2907c15d1;hb=0315f64ec2ee2c5eb10634360fb8874c52dbbabf;hp=bce8ac3e8a7fcadfd4eaf4d7073c659bf0813ff6;hpb=d4e6689215738b0802c3fa9948392bc6d73bf557;p=bertos.git diff --git a/bertos/kern/proc.c b/bertos/kern/proc.c index bce8ac3e..afe9e34a 100644 --- a/bertos/kern/proc.c +++ b/bertos/kern/proc.c @@ -203,6 +203,15 @@ struct Process *proc_new_with_name(UNUSED(const char *, name), void (*entry)(voi #endif #endif +#if CONFIG_KERN_PREEMPT + // FIXME: proc_exit + getcontext(&proc->context); + proc->context.uc_stack.ss_sp = stack_base; + proc->context.uc_stack.ss_size = stack_size; + proc->context.uc_link = NULL; + makecontext(&proc->context, entry, 0); + +#else // !CONFIG_KERN_PREEMPT /* Initialize process stack frame */ CPU_PUSH_CALL_FRAME(proc->stack, proc_exit); CPU_PUSH_CALL_FRAME(proc->stack, entry); @@ -214,6 +223,7 @@ struct Process *proc_new_with_name(UNUSED(const char *, name), void (*entry)(voi /* Add to ready list */ ATOMIC(SCHED_ENQUEUE(proc)); ATOMIC(LIST_ASSERT_VALID(&ProcReadyList)); +#endif // CONFIG_KERN_PREEMPT #if CONFIG_KERN_MONITOR monitor_add(proc, name);