X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fkern%2Fidle.c;h=7ba8d617d34a4177860e77876774a5ccb33d6bf8;hb=56bc2446f9445052fb0d7b1643628bbf4fc3cfe0;hp=229058bd4ba1c0e538a591baeda3e907ef1d2639;hpb=d3860ea45a63b0443e4e75a16b402ada83078d12;p=bertos.git diff --git a/bertos/kern/idle.c b/bertos/kern/idle.c index 229058bd..7ba8d617 100644 --- a/bertos/kern/idle.c +++ b/bertos/kern/idle.c @@ -31,17 +31,22 @@ * * \brief Idle loop for preemptive scheduling * - * \version $Id: proc.c 1616 2008-08-10 19:41:26Z bernie $ + * \version $Id$ * \author Bernie Innocenti */ #include "idle.h" #include "proc.h" +#include // cpu_relax() #include +#include // INT_MIN +#include -static cpustack_t idle_stack[CONFIG_KERN_MINSTACKSIZE / sizeof(cpustack_t)]; +struct Process *idle_proc; + +static PROC_DEFINE_STACK(idle_stack, KERN_MINSTACKSIZE); /** * The idle process @@ -59,14 +64,21 @@ static NORETURN void idle(void) { for (;;) { - TRACE; - //monitor_report(); - proc_yield(); // FIXME: CPU_IDLE + PAUSE; + proc_switch(); } } void idle_init(void) { - struct Process *idle_proc = proc_new(idle, NULL, sizeof(idle_stack), idle_stack); - proc_setPri(idle_proc, (int)~0); + /* + * Idle will be added to the ProcReadyList, but immediately removed + * after the first cpu_relax() execution. + * + * XXX: it would be better to never add idle_proc to the ProcReadyList, + * e.g., changing the prototype of proc_new() (or introducing a + * proc_new_nostart()) to allow the creation of "sleeping" tasks. + */ + idle_proc = proc_new(idle, NULL, sizeof(idle_stack), idle_stack); + proc_setPri(idle_proc, INT_MIN); }