Search code examples
linuxunixsolarisbsdsystem-calls

System Calls: UNIX, Linux, BSD and Solaris variations


Are there differences between the amount of syscalls in the major *NIX variants ?

Which syscalls would be supported universally ?


Solution

  • Anything that is not a posix standard may be an additional system call, or it maybe additional library functionality above the system call layer. 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.

    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. 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. 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. 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.

    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. If your goal is to write something that links against the standard libraries on various Unixes you can get a generally uniform interface.