[lkml]   [2002]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: the random driver
Hi Andrew,

On Tue, Nov 19, 2002 at 11:46:53PM -0800, Andrew Morton wrote:
> c) The ring-buffer handling is awkward. It shouldn't be masking
> the head and tail pointers to always remain within bounds.
> A better technique is to allow these indices to wrap at
> 0xffffffff and only mask their values when you actually use
> them as a subscript. This allows you to distinguish the
> completely-full case from the completely-empty one. See
> LOG_BUF* in kernel/printk.c.

Care to implement a generic ringbuffer in a header file, to avoid
this kind of errors? I'm sure there are more (and even overflows
on some implementations).

The gory implementation details of basic computer science
algorithms seem to cause problems for many driver writers.

So the trend of abstracting these away in the kernel, if it costs
no time and doesn't lead to ugly code, is right.


Ingo Oeser
Science is what we can tell a computer. Art is everything else. --- D.E.Knuth
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:31    [from the cache]
©2003-2014 Jasper Spaans. hosted at Digital Ocean