lkml.org 
[lkml]   [2004]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RFC, 2.6] a simple FIFO implementation
Date
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@tmr.com)
"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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:06    [from the cache]
©2003-2011 Jasper Spaans