views:

1089

answers:

2

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

Which syscalls would be supported universally ?

+9  A: 

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

Louis Gerbarg
+4  A: 

The best I can find is a Unix-Linux-BSD Cheat-Sheets, for various syscalls variations, to be compared with the Solaris syscalls.

For Unix alone, the number of system calls has quadrupled, more or less, depending on what you mean by "system call."
The first edition of Advanced UNIX Programming focused on only about 70 genuine kernel system calls—for example, open, read, and write; but not library calls like fopen, fread, and 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.)
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

VonC
@VoriC: I wish I could choose two answers, I think you and Louis have both given great informative answers. Cheers.
_ande_turner_
Hi Ande, no problem, Louis's answer is more detailed and very interesting. It is always a good thing where there is too much 'good answers' ;)
VonC