From a5f92e68309aa5270602cb6e911c43c9bc370408 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 13 Mar 2009 19:30:52 +0000 Subject: Improvements to the priority lists. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@838 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- src/chlists.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/chlists.c') diff --git a/src/chlists.c b/src/chlists.c index a3ec568a0..82be1923d 100644 --- a/src/chlists.c +++ b/src/chlists.c @@ -38,11 +38,12 @@ void prio_insert(Thread *tp, ThreadsQueue *tqp) { /* cp iterates over the queue */ - Thread *cp = tqp->p_next; - /* not end of queue? and cp has equal or higher priority than tp? */ - while ((cp != (Thread *)tqp) && (cp->p_prio >= tp->p_prio)) + Thread *cp = (Thread *)tqp; + do { /* iterate to next thread in queue */ cp = cp->p_next; + /* not end of queue? and cp has equal or higher priority than tp? */ + } while ((cp != (Thread *)tqp) && (cp->p_prio >= tp->p_prio)); /* insert before cp, point tp to next and prev in queue */ tp->p_prev = (tp->p_next = cp)->p_prev; /* make prev point to tp, and cp point back to tp */ -- cgit v1.2.3