From 69f9642bf44e6e3de680b07a22a290b9219ab47d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 26 Jul 2008 09:25:11 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@359 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- src/chlists.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/chlists.c') diff --git a/src/chlists.c b/src/chlists.c index 37db948b2..3b173c94d 100644 --- a/src/chlists.c +++ b/src/chlists.c @@ -26,6 +26,7 @@ #ifndef CH_OPTIMIZE_SPEED /* * Inserts a thread into a priority ordered queue. + * * @param tp the pointer to the thread to be inserted in the list * @param tqp the pointer to the threads list header * @note the insertion is done by scanning the list from the highest priority @@ -33,16 +34,21 @@ */ 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)) + /* iterate to next thread in queue */ cp = cp->p_next; - /* Insertion on p_prev.*/ + /* 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 */ tp->p_prev->p_next = cp->p_prev = tp; } /* - * Inserts a thread into a FIFO queue. + * Inserts a Thread into a FIFO queue. + * * @param tp the pointer to the thread to be inserted in the list * @param tqp the pointer to the threads list header */ @@ -53,8 +59,10 @@ void fifo_insert(Thread *tp, ThreadsQueue *tqp) { } /* - * Removes a thread from a FIFO queue. + * Removes the first-out Thread from a FIFO queue and returns it. + * * @param tqp the pointer to the threads list header + * @return the removed thread pointer */ Thread *fifo_remove(ThreadsQueue *tqp) { Thread *tp = tqp->p_next; @@ -65,8 +73,8 @@ Thread *fifo_remove(ThreadsQueue *tqp) { /* * Removes a Thread from a FIFO list and returns it. + * * @param tp the pointer to the thread to be removed from the list - * @param tqp the pointer to the list header * @return the removed thread pointer */ Thread *dequeue(Thread *tp) { @@ -77,7 +85,8 @@ Thread *dequeue(Thread *tp) { } /* - * Inserts a Thread into a stack list. + * Pushes a Thread on top of a stack list. + * * @param tp the pointer to the thread to be inserted in the list * @param tlp the pointer to the threads list header */ @@ -87,9 +96,9 @@ void list_insert(Thread *tp, ThreadsList *tlp) { tlp->p_next = tp; } - /* - * Removes a Thread from a stack list and returns it. + * Pops a Thread from the top of a stack list and returns it. + * * @param tlp the pointer to the threads list header * @return the removed thread pointer */ -- cgit v1.2.3