📄 brk.2
字号:
.TH brk 2 RISC.SH Namebrk, sbrk \- change data segment space allocation.SH Syntax.B #include <sys/types.h>.PP.B char \(**brk(addr).br.B char \(**addr;.PP.B char \(**sbrk(incr).br.B int incr;.SH DescriptionThe.PN brksystem callsets the system's idea of the lowest data segment location not usedby the program (called the break) to .I addr(rounded up to the next multiple of the system's page size). Locationsgreater than.I addr and below the stack pointer are not in the address space and thus willcause a memory violation if accessed..PPIn the alternate function.PN sbrk ,.I incrmore bytes are added to the program's data space and a pointer to thestart of the new area is returned..PPWhen a program begins execution by .PN execve ,the break is set at the highest location defined by the program anddata storage areas. Ordinarily, therefore, only programs with growing data areas need to use.PN brk ..PPThe.MS getrlimit 2system call may be used to determine the maximum permissible size ofthe data segment; it will not be possible to set the break beyondthe .I rlim_maxvalue returned from a call to.MS getrlimit 2 .For example:.EX0x10000000 + rlp -> rlim_max.EE.SH Return ValuesUpon successful completion, the.PN brksystem callreturns a value of 0 or \-1 if the program requests more memory thanthe system limit. The.PN sbrksystem call returns \-1 if the break could not be set..SH RestrictionsSetting the break may fail due to a temporary lack of swap space. It isnot possible to distinguish this from a failure caused by exceeding themaximum size of the data segment without consulting .PN getrlimit ..SH DiagnosticsThe.PN sbrksystem call fails and no additionally memory is allocated if one of the following is true:.RS.TP 13.SM [ENOMEM]The limit, as set by.MS setrlimit 2was exceeded..TP.SM [ENOMEM]The maximum possible size a data segment (compiled into the system)was exceeded..TP.SM [ENOMEM]Insufficient space existed in the swap area to support the expansion..RE.SH See Alsoexecve(2), getrlimit(2), setrlimit(2), ulimit(2)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -