aboutsummaryrefslogtreecommitdiffstats
path: root/src/chlists.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/chlists.c')
-rw-r--r--src/chlists.c7
1 files changed, 4 insertions, 3 deletions
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 */