brk(2)
NAME
brk, sbrk, break − change core allocation
SYNTAX
int brk(addr)
char addr; char *sbrk(incr)
int incr;
DESCRIPTION
The brk system call sets the system’s idea of the lowest location that is not used by the program (called the break) to addr (rounded up to the next multiple of 64 bytes on the PDP11). Locations not less than addr and below the stack pointer are not in the address space and thus will cause a memory violation if accessed.
The sbrk system call adds incr more bytes to the program’s data space and returns a pointer to the start of the new area.
When a program begins execution with an exec call, the break is set at the highest location defined by the program and data storage areas. Ordinarily, only programs with growing data areas need to use the break call.
RESTRICTIONS
Setting the break in the range 0177701 to 0177777 (on the PDP11) is the same as setting it to zero.
RETURN VALUE
If unsuccessful, returns a −1. The global variable errno indicates the error code.
DIAGNOSTICS
The brk and sbrk will fail if:
[ENOMEM] The maximum possible size of a data segment (compiled into the system) was exceeded.
[ENOMEM] The maximum available memory for a user process was exceeded. For a split I+D process, text or data+stack was larger than 64KB. For a non-split I+D process, text+data+stack was larger than 64KB.
ASSEMBLER
(break = 17.)
sys break; addr
The break call performs the function of brk. The name of the routine differs from that in C for historical reasons.