Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ brk(2) — Unisoft V7

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

exec(2)

malloc(3)

end(3)

BRK(2)  —  UNIX Programmer’s Manual

NAME

brk, sbrk, break − change core allocation

SYNOPSIS

char *brk(addr)
char *addr
char *sbrk(incr)
int incr;

DESCRIPTION

Brk sets the system’s idea of the lowest location not used by the program (called the break) to addr rounded up to the next memory segment multiple.  Locations not less than addr and below the stack pointer are not in the address space and will thus cause a memory violation if accessed. 

In systems without memory management brk will fail if there are not at least 8192 bytes between the top of the permanent data space and the bottom of the current stack pointer. 

In the alternate function sbrk, incr more bytes are added to the program’s data space and a pointer to the start of the new area is returned. 

When a program begins execution via exec, the break is set at the highest location defined by the program and data storage areas.  Ordinarily, therefore, only programs with growing data areas need to use break.

SEE ALSO

exec(2), malloc(3), end(3)

DIAGNOSTICS

Zero is returned if the brk could be set; −1 if the program requests more memory than the system limit or, on memory management CPUs, if too many segmentation registers would be required to implement the break.  Sbrk returns −1 if the break could not be set. 

7th Edition

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026