1833913 Members
2730 Online
110063 Solutions
New Discussion

Re: mmap

 
SOLVED
Go to solution
Victor.Lin
Occasional Contributor

mmap

Several processes establish mapping between process?? address space and a file via mmap() with MAP_SHARED selected. Whether subsequent references to the share region are mapped directly to related processes or indirectly via the disk I/O ?
2 REPLIES 2
rick jones
Honored Contributor
Solution

Re: mmap

anyone who MAP_SHAREDs a file will all share the same memory. given the peculularities of PA-RISC processors and their caches, it is important to let mmap() decide where to make the association. there should be more about that in the manpage.

i also believe that the FS works to keep things up-to-date with others doing stuff to the same file via file I/O, but my personal suggestion is to not mix one process using mmap() with another doing read/write to the same file. it just "feels" like it would be fraught with issues to me, but i'm just a raving paranoid :)
there is no rest for the wicked yet the virtuous have no pillows
Vincent Fleming
Honored Contributor

Re: mmap

The VMM maps the I/O buffers from the kernel directly into the address space of the process when you use mmap(). Any changes to the buffers would therefore be "seen" immediately in the processes that mmap() the file, regardless of how the changes are made; ie: through a memory reference or through write().

As a general programming practice, I would avoind mixing the two access methods, as it would be very confusing to anyone trying to decipher your code.
No matter where you go, there you are.