*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->IRIX man pages -> standard/brk (2)              
Title
Content
Arch
Section
 

Contents


brk(2)									brk(2)


NAME    [Toc]    [Back]

     brk, sbrk - change	data segment space allocation

C SYNOPSIS    [Toc]    [Back]

     #include <unistd.h>

     int brk (void *endds);

     void *sbrk	(ssize_t incr);

DESCRIPTION    [Toc]    [Back]

     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.  Newly allocated space is set to
     zero.  If,	however, the same memory space is reallocated to the same
     process its contents are undefined.

     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 negative, in which case the amount of allocated
     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:

	  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 temporarily insufficient [see
		       shmop(2)].  This	may occur even though the space
		       requested was less than the system-imposed maximum
		       process size [see ulimit(2)].

SEE ALSO    [Toc]    [Back]

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

CAVEATS    [Toc]    [Back]

     sbrk(2) is	not multithreaded.  Simultaneous sbrk calls with positive
     increments	will return the	same value.  It	is recommended that malloc(2)
     be	used instead of	sbrk(2).

DIAGNOSTICS    [Toc]    [Back]

     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.



									Page 1






brk(2)									brk(2)


									PPPPaaaaggggeeee 2222
[ Back ]
 Similar pages
Name OS Title
brk Tru64 Change space allocation
sbrk Tru64 Change space allocation
brk NetBSD change data segment size
sbrk FreeBSD change data segment size
sbrk OpenBSD change data segment size
brk OpenBSD change data segment size
sbrk NetBSD change data segment size
brk Linux change data segment size
brk FreeBSD change data segment size
munlock HP-UX unlock a segment of the process virtual address space
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service