POSIX munmap
Posted: Sun Mar 20, 2011 5:59 am
Whilst reading the posix munmap specification I got some questions that I cannot answer using that specification.
For the munmap call it is specified:
[quote=The open group base specifications issue 7]
The munmap() function shall remove any mappings for those entire pages containing any part of the address space of the process starting at addr and continuing for len bytes. Further references to these pages shall result in the generation of a SIGSEGV signal to the process. If there are no mappings in the specified address range, then munmap() has no effect.
[/quote]
Now suppose we have a system with a page size of 4K and an application which has 4K of memory mapped at address 0
What (according to the specs) should be the result of the following munmap call:
munmap(0,1);
Should it do absolutely nothing aside from registering that a small part of that first page is unmapped so that when a call munmap(1,4K-1) happens it can unmap the entire page
or should it unmap the entire 4K page at address 0?
For the munmap call it is specified:
[quote=The open group base specifications issue 7]
The munmap() function shall remove any mappings for those entire pages containing any part of the address space of the process starting at addr and continuing for len bytes. Further references to these pages shall result in the generation of a SIGSEGV signal to the process. If there are no mappings in the specified address range, then munmap() has no effect.
[/quote]
Now suppose we have a system with a page size of 4K and an application which has 4K of memory mapped at address 0
What (according to the specs) should be the result of the following munmap call:
munmap(0,1);
Should it do absolutely nothing aside from registering that a small part of that first page is unmapped so that when a call munmap(1,4K-1) happens it can unmap the entire page
or should it unmap the entire 4K page at address 0?