From 0315f64ec2ee2c5eb10634360fb8874c52dbbabf Mon Sep 17 00:00:00 2001 From: bernie Date: Thu, 14 Aug 2008 04:22:05 +0000 Subject: [PATCH] preempt: initialize process context structure in proc_new() git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1641 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/kern/preempt.c | 2 +- bertos/kern/proc.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bertos/kern/preempt.c b/bertos/kern/preempt.c index 0cbaf7c9..dfa343d7 100644 --- a/bertos/kern/preempt.c +++ b/bertos/kern/preempt.c @@ -182,5 +182,5 @@ void preempt_init(void) sigaction(SIGUSR1, &act, NULL); sigaction(SIGALRM, &act, NULL); - alarm(1); + alarm(1); // FIXME } 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); -- 2.25.1