Does mmap fit a page or part of a page?

Am I confused, mmapis it allocating a whole page of memory (regardless of the specified size), or is it just allocating the required size? Indeed, I am curious what will happen in subsequent calls to mmap- if the second call selects a new page (even if both calls use the sum of the page size) or it selects a block adjacent to the previous call

The same for mprotect- does it protect the entire page or only the specified part?

+4
source share
2 answers

If the length argument is not a multiple of the page size, it will be rounded to the size of the page.

, : yes mmap() .

mprotect(), :

mprotect() () [addr, + LEN-1]. addr .

+5

.

- mmap , ​​ - . , MMU "" , ( ), - .
, , 2 1, ? , .

mmap , , . , ( ), , , , ( "" , , "Linux",).

( mmap) - , . ( 4096 ) .
Linux - , , 2.6, mmap_min_addr EINVAL, , .

: POSIX

+7

Source: https://habr.com/ru/post/1532328/


All Articles