Re: Big mallocs, mmap sorrows and double buffering.

Andreas Schwab (schwab@issan.informatik.uni-dortmund.de)
12 Feb 1997 11:21:31 +0100


Matti Aarnio <matti.aarnio@tele.fi> writes:

|>> icp = (char *)mmap( 0, st.st_size,
|>> PROT_READ, MAP_FILE | MAP_PRIVATE, ifd, 0);

|> Ouch! You need: MAP_FILE|MAP_SHARED
|> You don't want a private copy of it!

Since PROT_WRITE is not set this is in effect a shared mapping (and Linux
internally handles it like a shared mapping).

|>> ocp = (char *)mmap( 0, st.st_size,
|>> PROT_WRITE, MAP_FILE | MAP_PRIVATE, ofd, 0);

|> No, you can't mmap() for writing the file.

Sure you can (if you use MAP_SHARED).

-- 
Andreas Schwab                                      "And now for something
schwab@issan.informatik.uni-dortmund.de              completely different"