Re: [RFC, 2.6] a simple FIFO implementation

From: Bill Davidsen
Date: Thu Sep 16 2004 - 11:24:15 EST


Stelian Pop wrote:
Hi all,

Is there a reason there is no API implementing a simple in-kernel
FIFO ? A linked list is a bit overkill...

Besides my sonypi and meye drivers which could use this, there are
quite a few other drivers which re-implement the circular buffer
over and over again...

An initial implementation follows below. Comments ?

Many.

- you don't need both size and len, just the length
- you don't need a count of what's in the fifo, calc from tail-head
- you don't need remaining, when the tail reaches the head
you're out of data.
- you want to do at most two memcpy operations, the loop is just
unproductive overhead.
- if the fifo goes empty set the head and tail back to zero so you don't
wrap (assumes doing just two memcpy ops) when you don't need to

--
-bill davidsen (davidsen@xxxxxxx)
"The secret to procrastination is to put things off until the
last possible moment - but no longer" -me
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/