Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sbrk(2) — CX/UX 6.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

exec(2)

plock(2)

shmop(2)

ulimit(2)

getrlimit(2)

end(3C)



brk(2)                                                     brk(2)



NAME
     brk, sbrk - change data segment space allocation

SYNOPSIS
     int brk (endds)
     char *endds;

     char *sbrk (incr)
     int incr;

DESCRIPTION
     brk and sbrk are used to change dynamically the amount of
     space allocated for the calling process's data segment; see
     exec(2).  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 end of the data segment.  The amount of allocated space
     increases as the break value increases.  The newly allocated
     space is set to zero.

     brk sets the break value to endds and changes the allocated
     space accordingly.

     Sbrk adds incr bytes to the break value and changes the
     allocated space accordingly.  Incr can be zero, in which
     case sbrk will return the process' current break vlaue.
     Incr can also be negative, in which case the amount of allo-
     cated space is decreased.

     brk and sbrk will fail without making any change in the
     allocated space if one or more of the following are true:

          Such a change would result in more space being allo-
          cated than is allowed by a system-imposed maximum (see
          ulimit(2)).  [ENOMEM]

          Such a change would result in a break value either
          greater than or equal to the starting address of an
          attached shared memory segment [see shmop(2)] or less
          than the starting address of data.  [ENOMEM]

          Insufficient space existed in the swap area to support
          the expansion.  [ENOMEM]

          The process has its data region locked and the total
          amount of system memory available is temporarily insuf-
          ficient [see plock(2)].  This may occur even though the
          space requested was less than the system-imposed max-
          imum process size [see ulimit(2)].  [EAGAIN]

RETURN VALUE
     Upon successful completion, brk returns a value of 0 and



Page 1                        CX/UX Programmer's Reference Manual





brk(2)                                                     brk(2)



     sbrk returns the old break value.  Otherwise, a value of -1
     is returned and errno is set to indicate the error.

     As noted in the description, errno can be set to one of the
     following values depending on the error that occurs:

          [EAGAIN]

          [ENOMEM]

BUGS
     brk and sbrk will not set the break value to an address
     below the value of end (see end(3C)).

SEE ALSO
     exec(2), plock(2), shmop(2), ulimit(2), getrlimit(2),
     end(3C).






































Page 2                        CX/UX Programmer's Reference Manual



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