参考:http://www.win.tue.nl/~aeb/linux/lk/lk-3.html
glibc是gnu发布的libc库,也即c运行库。glibc是linux系统中最底层的api(应用程序开发接口),几乎其它任何的运行 库都会倚赖于glibc。glibc除了封装linux操作系统所提供的系统服务外,它本身也提供了许多其它一些必要功能服务的实现,主要的如下:
(1)string,字符串处理
(2)signal,信号处理
(3)dlfcn,管理共享库的动态加载
(4)direct,文件目录操作
(5)elf,共享库的动态加载器,也即interpreter
(6)iconv,不同字符集的编码转换
(7)inet,socket接口的实现
(8)intl,国际化,也即gettext的实现
(9)io
(10)linuxthreads
(11)locale,本地化
(12)login,虚拟终端设备的管理,及系统的安全访问
(13)malloc,动态内存的分配与管理
(14)nis
(15)stdlib,其它基本功能
linux kernel中解释:
3.Application programs and C library
The programmer who writes the canonical program
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }programs for the libc interface. This C program calls the routine
printf()
that is part of the C library. A large part of the API (Application Program(ming) Interface) of the C library in a Unix environment is described by POSIX. The latest version of this standard is
POSIX 1003.1-2001
.
From the viewpoint of the application programmer (and from the viewpoint of the POSIX standard) there is no distinction between library routines and system calls. Kernel and C library together provide the services described.
Many things are handled by the C library itself - those are the things the user could have programmed himself, but need not since the author of the library did this job already. Maybe the presence of the library also saves some memory: many utilities can share common library code.
But for the basic things, starting programs, allocating memory, file I/O etc., the C library invokes the kernel.
内核和C库一起完成调用的服务,C库里面有些系统调用的动作已经在里面实现了,复用即可。对于像分配内存、控制io这些基本动作,C库需要调用内核来完成。