简体   繁体   English

系统调用:UNIX、Linux、BSD 和 Solaris 变体

[英]System Calls: UNIX, Linux, BSD and Solaris variations

Are there differences between the amount of syscalls in the major *NIX variants ?主要 *NIX 变体中的系统调用数量之间是否存在差异?

Which syscalls would be supported universally ?哪些系统调用会得到普遍支持?

Anything that is not a posix standard may be an additional system call, or it maybe additional library functionality above the system call layer.任何不是 posix 标准的东西都可能是一个额外的系统调用,或者它可能是系统调用层之上的额外库功能。 If your goal is to write portable code stick to posix, and use the c library (as opposed to direct system calls) as much as possible.如果您的目标是编写可移植代码,请坚持使用 posix,并尽可能多地使用 c 库(而不是直接系统调用)。

If you are just curious, they vary quite widely.如果你只是好奇,它们的差异很大。 You do not need to support much in the way of system calls in order to be posix compliant.为了符合 posix,您不需要在系统调用方面提供太多支持。 It specifies interfaces you need to support, but whether you do that through calling into the kernel or jumping into a shared library is pretty much up to you.它指定了您需要支持的接口,但是是通过调用内核还是跳转到共享库来实现这一点几乎取决于您。

Mac OS X does not even guarantee binary compatibility for system calls between releases, they consider them private interfaces between the system libraries and the OS. Mac OS X 甚至不保证版本之间系统调用的二进制兼容性,他们认为它们是系统库和操作系统之间的私有接口。 What most people consider to be system calls are actually small stubs in a dynamic library that call through to the kernel, and if you make the system calls directly instead of linking to that dynamic library and calling the stub functions then your code may break between OS releases.大多数人认为的系统调用实际上是动态库中调用内核的小存根,如果您直接进行系统调用而不是链接到该动态库并调用存根函数,那么您的代码可能会在操作系统之间中断发布。

That flexibility means a number of OSes implement system calls that are completely different from what they need to support posix, then deal with the differences in their libraries.这种灵活性意味着许多操作系统实现的系统调用与其支持 posix 所需的系统调用完全不同,然后处理它们库中的差异。 For example, Linux's threading implementation is based around a system call called clone(), and they deal with much of the bookkeeping to make the pthreads interface work in their libraries.例如,Linux 的线程实现基于名为 clone() 的系统调用,它们处理大量簿记以使 pthreads 接口在其库中工作。

So if your goal is to implement a standard library the does not link against anything else and works on multiple unixes, you may find things a bit tricky in some cases.因此,如果您的目标是实现一个标准库,该库不链接其他任何东西并且可以在多个 unix 上运行,那么在某些情况下您可能会发现事情有点棘手。 If your goal is to write something that links against the standard libraries on various Unixes you can get a generally uniform interface.如果您的目标是编写一些链接到各种 Unix 上的标准库的东西,您可以获得一个统一的接口。

The best I can find is aUnix-Linux-BSD Cheat-Sheets , for various syscalls variations, to be compared with the Solaris syscalls .我能找到的最好的是Unix-Linux-BSD Cheat-Sheets ,用于各种系统调用变体,与Solaris 系统调用进行比较。

For Unix alone, the number of system calls has quadrupled, more or less, depending on what you mean by "system call."仅就 Unix 而言,系统调用的数量或多或少增加了四倍,这取决于“系统调用”的含义。
The first edition of Advanced UNIX Programming focused on only about 70 genuine kernel system calls—for example, open, read, and write; Advanced UNIX Programming 的第一版只关注了大约 70 个真正的内核系统调用——例如,打开、读取和写入; but not library calls like fopen, fread, and fwrite.但不是像 fopen、fread 和 fwrite 这样的库调用。
The second edition includes about 300. (There are about 1,100 standard function calls in all, but many of those are part of the Standard C Library or are obviously not kernel facilities.)第二版包括大约 300 个。(总共有大约 1,100 个标准函数调用,但其中许多是标准 C 库的一部分,或者显然不是内核设施。)
Today's UNIX has threads, real-time signals, asynchronous I/O, and new interprocess-communication features (POSIX IPC), none of which existed 20 years ago今天的 UNIX 拥有线程、实时信号、异步 I/O 和新的进程间通信特性 (POSIX IPC),这些特性在 20 年前都不存在

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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