Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 13: System Calls


13.1.2 Supported Standards


System calls are of special significance in allUnixlook-alikes. Their scope and speed and their efficient
implementation play a major role in system performance. System calls are implemented extremely effi-
ciently in Linux, as demonstrated in Section 13.3. Of equal importance are the versatility and choice of
available routines to make the lives of programmers (of applications and of standard library functions)
easier and to facilitate program portability between the variousUnixderivatives on source text level. In
the more than 25-year history ofUnix, this has contributed to the emergence of standards and de facto
standards governing the uniformity of interfaces between the various systems.

The POSIX standard (whose acronym —Portable Operating System Interface forUnix— reveals its
purpose) has emerged as the dominant standard. Linux and the C standard library also make every
effort to comply with POSIX, which is why it is worthy of brief discussion here. Since publication of
the first documents at the end of the 1980s, the standard has expanded drastically in scope (the current
version fills four volumes^3 ) and is now — in the opinion of many programmers — overlong and too
complex.

The Linux kernel is largely compatible with the POSIX-1003.1 standard. Naturally, new developments in
the standard take some time before they filter through into kernel code.

In addition to POSIX, there are other standards that are not based on the work of committees but are
rooted in the development ofUnixand its look-alikes. In the history ofUnix, two major lines of devel-
opment have produced two independent and autonomous systems — System V (which derives directly
from the original sources of AT&T) and BSD (Berkeley Software Distribution, developed at the Univer-
sity of California and now strongly represented in the marketplace under the names of NetBSD, FreeBSD,
and OpenBSD and the commercial offshoots, BSDI and MacOS X).

Linux features system calls from all three of the above sources — in a separate implementation, of course.
The code of competing systems is not used for legal and licensing reasons alone. For example, the three
well-known system calls listed below originate from the three different camps:

❑ flocklocks a file to prevent parallel access by several processes and to ensure file consistency.
This call is prescribed by the POSIX standard.
❑ BSDUnixprovides thetruncatecall to shorten a file by a specified number of bytes; Linux also
implements this function under the same name.
❑ sysfsgathers information on the filesystems known to the kernel and was introduced in System
V Release 4. Linux has also adopted this system call. However, the Linux developers might not
entirely agree with the System V designers about the true value of the call — at least, the source
code comment saysWhee.. Weird sysv syscall.
Nowadays, the information is obtained much more easily by reading/proc/filesystems.

Some system calls are required by all three standards. For example,time,gettimeofdayand
settimeofdayexist in identical form in System V, POSIX, and 4.3BSD — and consequently in the
Linux kernel.

(^3) The standard is available in electronic form atwww.opengroup.org/onlinepubs/007904975/.

Free download pdf