Date: Mon, 8 Sep 2003 15:32:16 -0700 From: "Sean Hamilton" <sh@bel.bc.ca> To: <hackers@freebsd.org> Subject: mmap(2) questions, reads not caching Message-ID: <001c01c37659$4d38f090$0300000a@antalus>
next in thread | raw e-mail | index | archive | help
I have some code resembling: FILE * f = fopen (filename, "rb"); mmap (NULL, st.st_size, PROT_READ, MAP_PRIVATE, fileno (f), 0); I've found that reads are not brought into disk cache. Successive reads on the same file once again read from disk. If I cat the file to /dev/null, then the mmap(2) does indeed read the data from cache. What's going on here? Also, the man page states that the mapped region may be longer than the specified size. Does this have any implications for the size which is passed to munmap(2)? If I pass the same size to munmap(2), then will there still be leftover, or will the entire region be unmapped? And, should I be passing MAP_PRIVATE or MAP_SHARED to read-only mmaps? Does it make any difference at all? Running 5.1-RELEASE.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?001c01c37659$4d38f090$0300000a>