I have read in Advanced Unix Programming (and also in a few other books) that Linux malloc()
uses the Linux system call sbrk()
to request memory from the operating system.
I am looking at the glibc malloc.c
code and I can see many mentions of sbrk()
in the comments, but not referred to directly in the code.
How/where is sbrk()
referred to/used when malloc()
requests memory from the OS?
(This could be a general misunderstanding on my part of how system calls are made from the C runtime library. If so, I would be interested to know how they are made??)
sbrk
, there's nothing different between a system call in C and a function, with the exception that control is completely managed by the operating system until the system call completes. – Hemstitchsbrk
is removed from latest Posix standard. – Sheelah