From e150283e1f071673e1d3490cbf85651e5502d421 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 30 Jul 2008 11:01:56 +0000 Subject: Various optimizations to the scheduler. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@378 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- src/chlists.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/chlists.c') diff --git a/src/chlists.c b/src/chlists.c index 3b173c94d..dcb3b0412 100644 --- a/src/chlists.c +++ b/src/chlists.c @@ -47,19 +47,19 @@ void prio_insert(Thread *tp, ThreadsQueue *tqp) { } /* - * Inserts a Thread into a FIFO queue. + * Inserts a Thread into a queue. * * @param tp the pointer to the thread to be inserted in the list * @param tqp the pointer to the threads list header */ -void fifo_insert(Thread *tp, ThreadsQueue *tqp) { +void queue_insert(Thread *tp, ThreadsQueue *tqp) { tp->p_prev = (tp->p_next = (Thread *)tqp)->p_prev; tp->p_prev->p_next = tqp->p_prev = tp; } /* - * Removes the first-out Thread from a FIFO queue and returns it. + * Removes the first-out Thread from a queue and returns it. * * @param tqp the pointer to the threads list header * @return the removed thread pointer @@ -71,6 +71,19 @@ Thread *fifo_remove(ThreadsQueue *tqp) { return tp; } +/* + * Removes the last-out Thread from a queue and returns it. + * + * @param tqp the pointer to the threads list header + * @return the removed thread pointer + */ +Thread *lifo_remove(ThreadsQueue *tqp) { + Thread *tp = tqp->p_next; + + (tqp->p_next = tp->p_next)->p_prev = (Thread *)tqp; + return tp; +} + /* * Removes a Thread from a FIFO list and returns it. * -- cgit v1.2.3