preempt: initialize process context structure in proc_new()
authorbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 14 Aug 2008 04:22:05 +0000 (04:22 +0000)
committerbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 14 Aug 2008 04:22:05 +0000 (04:22 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1641 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/kern/preempt.c
bertos/kern/proc.c

index 0cbaf7c902dd2d65a03015cecf2b15804853f17e..dfa343d7a9b702c769a590d8b76e0a409bdec9e2 100644 (file)
@@ -182,5 +182,5 @@ void preempt_init(void)
        sigaction(SIGUSR1, &act, NULL);
        sigaction(SIGALRM, &act, NULL);
 
-       alarm(1);
+       alarm(1);  // FIXME
 }
index bce8ac3e8a7fcadfd4eaf4d7073c659bf0813ff6..afe9e34a92e5430a9832d2d76a0d2ce2907c15d1 100644 (file)
@@ -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);