I was reading the list of Linux system calls and found sys_break
, whose description is as follows.
Syntax: int sys_break()
Source: kernel/sys.c
Action: return -ENOSYS
Details: call exists only for compatibility
Does anyone know what sys_break
do? Or does it do nothing?
I might be wrong, but I assume it is replaced by brk(2)
system call which is used to control the amount of memory allocated to the data segment of the process. The original break
call was deprecated probably because break
is a keyword in C programming language. And I found following comment in Unix V6 source code (written either in or before 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
*/
...
}
So, before C programming language was invented, Unix was written in assembler which didn't define break
as reserved word.
sys_break
itself as syscall number 17 was introduced in Unix V1 (this is PDP-11 assembler):
# 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
Now if you compare the V6 and V1, you can see that the meaning of the syscall has changed over time. Originally it was used to set the breakpoint for process, in V6 it is basically the brk(2)
syscall.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With