O'Reilly logo

Advanced UNIX Programming by Warren W. Gay

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Controlling Memory-Mapped Regions

A memory-mapped region often requires its attributes to be queried or changed in some fashion. This section looks at four system calls designed for this purpose:

mprotect(2) Change the access of the indicated memory pages.
madvise(2) Advise the UNIX kernel how you intend to use your memory region.
mincore(2) Determine if pages of mapped memory are currently in memory.
msync(2) Where modifications exist, indicate what regions of memory should be updated to the mapped files.

Changing the Access Protection

A memory-mapped region, entirely or in part, may have its access protections changed by the mprotect(2) system call. Its function synopsis is as follows:

 #include <sys/types.h> #include <sys/mman.h> int mprotect(const ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required