I read hundreds of postings to the subject "mmap or shm*" and now i
only have last things, that are not really clear to me.
1. is it right: when i mmap a file in a process with MAP_SHARED and
another process is started slightly after the first and mmap's the
same file, the second process gets the data "already read" bye the
first process from memory.
2. is it right: They both use the same physical memory.
3. is it right: that when process 2 wants some data from that mmap'ed
file which hasn't been used by process 1, this data is read from disk
and placed into mmap'ed memory, so process 1 can also use it.
4. if 3 is right, mmap doesn't read the whole file on start, at which
size does mmap read data into memory (like 4k blocks)
5. when the two processes are closed and a 3rd process starts half a
second after 1,2 closed, #3 has to read the file again, cause "when
the last process which mmap's the same file is closing, the shared
memory is removed"
6. The better solution for scenario #5 is a forking process who get a
shared memory by shm_get, read the whole file into it and fork()'s on
demand. disconnecting shared memory is made by the parent process by
his own "caching" algorithms (in case #5 i hold the shared memory till
10 seconds after last process is using it, so process 3 could benefit
from "my caching")
7. shared memory with shm_get isn't slower than mmap
i hope i'm at least right in the half of these thesis
thanx Stefan Lischke