Re: mmap() and threads BUG

Alan Cox (alan@lxorguk.ukuu.org.uk)
Thu, 1 Apr 1999 19:04:22 +0100 (BST)


> It seems that if you use mmap(),memcpy(),munmap() to read/write to a
> portion of a file, you can get corrupt data. There appears to be no
> thread-safe alternative besides this method to do offset-thread-safe
> reads and writes on Linux.

Interesting. That looks like some kind of mapping race in 2.0 yes. I'll
have a look for that before doing a final 2.0.37.

> Does this program work on the "2.2" kernels?
> This program makes it appear that mmap() is really broken in 2.0.36.

2.2 reports

Initializing File
Starting Threads
Thread a starting Write/Read Loop.
Thread b starting Write/Read Loop.
Thread c starting Write/Read Loop.
Thread d starting Write/Read Loop.
Thread e starting Write/Read Loop.
Thread f starting Write/Read Loop.
Thread g starting Write/Read Loop.
Thread h starting Write/Read Loop.
Thread i starting Write/Read Loop.
Waiting for Threads
Thread j starting Write/Read Loop.
Test Exiting

(16Mb 486DX33, Symbios FC920 FC disk)

So it seems to work. It also has pread/pwrite.

Alan

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/