Re: Lockless file reading

From: Timo Sirainen
Date: Thu Aug 28 2003 - 05:28:51 EST


On Thu, 2003-08-28 at 00:15, Nagendra Singh Tomar wrote:
> > > I beleive ur original post was to address the case of a reader
> > reading
> > > a file getting *incorrect* data due to the file being written
> > > simultaneously by another writer process.
> >
> > Well, "old" data, which mixed with new data would become incorrect as a
> > whole.
>
> What is this mixing we are talking of ??

I can easily see that the data might be divided into two separate pages
and between updating those pages, another process would have read the
first page, but not the second page. That would result in a mixed old
and new data. Probably just <old><new> or <new><old> instead of
<new><old><new> what I was worrying about, but still it would be nicer
to rely only on byte atomicity and read/write ordering. :)

> > That was my original plan, to just rely on such kernel behaviour. I just
> > don't know if it's such a good idea to rely on that, especially if I
> > want to keep my program portable. I'll probably fallback to that anyway
> > if my checksumming ideas won't work.
>
> But I don't see any problem with a single writer and >=1 reader. There is
> no question of portability.

There are of multiple writers, but it's fine for them to do locking
between each others.


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