简体   繁体   中英

What is the relation between Linux kernel and GNU C library?

We know that Linux kernel is written in C. But does it also call standard C functions like malloc() or extra functions like mmap() which are provided by GNU C library (glibc)? In that case, it's strange, because direct low-level interaction with hardware, eg memory management, is supposed to be almost always the task of a kernel. So, which is dependent on the other? Which is more fundamental/low-level?

We know that Linux kernel is written in C. But does it also call standard C functions like malloc()

No. However, the kernel defines similar functions likekmalloc . Note this is not part of a library; it's part of the kernel itself.

or extra functions like mmap()

Not mmap , but there are a lot of memory management functions in the kernel.

which are provided by GNU C library (glibc)?

Definitely not. The kernel does not use glibc ever.

So, which is dependent on the other?

Some parts of glibc depends on the kernel. Other parts (like strcpy ) have nothing to do with the kernel and don't depend on it. The kernel never depends on glibc. You can run programs on Linux that use a different libc (like "musl") or that don't use a libc at all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM