microZEUS
The whole stack, hand-drawn.

◄ Wiki / OS

mprotect

A system call that changes what a program is allowed to do with a region of its memory — read, write, or execute.

After memory is mapped, mprotect can mark a region read-only, make it executable, or forbid access entirely, and the hardware enforces those permissions on every access. It's used for things like write-protecting data, implementing guard pages that trap stray accesses, and enabling just-in-time compiled code. Violating the set permissions triggers a fault the OS must handle.

See also

  • mmapA system call that makes a file or a block of memory appear directly in a program's address space.
  • page faultThe interrupt that fires when a program touches memory that isn't currently mapped in.
  • pagingThe virtual-memory scheme that splits memory into fixed-size chunks and maps them flexibly.

Referenced by

mmap