Index: include/nucleus/queue.h =================================================================== --- include/nucleus/queue.h (revision 1561) +++ include/nucleus/queue.h (working copy) @@ -242,6 +242,19 @@ static inline xnholder_t *popq (xnqueue_ return nextholder; } +static inline xnholder_t *lastq (xnqueue_t *qslot) +{ + xnholder_t *holder = qslot->head.last; + return holder == &qslot->head ? NULL : holder; +} + +static inline xnholder_t *getlastq (xnqueue_t *qslot) +{ + xnholder_t *holder = lastq(qslot); + if (holder) removeq(qslot,holder); + return holder; +} + static inline int countq (xnqueue_t *qslot) { return qslot->elems; @@ -437,6 +450,11 @@ static inline xnpholder_t *poppq (xnpque return (xnpholder_t *)popq(&pqslot->pqueue,&holder->plink); } +static inline xnpholder_t *getlastpq (xnpqueue_t *pqslot) +{ + return (xnpholder_t *)getlastq(&pqslot->pqueue); +} + static inline int countpq (xnpqueue_t *pqslot) { return countq(&pqslot->pqueue); Index: ksrc/nucleus/synch.c =================================================================== --- ksrc/nucleus/synch.c (revision 1561) +++ ksrc/nucleus/synch.c (working copy) @@ -525,7 +525,7 @@ int xnsynch_flush(xnsynch_t *synch, xnfl status = emptypq_p(&synch->pendq) ? XNSYNCH_DONE : XNSYNCH_RESCHED; - while ((holder = getpq(&synch->pendq)) != NULL) { + while ((holder = getlastpq(&synch->pendq)) != NULL) { xnthread_t *sleeper = link2thread(holder, plink); __setbits(sleeper->status, reason); sleeper->wchan = NULL;