posts - 297,  comments - 15,  trackbacks - 0

NAME
       brk, sbrk - change data segment size

SYNOPSIS
       #include <unistd.h>

       int brk(void *end_data_segment);

       void *sbrk(intptr_t increment);

DESCRIPTION
       brk()  sets the end of the data segment to the value specified by end_data_segment,
       when that value is reasonable, the system does have enough memory and  the  process
       does not exceed its max data size (see setrlimit(2)).

       sbrk() increments the program's data space by increment bytes.  sbrk() isn't a sys-
       tem call, it is just a C library wrapper.  Calling sbrk() with an  increment  of  0
       can be used to find the current location of the program break.

RETURN VALUE
       On  success,  brk()  returns zero, and sbrk() returns a pointer to the start of the
       new area.  On error, -1 is returned, and errno is set to ENOMEM.

CONFORMING TO
       4.3BSD

       brk() and sbrk() are not defined in the C Standard and  are  deliberately  excluded
       from the POSIX.1 standard (see paragraphs B.1.1.1.3 and B.8.3.3).

NOTES
       Various  systems  use  various  types for the parameter of sbrk().  Common are int,
       ssize_t, ptrdiff_t, intptr_t.  XPGv6 obsoletes this function.

SEE ALSO
       execve(2), getrlimit(2), malloc(3)

    The brk() and sbrk() functions are used to change the amount of memory
    allocated in a process's data segment. They do this by moving the loca-
    tion of the ``break''. The break is the first address after the end of  
    the process's uninitialized data segment (also known as the ``BSS'').


brk and sbrk设置的是BSS里的边界,具体什么是BSS呢
bss = "Block Started by Symbol" (由符号启始的区块)

Dennis Ritchie 曾说过:
这个缩写也许有其它说法,但事实上我们采用这个缩写的本意是
"Block Started by Symbol"。它是 FAP 上的伪指令,FAP
(Fortran Assembly [-er?] Program) 是指 IBM 704-709-7090-7094
这种机型的组译器。这个指令可定义自己的标号,并且预留一定数目
的字组空间。还有另一个伪指令 BES,是 "Block Ended by
Symbol",跟 BSS 指令几乎一样,不同点在于标号是定义在预留字组
空间尾端的地址 + 1 的地方。在这些机器上,Fortran 的数组是以反
方向储存,而且数组的索引是从 1 算起。

这种用法是合理的,因为这跟 UNIX 上标准的程序加载器一样,程序
码当中并非真的放入这一整块预留空间,而是先用一个数目表示,在
加载时才真的把所需的预留空间定出来。
from:
Linux man page and
http://www.linuxforum.net/forum/gshowflat.php?Cat=&Board=linuxK&Number=300677&page=16&view=collapsed&sb=5&o=all&fpart=

posted on 2010-02-18 19:23 chatler 阅读(649) 评论(0)  编辑 收藏 引用 所属分类: Linux_Coding

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理


<2024年12月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

留言簿(10)

随笔分类(307)

随笔档案(297)

algorithm

Books_Free_Online

C++

database

Linux

Linux shell

linux socket

misce

  • cloudward
  • 感觉这个博客还是不错,虽然做的东西和我不大相关,觉得看看还是有好处的

network

OSS

  • Google Android
  • Android is a software stack for mobile devices that includes an operating system, middleware and key applications. This early look at the Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language.
  • os161 file list

overall

搜索

  •  

最新评论

阅读排行榜

评论排行榜