128 lines
2.6 KiB
HTML
128 lines
2.6 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>brk(2)</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<H1>brk(2)</H1>
|
|
<HR>
|
|
<PRE>
|
|
|
|
</PRE>
|
|
<H2>NAME</H2><PRE>
|
|
brk, sbrk - change data segment size
|
|
|
|
|
|
</PRE>
|
|
<H2>SYNOPSIS</H2><PRE>
|
|
#include <unistd.h>
|
|
|
|
<STRONG>char</STRONG> <STRONG>*brk(char</STRONG> <STRONG>*</STRONG><EM>addr</EM><STRONG>)</STRONG>
|
|
|
|
<STRONG>char</STRONG> <STRONG>*sbrk(int</STRONG> <EM>incr</EM><STRONG>)</STRONG>
|
|
|
|
|
|
</PRE>
|
|
<H2>DESCRIPTION</H2><PRE>
|
|
<STRONG>Brk</STRONG> sets the system's idea of the lowest data segment location not used
|
|
by the program (called the break) to <EM>addr</EM>. Locations greater than <EM>addr</EM>
|
|
and below the stack pointer are not in the address space and will thus
|
|
cause a memory violation if accessed.
|
|
|
|
In the alternate function <STRONG>sbrk</STRONG>, <EM>incr</EM> 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 <STRONG>execve</STRONG> 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
|
|
<STRONG>sbrk</STRONG>.
|
|
|
|
|
|
</PRE>
|
|
<H2>RETURN VALUE</H2><PRE>
|
|
The address of the new break is returned if <STRONG>brk</STRONG> succeeds; <STRONG>-1</STRONG> if the
|
|
program requests more memory than the system limit. <STRONG>Sbrk</STRONG> returns <STRONG>-1</STRONG> if
|
|
the break could not be set.
|
|
|
|
|
|
</PRE>
|
|
<H2>ERRORS</H2><PRE>
|
|
<STRONG>Sbrk</STRONG> will fail and no additional memory will be allocated if one of the
|
|
following are true:
|
|
|
|
[ENOMEM] The maximum possible size of a data segment (as set by
|
|
<STRONG><A HREF="../man1/chmem.1.html">chmem(1)</A></STRONG>) was exceeded.
|
|
|
|
[ENOMEM] Insufficient virtual memory space existed to support the
|
|
expansion. (Minix-vmd)
|
|
|
|
|
|
</PRE>
|
|
<H2>SEE ALSO</H2><PRE>
|
|
<STRONG><A HREF="../man1/chmem.1.html">chmem(1)</A></STRONG>, <STRONG><A HREF="../man2/execve.2.html">execve(2)</A></STRONG>, <STRONG><A HREF="../man3/malloc.3.html">malloc(3)</A></STRONG>, <STRONG><A HREF="../man3/end.3.html">end(3)</A></STRONG>.
|
|
|
|
|
|
</PRE>
|
|
<H2>NOTES</H2><PRE>
|
|
Minix-vmd rounds a small data segment limit up to 3 megabytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</PRE>
|
|
<H2>BUGS</H2><PRE>
|
|
Setting the break may fail due to a temporary lack of virtual memory
|
|
under Minix-vmd. It is not possible to distinguish this from a failure
|
|
caused by exceeding the maximum size of the data segment.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</PRE>
|
|
</BODY>
|
|
</HTML>
|