Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ brk(2) — AIX PS/2 1.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

exec: execl, execv, execle, execve, execlp, execvp

shmat

shmdt

getrlimit, setrlimit, vlimit

ulimit



BRK(2,L)                    AIX Technical Reference                    BRK(2,L)



-------------------------------------------------------------------------------
brk, sbrk



PURPOSE

Changes data segment space allocation.

SYNTAX


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


DESCRIPTION

The brk and sbrk system calls dynamically change the amount of space allocated
for the calling process's data segment.  (For information about data segments,
see "exec:  execl, execv, execle, execve, execlp, execvp.")

The change is made by resetting the process's break value and allocating the
appropriate amount of space.  The break value is the address of the first
location beyond the current end of the data segment.  The amount of allocated
space increases as the break value increases.  The newly allocated space is
initialized to 0.  The break value can be automatically rounded up to a size
appropriate for the memory management architecture.

The brk system call sets the break value to the value of the endds parameter
and changes the allocated space accordingly.

The sbrk system call adds to the break value the number of bytes contained in
the incr parameter and changes the allocated space accordingly.  The incr
parameter can be a negative number, in which case the amount of allocated space
is decreased.

RETURN VALUE

Upon successful completion, the brk system call returns a value of 0, and the
sbrk system call returns the old break value.  If the brk or the sbrk system
calls fail, a value of -1 is returned and errno is set to indicate the error.

ERROR CONDITIONS

The brk and the sbrk system calls fail and the allocated space remains
unchanged if one or more of the following are true:







Processed November 7, 1990         BRK(2,L)                                   1





BRK(2,L)                    AIX Technical Reference                    BRK(2,L)



ENOMEM    The requested change will allocate more space than is allowed by a
          system-imposed maximum.  (For information on the system-imposed
          maximum on memory space, see "getrlimit, setrlimit, vlimit" and
          "ulimit.")

ENOMEM    The requested change will set the break value to a value greater than
          the lowest stack address or to a value greater than the start address
          of any attached shared memory segment.  (For information on shared
          memory operations, see "shmat,"  "shmdt," and "shmget.")

EINVAL    The endss or incr parameters would free more data space than had been
          allocated.

RELATED INFORMATION

In this book:  "exec:  execl, execv, execle, execve, execlp, execvp," "shmat,"
"shmdt,"  "getrlimit, setrlimit, vlimit," and "ulimit."






































Processed November 7, 1990         BRK(2,L)                                   2



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