X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fkern%2Fproc.c;h=3f2548923dbc1527660cdf3138a091c285f00aee;hb=6a60d159530b29a6f60edbad42d0e31c1f1994d9;hp=bce8ac3e8a7fcadfd4eaf4d7073c659bf0813ff6;hpb=8cfe12e5b95974d75b98ec964fc7edaf37919f0e;p=bertos.git diff --git a/bertos/kern/proc.c b/bertos/kern/proc.c index bce8ac3e..3f254892 100644 --- a/bertos/kern/proc.c +++ b/bertos/kern/proc.c @@ -52,9 +52,6 @@ #include /* memset() */ -#if CONFIG_KERN_PREEMPT -#include "preempt.h" -#endif /* * The scheduer tracks ready processes by enqueuing them in the @@ -203,6 +200,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, (void (*)(void))proc_entry, 1, entry); + +#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 +220,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); @@ -238,7 +245,7 @@ void proc_rename(struct Process *proc, const char *name) */ void proc_exit(void) { - TRACE; + TRACEMSG("%p:%s", CurrentProcess, CurrentProcess->monitor.name); #if CONFIG_KERN_MONITOR monitor_remove(CurrentProcess);