diff --git a/os/kernel/include/scheduler.h b/os/kernel/include/scheduler.h index 648cb7bc5..d29b92ae6 100644 --- a/os/kernel/include/scheduler.h +++ b/os/kernel/include/scheduler.h @@ -64,13 +64,10 @@ * @extends ThreadsQueue */ typedef struct { - Thread *p_next; /**< Next @p Thread in the ready list.*/ - Thread *p_prev; /**< Previous @p Thread in the ready - list.*/ - /* End of the fields shared with the ThreadsQueue structure. */ + ThreadsQueue r_queue; /**< Next @p Threads queue.*/ tprio_t r_prio; /**< This field must be initialized to zero.*/ - /* End of the fields shared with the Thread structure. */ + /* End of the fields shared with the Thread structure.*/ #if CH_USE_ROUNDROBIN cnt_t r_preempt; /**< Round robin counter.*/ #endif diff --git a/os/kernel/src/chschd.c b/os/kernel/src/chschd.c index 3ba8b29e9..76464d603 100644 --- a/os/kernel/src/chschd.c +++ b/os/kernel/src/chschd.c @@ -37,7 +37,7 @@ ReadyList rlist; */ void scheduler_init(void) { - queue_init(&rlist); + queue_init(&rlist.r_queue); rlist.r_prio = NOPRIO; #if CH_USE_ROUNDROBIN rlist.r_preempt = CH_TIME_QUANTUM; @@ -82,7 +82,7 @@ void chSchGoSleepS(tstate_t newstate) { Thread *otp; (otp = currp)->p_state = newstate; - (currp = fifo_remove((void *)&rlist))->p_state = PRCURR; + (currp = fifo_remove(&rlist.r_queue))->p_state = PRCURR; #if CH_USE_ROUNDROBIN rlist.r_preempt = CH_TIME_QUANTUM; #endif @@ -194,7 +194,7 @@ void chSchDoRescheduleI(void) { Thread *otp = currp; /* pick the first thread from the ready queue and makes it current */ - (currp = fifo_remove((void *)&rlist))->p_state = PRCURR; + (currp = fifo_remove(&rlist.r_queue))->p_state = PRCURR; chSchReadyI(otp); #if CH_USE_ROUNDROBIN rlist.r_preempt = CH_TIME_QUANTUM; @@ -211,7 +211,7 @@ void chSchDoRescheduleI(void) { void chSchRescheduleS(void) { /* first thread in the runnable queue has higher priority than the running * thread? */ - if (firstprio(&rlist) > currp->p_prio) + if (firstprio(&rlist.r_queue) > currp->p_prio) chSchDoRescheduleI(); } @@ -224,7 +224,7 @@ void chSchRescheduleS(void) { * @retval FALSE if a reschedulation is not required. */ bool_t chSchRescRequiredI(void) { - tprio_t p1 = firstprio(&rlist); + tprio_t p1 = firstprio(&rlist.r_queue); tprio_t p2 = currp->p_prio; #if CH_USE_ROUNDROBIN /* If the running thread has not reached its time quantum, reschedule only