mmap: will the mapped file be loaded into memory immediately?

后端 未结 4 1075
無奈伤痛
無奈伤痛 2020-12-30 06:12

From the manual, I just know that mmap() maps a file to a virtual address space, so the file can be randomly accessed. But, it is unclear to me that whether the mapped file

4条回答
  •  遥遥无期
    2020-12-30 06:39

    Yes, mmap creates a mapping. It does not normally read the entire content of whatever you have mapped into memory. If you wish to do that you can use the mlock/mlockall system call to force the kernel to read into RAM the content of the mapping, if applicable.

提交回复
热议问题