Re: the random driver

From: Ingo Oeser (ingo.oeser@informatik.tu-chemnitz.de)
Date: Wed Nov 20 2002 - 07:04:42 EST


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.

Regards

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 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/



This archive was generated by hypermail 2b29 : Sat Nov 23 2002 - 22:00:32 EST