- #if CONFIG_KERN_PREEMPT
-
- getcontext(&proc->context);
- proc->context.uc_stack.ss_sp = proc->stack;
- proc->context.uc_stack.ss_size = stack_size - PROC_SIZE_WORDS - 1;
- proc->context.uc_link = NULL;
- makecontext(&proc->context, (void (*)(void))proc_entry, 1, entry);
-
- #else // !CONFIG_KERN_PREEMPT
- {
- size_t i;
-
- /* Initialize process stack frame */
- CPU_PUSH_CALL_FRAME(proc->stack, proc_exit);
- CPU_PUSH_CALL_FRAME(proc->stack, entry);
-
- /* Push a clean set of CPU registers for asm_switch_context() */
- for (i = 0; i < CPU_SAVED_REGS_CNT; i++)
- CPU_PUSH_WORD(proc->stack, CPU_REG_INIT_VALUE(i));
- }
- #endif // CONFIG_KERN_PREEMPT
-
- #if CONFIG_KERN_MONITOR
- monitor_add(proc, name);
- #endif