“C 系统调用"和“C 系统调用"有什么区别?和“C 库例程"? [英] What's the difference between "C system calls" and "C library routines"?

查看:21
本文介绍了“C 系统调用"和“C 系统调用"有什么区别?和“C 库例程"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

联机帮助页中有多个部分.其中两个是:

<前>2 Unix 和 C 系统调用3 C 程序的 C 库例程

例如有 getmntinfo(3)getfsstat(2),两者看起来都在做同样的事情.什么时候应该用哪个,有什么区别?

解决方案

系统调用是操作系统函数,就像在 UNIX 上,malloc() 函数建立在 sbrk() 系统调用(用于调整进程内存空间).

库只是应用程序代码,不属于操作系统的一部分,通常可以在多个操作系统上使用.它们与您自己程序中的函数调用基本相同.

这条线可能有点模糊,但只需将系统调用视为内核级功能即可.

There are multiple sections in the manpages. Two of them are:

2     Unix and C system calls
3     C Library routines for C programs

For example there is getmntinfo(3) and getfsstat(2), both look like they do the same thing. When should one use which and what is the difference?

解决方案

System calls are operating system functions, like on UNIX, the malloc() function is built on top of the sbrk() system call (for resizing process memory space).

Libraries are just application code that's not part of the operating system and will often be available on more than one OS. They're basically the same as function calls within your own program.

The line can be a little blurry but just view system calls as kernel-level functionality.

这篇关于“C 系统调用"和“C 系统调用"有什么区别?和“C 库例程"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆