Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

exec(2)

shmop(2)

ulimit(2)

end(3C)



          BRK(2)               INTERACTIVE UNIX System               BRK(2)



          NAME
               brk, sbrk - change data segment space allocation

          SYNOPSIS
               int brk (endds)
               char *endds;

               char *sbrk (incr)
               int incr;

          DESCRIPTION
               The brk and sbrk system calls 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 loca-
               tion beyond the end of the data segment.  The amount of
               allocated space increases as the break value increases.
               Newly allocated space is set to zero.  If, however, the same
               memory space is reallocated to the same process, its con-
               tents are undefined.

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

               The sbrk system call adds incr bytes to the break value and
               changes the allocated space accordingly.  Incr can be nega-
               tive, in which case the amount of allocated space is
               decreased.

               The brk and sbrk system calls will fail without making any
               change in the allocated space if one or more of the follow-
               ing is true:

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

                    [EAGAIN]     Total amount of system memory available
                                 for a read during physical IO is tem-
                                 porarily insufficient [see shmop(2)].
                                 This may occur even though the space
                                 requested was less than the system-imposed
                                 maximum process size [see ulimit(2)].

          RETURN VALUE
               Upon successful completion brk returns a value of 0, and
               sbrk returns the old break value.  Otherwise, a value of -1
               is returned and errno is set to indicate the error.

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


          Rev. C Software Development Set                            Page 1



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