Re: Lockless file reading
From: Timo Sirainen
Date: Wed Aug 27 2003 - 22:20:20 EST
On Thursday, Aug 28, 2003, at 04:50 Europe/Helsinki, Jamie Lokier wrote:
checksum[0]++;
xor = buf[0] ^ checksum[0];
Your algorithm isn't going to work if the new value of xor is the same
as the old value of xor.
I was trying to prevent it with the checksum[0]++ .. but yes, you're
right.
I'm sure someone has figured out a way to make a checksum of data that
can detect if there's even a single bit wrong, if the checksum is
allowed to take as much space as the data itself. I should read more
about algorithms..
How about checksum[n] = data[n-1] ^ data[n]? That looks like it would
work.
-
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/