brk 和 sbrk 代表什么?
虽然我知道 Unix 系统调用 brk
和函数 sbrk
的作用,但我不知道它们代表什么。谁能启发我吗?
While I know what the Unix system call brk
and function sbrk
do, I have no idea what they stand for. Can anyone enlighten me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它来自“打破价值”。
我引用:
“通过重置进程的中断值并分配适当的空间量来进行更改。中断值是超出数据段末尾的第一个位置的地址。”
(来源:http://www.s- gms.ms.edus.si/cgi-bin/man-cgi?brk+2)
It comes from "break value".
I quote:
"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."
(source: http://www.s-gms.ms.edus.si/cgi-bin/man-cgi?brk+2)
只需阅读 手册页:
brk() 和 sbrk() 更改程序断点,定义进程数据段的结束位置(即程序断点是未初始化数据段结束后的第一个位置)。增加程序中断具有给进程分配内存的作用;减少中断会释放内存。
brk() 将数据段的末尾设置为 addr 指定的值,当该值合理时,系统有足够的内存,并且进程不会超过其最大数据大小(请参阅 setrlimit(2))。
sbrk() 通过增加字节来增加程序的数据空间。以 0 为增量调用 sbrk() 可用于查找程序中断的当前位置。
Just read the man page:
brk() and sbrk() change the location of the program break, which defines the end of the process's data segment (i.e., the program break is the first location after the end of the uninitialized data segment). Increasing the program break has the effect of allocating memory to the process; decreasing the break deallocates memory.
brk() sets the end of the data segment to the value specified by addr, when that value is reasonable, the system has enough memory, and the process does not exceed its maximum data size (see setrlimit(2)).
sbrk() increments the program's data space by increment bytes. Calling sbrk() with an increment of 0 can be used to find the current location of the program break.