I studied like malloc uses the sbrk system call. But, some one says, the sbrk is deprecated one. Now a days malloc using the mmap2 system call to allocate memory. So, Is there any commands like (ls,cat, grep, sed) using the sbrk system call. For Ex:
mohanraj@ltsp63:~/Development/chap8$ strace -c ls a.out files flush.c fopen.c ld.c lld.c malloc.c opendir1.c t2.c t3.c t.c test.c % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- -nan 0.000000 0 12 read -nan 0.000000 0 1 write -nan 0.000000 0 13 open -nan 0.000000 0 16 close -nan 0.000000 0 1 execve -nan 0.000000 0 1 time -nan 0.000000 0 9 8 access -nan 0.000000 0 3 brk -nan 0.000000 0 3 ioctl -nan 0.000000 0 1 readlink -nan 0.000000 0 5 munmap -nan 0.000000 0 1 uname -nan 0.000000 0 11 mprotect -nan 0.000000 0 1 _llseek -nan 0.000000 0 1 getsid -nan 0.000000 0 2 rt_sigaction -nan 0.000000 0 1 rt_sigprocmask -nan 0.000000 0 1 getcwd -nan 0.000000 0 1 getrlimit -nan 0.000000 0 28 mmap2 -nan 0.000000 0 1 stat64 -nan 0.000000 0 16 fstat64 -nan 0.000000 0 1 getuid32 -nan 0.000000 0 2 getdents64 -nan 0.000000 0 1 1 futex -nan 0.000000 0 1 set_thread_area -nan 0.000000 0 1 set_tid_address -nan 0.000000 0 1 statfs64 -nan 0.000000 0 1 openat -nan 0.000000 0 1 set_robust_list -nan 0.000000 0 1 socket -nan 0.000000 0 1 connect -nan 0.000000 0 1 send ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000000 141 9 total mohanraj@ltsp63:~/Development/chap8$
The above output shows that the ls command using the above syscall to execute the output. Likewise any command using the sbrk system call, Is there any what is that?
Thanks in Advance.
Advertisement
Answer
sbrk
is not a system call in linux. It’s a library function implemented in libc which uses the brk
system call. Your strace shows brk
being used.