The Linux man-pages project documents the Linux kernel and C library interfaces that are employed by user programs. It provides manual pages in the following sections:
- 2: System calls, documenting the system calls provided by the Linux kernel.
- 3: Library functions, documenting the functions provided by the standard C library (with particular focus on glibc, the GNU C library).
- 4: Devices, which documents details of various devices, most of which reside in /dev.
- 5: Files, which describes various file formats, and includes proc(5), which documents the /proc file system.
- 7: Overviews, conventions, and miscellaneous.
从以上可以看出man究竟是针对谁的:Linux系统本身,kernel,C库.
其中第二部分对应的是System calls(系统调用),是由内核提供的;
第三部分对应的是Library functions,这部分是由标准C库(一般指的是GNU的glibc)提供的.
我们之前使用的命令 man 2 其中的2就是指定man手册的第二部分,同理可以指定其他的部分,尤其对系统调用和库函数同名的话,就需要手动指定了,如果不重名的话,这里的数字是可以省略的.
1.系统调用是为了方便应用使用操作系统的接口,而库函数是为了方便人们编写应用程序而引出的,比如你自己编写一个函数其实也可以说就是一个库函数。
2.系统调用可以理解为内核提供给我们在用户态用的接口函数,可以认为是某种内核的库函数。
3.read就是系统调用,而fread就是C标准库函数.
4.很多c函数库中的函数名与系统调用的名称一样是因为该函数本身其实就是调用的系统调用,放到c函数库就是为了用户态的使用
5.写程序直接使用的是库函数,而库函数内部可能就是调用的同名系统调用
关于系统调用详细,请看博客
http://www.cnblogs.com/yysblog/archive/2012/10/17/2728603.html