Programming Interfaces Guide

Other Memory Control Interfaces

sysconf

sysconf(3C) returns the system dependent size of a memory page. For portability, applications should not embed any constants that specify the size of a page. Note that varying page sizes are not unusual, even among implementations of the same instruction set.

mprotect

mprotect(2) assigns the specified protection to all pages in the specified address range. The protection cannot exceed the permissions that are allowed on the underlying object.

brk and sbrk

A break is the greatest valid data address in the process image that is not in the stack. When a program starts executing, the break value is normally set by execve(2) to the greatest address defined by the program and its data storage.

Use brk(2) to set the break to a greater address. You can also use sbrk(2) to add an increment of storage to the data segment of a process. You can get the maximum possible size of the data segment by a call to getrlimit(2).

caddr_t
 brk(caddr_t addr);

 caddr_t
 sbrk(intptr_t incr); 

brk identifies the lowest data segment location not used by the caller as addr. This location is rounded up to the next multiple of the system page size.

sbrk, the alternate interface, adds incr bytes to the caller data space and returns a pointer to the start of the new data area.