Met*_*est 3 c linux x86 gcc system-calls
我正在阅读Linux系统调用列表并找到sys_break,其描述如下.
Syntax: int sys_break()
Source: kernel/sys.c
Action: return -ENOSYS
Details: call exists only for compatibility
Run Code Online (Sandbox Code Playgroud)
有谁知道怎么sys_break办?或者它什么都不做?
我可能错了,但我认为它被brk(2)系统调用所取代,系统调用用于控制分配给进程数据段的内存量.原始break调用被弃用可能是因为它break是C编程语言中的关键字.我在Unix V6源代码中找到了以下注释(在1976年或之前编写):
/* break system call.
* -- bad planning: "break" is a dirty word in C.
*/
sbreak()
{
register a, n, d;
int i;
/* set n to new data size
* set d to new-old
* set n to new total size
*/
...
}
Run Code Online (Sandbox Code Playgroud)
因此,在C编程语言发明之前,Unix是用汇编语言编写的,没有定义break为保留字.
sys_break 在Unix V1中引入了系统调用号17(这是PDP-11汇编程序):
# V1/u2.s - 1971-11-03
sysbreak: / set the program break
mov u.break,r1 / move users break point to r1
cmp r1,$core / is it the same or lower than core?
blos 1f / yes, 1f
cmp r1,sp / is it the same or higher than the stack?
bhis 1f / yes, 1f
bit $1,r1 / is it an odd address
beq 2f / no, its even
clrb (r1)+ / yes, make it even
2: / clear area between the break point and the stack
cmp r1,sp / is it higher or same than the stack
bhis 1f / yes, quit
clr (r1)+ / clear word
br 2b / go back
1:
jsr r0,arg; u.break / put the "address" in u.break (set new
/ break point)
br sysret4 / br sysret
Run Code Online (Sandbox Code Playgroud)
现在,如果您比较V6和V1,您可以看到系统调用的含义随着时间的推移而发生了变化.最初它用于设置进程的断点,在V6中它基本上是brk(2)系统调用.
| 归档时间: |
|
| 查看次数: |
430 次 |
| 最近记录: |