lkml.org 
[lkml]   [2004]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC, 2.6] a simple FIFO implementation
On Thu, Sep 16, 2004 at 08:45:49AM -0700, Paul Jackson wrote:

> > 'size' field instead of an 'end'
>
> The start, end, put, get names in that *.pdf might be a
> bit quicker to read.
>
> I suspect that more readers would come away with the right
> understanding, first time, if you struct was (taken roughly
> from the *.pdf, using an 'end' one bigger than *.pdf uses):
>
> /* kfifo is empty, not full, when head == tail */
> struct kfifo {
> unsigned char *start; /* [start, end) */
> unsigned char *end;
> unsigned char *head; /* next input char goes in here */
> unsigned char *tail; /* next output char comes from here */
> spinlock_t lock;
> };
>
> then your structure:
>
> struct kfifo {
> unsigned int head;
> unsigned int tail;
> unsigned int size;
> spinlock_t lock;
> unsigned char *buffer;
> };
>
> Differences include names, all pointers,

Except that this implementation requires 'head' and 'tail' to be
constrained to be between 'start' and 'end', adding an if test instead
of arithmetic unsigned int wrap.

> ordering of struct elements,

I could place buffer at the beginning of the struct, indeed.

> and comments.

And commenting the fields is of course a very good idea.

Stelian.
--
Stelian Pop <stelian@popies.net>
-
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