Re: [RFC, 2.6] a simple FIFO implementation

From: Peter Chubb
Date: Thu Sep 16 2004 - 20:02:32 EST


>>>>> "Andrew" == Andrew Morton <akpm@xxxxxxxx> writes:


Andrew> All the struct needs is `head', `tail' and
Andrew> `number_of_bytes_at_buf', all unsigned.

Andrew> add(char c) {
Andrew> p-> buf[p->head++ % p->number_of_bytes_at_buf] = c;
Andrew> }

This depends on how expensive % is. On IA64, something like this:

add(char c) {
int i = p->head == p->len ? p->head++ : 0;
p->buf[i] = c;
}

is cheaper, as % generates a subroutine call to __modsi3. It also is
shorter =-- 12 bundles as opposed to 15.



--
Dr Peter Chubb http://www.gelato.unsw.edu.au peterc AT gelato.unsw.edu.au
The technical we do immediately, the political takes *forever*
-
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/