brk.2
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 2 代码 · 共 102 行
2
102 行
.\" SCCSID: @(#)brk.2 8.1 9/11/90.TH brk 2 VAX.SH Namebrk, sbrk \- change core allocation.SH Syntax#include <sys/types.h>.PPcaddr_t brk(\fIaddr\fP).brcaddr_t \fIaddr\fP;.PPcaddr_t sbrk(\fIincr\fP).brint \fIincr\fP;.SH Description.NXR "brk system call".NXR "sbrk system call".NXR "data memory" "changing size"The.PN brksystem call sets the system's idea of the lowest data segment location not used by the program (called the break)to.I addr(rounded up to the next multiple of the system's page size).Locations greater than.I addrand below the stack pointerare not in the address space and will thuscause a memory violation if accessed..PPIn the alternate function.PN sbrk ,.I incrmore bytes are added to theprogram's data space and a pointer to thestart of the new area is returned..PPWhen a program begins execution using.PN execve ,the break is set at thehighest location defined by the programand data storage areas.Ordinarily, therefore, only programs with growingdata areas need to use.PN sbrk ..PPThe.PN getrlimitsystem call may be used to determinethe maximum permissible size of the.I datasegment.It will not be possible to set the breakbeyond the.I rlim_maxvalue returned from a call to.PN getrlimit ,for example, .B etext + rlp \-\fIrlim_max.\fRSee.MS end 3for the definition of.IR etext ..SH Return ValuesIf the call is successful, .PN brkreturns a 0 value.If the program requests morememory than the system limit, .PN brkreturns \-1. If the break could not be set, .PN brkreturns \-1..SH RestrictionsSetting the break may fail due to a temporary lack ofswap space. It is not possible to distinguish thisfrom a failure caused by exceeding the maximum size ofthe data segment without consulting .PN getrlimit ..SH DiagnosticsThe.PN sbrkcall fails and no additional memory is allocated under the followingconditions:.TP 15[ENOMEM]The limit, as set by.PN setrlimit , is exceeded..TP 15[ENOMEM]The maximum possible size of a data segment (compiled into thesystem) is exceeded..TP 15[ENOMEM]Insufficient space exists in the swap areato support the expansion..SH See Alsoexecve(2), getrlimit(2), setrlimit(2), end(3), malloc(3)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?