From c7c1702dc66f5be0f8f07703e2c8e9f5bd8db80d Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Fri, 21 Jan 2022 15:08:19 -0700 Subject: Simplified Queue Iteration Logic --- src/sys/schedule.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/src/sys/schedule.c b/src/sys/schedule.c index e20abe7..119ad6b 100644 --- a/src/sys/schedule.c +++ b/src/sys/schedule.c @@ -23,30 +23,13 @@ void init_scheduler(void) for (int i = 0; i < PRIORITIES; i++) { tq = &scheduler.thread_queues[i]; struct ThreadRotBuffer* trb = &tq->ready; - trb->roffset = 0; - trb->woffset = 0; - for (int j = 0; j < TQUEUE_MAX; j++) - trb->queue[j] = 0; - trb = &tq->mwait; - trb->roffset = 0; - trb->woffset = 0; - for (int j = 0; j < TQUEUE_MAX; j++) - trb->queue[j] = 0; - trb = &tq->swait; - trb->roffset = 0; - trb->woffset = 0; - for (int j = 0; j < TQUEUE_MAX; j++) - trb->queue[j] = 0; - trb = &tq->finish; - trb->roffset = 0; - trb->woffset = 0; - for (int j = 0; j < TQUEUE_MAX; j++) - trb->queue[j] = 0; - trb = &tq->serror; - trb->roffset = 0; - trb->woffset = 0; - for (int j = 0; j < TQUEUE_MAX; j++) - trb->queue[j] = 0; + for (int i = 0; i < TQUEUE_CNT; i++) { + trb->roffset = 0; + trb->woffset = 0; + for (int j = 0; j < TQUEUE_MAX; j++) + trb->queue[j] = 0; + trb += 1; + } } // Initialize nextpid nextpid = SCHED_PID + 1; -- cgit v1.2.1