
The
Linux kernel
The Linux kernel is a Free and open-source software, free and open source Unix-like kernel (operating system), kernel that is used in many computer systems worldwide. The kernel was created by Linus Torvalds in 1991 and was soon adopted as the k ...
provides multiple interfaces to
user-space and kernel-mode code. The interfaces can be classified as either
application programming interface
An application programming interface (API) is a connection between computers or between computer programs. It is a type of software Interface (computing), interface, offering a service to other pieces of software. A document or standard that des ...
(API) or
application binary interface
An application binary interface (ABI) is an interface exposed by software that is defined for in-process machine code access. Often, the exposing software is a library, and the consumer is a program.
An ABI is at a relatively low-level of a ...
(ABI), and they can be classified as either kernel–user space or kernel-internal.
Linux API

The Linux API includes the kernel–user space API, which allows code in user space to access system resources and services of the Linux kernel. It is composed of the system call interface of the Linux kernel and the subroutines in the
C standard library
The C standard library, sometimes referred to as libc, is the standard library for the C (programming language), C programming language, as specified in the ISO C standard.International Organization for Standardization, ISO/International Electrote ...
. The focus of the development of the Linux API has been to provide the ''usable features'' of the specifications defined in
POSIX
The Portable Operating System Interface (POSIX; ) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines application programming interfaces (APIs), along with comm ...
in a way which is reasonably compatible, robust and performant, and to provide additional useful features not defined in POSIX, just as the kernel–user space APIs of other systems implementing the POSIX API also provide additional features not defined in POSIX.
The Linux API, by choice, has been kept stable over the decades through a policy of not introducing breaking changes; this stability guarantees the portability of
source code
In computing, source code, or simply code or source, is a plain text computer program written in a programming language. A programmer writes the human readable source code to control the behavior of a computer.
Since a computer, at base, only ...
. At the same time, Linux kernel developers have historically been conservative and meticulous about introducing new system calls.
Much available
free and open-source software
Free and open-source software (FOSS) is software available under a license that grants users the right to use, modify, and distribute the software modified or not to everyone free of charge. FOSS is an inclusive umbrella term encompassing free ...
is written for the POSIX API. Since so much more development flows into the Linux kernel as compared to the other POSIX-compliant combinations of kernel and C standard library, the Linux kernel and its API have been augmented with additional features. Programming for the full Linux API, rather than just the POSIX API, may provide advantages in cases where those additional features are useful. Well-known current examples are
udev,
systemd and
Weston
Weston may refer to:
Places Australia
* Weston, Australian Capital Territory, a suburb of Canberra
* Weston, New South Wales
* Weston Creek, a residential district of Canberra
* Weston Park, Canberra, a park
Canada
* Weston, Nova Scotia
* W ...
. People such as
Lennart Poettering openly advocate to prefer the Linux API over the POSIX API, where this offers advantages.
At
FOSDEM
Free and Open source Software Developers' European Meeting (FOSDEM) is an annual software engineering conference. It is non-commercial and volunteer-organized with a focus on free and open-source software. Initiated in 2000, it is usually held d ...
2016,
Michael Kerrisk explained some of the perceived issues with the Linux kernel's user-space API, describing that it contains multiple design errors by being non-extensible, unmaintainable, overly complex, of limited purpose, in violation of standards, and inconsistent. Most of those mistakes cannot be fixed because doing so would break the ABI that the kernel presents to the user space.
System call interface of the Linux kernel
The ''system call interface'' of a kernel is the set of all implemented and available
system calls in a kernel. In the Linux kernel, various subsystems, such as the
Direct Rendering Manager (DRM), define their own system calls, all of which are part of the system call interface.
Various issues with the organization of the Linux kernel system calls are being publicly discussed. Issues have been pointed out by Andy Lutomirski,
Michael Kerrisk and others.
The C standard library

A
C standard library
The C standard library, sometimes referred to as libc, is the standard library for the C (programming language), C programming language, as specified in the ISO C standard.International Organization for Standardization, ISO/International Electrote ...
for Linux includes wrappers around the system calls of the Linux kernel; the combination of the Linux kernel system call interface and a C standard library is what builds the Linux API. Some popular implementations of the C standard library are
*
glibc
The GNU C Library, commonly known as glibc, is the GNU Project implementation of the C standard library. It provides a wrapper around the system calls of the Linux kernel and other kernels for application use. Despite its name, it now also dir ...
*
uClibc
*
klibc
*
Newlib
*
musl
*
dietlibc
*
libbionic and
libhybris
Although the landscape is shifting, amongst these options, glibc remains the most popular implementation, to the point of many treating it as the default and the term equivalent to libc.
Additions to POSIX
As in other
Unix-like
A Unix-like (sometimes referred to as UN*X, *nix or *NIX) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Uni ...
systems, additional capabilities of the Linux kernel exist that are not part of POSIX:
*
cgroups subsystem, the system calls it introduces and libcgroup
* The system calls of the
Direct Rendering Manager, especially the driver-private ioctls for the command submission, are ''not'' part of the POSIX specifications.
*
Advanced Linux Sound Architecture ''could'' set system calls, which are not part of the POSIX specifications
* The system calls
futex
(fast userspace mutex),
epoll
,
splice
,
dnotify
,
fanotify
, and
inotify
have been exclusive to the Linux kernel so far.
* The system call
getrandom
was introduced in version 3.17 of the
Linux kernel mainline
*
memfd
was proposed by the
kdbus developers
**
memfd_create
was merged into the Linux kernel mainline in kernel version 3.17
*
readahead
initiates a file "read-ahead" into page cache
DRM has been paramount for the development and implementations of well-defined and performant
free and open-source graphics device drivers without which no rendering acceleration would be available at all, only the 2D drivers would be available in the
X.Org Server. DRM was developed for Linux, and since has been ported to other operating systems as well.
Further libraries
* libdrm (for
Direct Rendering Manager)
* libnl (The libnl suite is a collection of libraries providing APIs to netlink protocol based Linux kernel interfaces.)
* libevdev (for
evdev)
* libasound (
Advanced Linux Sound Architecture)
Linux ABI

The Linux ABI is a kernel–user space ABI. As ABI is a
machine code interface, the Linux ABI is bound to the
instruction set
In computer science, an instruction set architecture (ISA) is an abstract model that generally defines how software controls the CPU in a computer or a family of computers. A device or program that executes instructions described by that ISA, s ...
. Defining a useful ABI and keeping it stable is less the responsibility of the Linux kernel developers or of the developers of the GNU C Library, and more the task for
Linux distribution
A Linux distribution, often abbreviated as distro, is an operating system that includes the Linux kernel for its kernel functionality. Although the name does not imply product distribution per se, a distro—if distributed on its own—is oft ...
s and
independent software vendors (ISVs) who wish to sell and provide support for their proprietary software as binaries only for such a single Linux ABI, as opposed to supporting multiple Linux ABIs.
An ABI has to be defined for every instruction set, such as
x86,
x86-64
x86-64 (also known as x64, x86_64, AMD64, and Intel 64) is a 64-bit extension of the x86 instruction set architecture, instruction set. It was announced in 1999 and first available in the AMD Opteron family in 2003. It introduces two new ope ...
,
MIPS,
ARMv7-A (32-Bit),
ARMv8-A (64-Bit), etc. with the
endianness
file:Gullivers_travels.jpg, ''Gulliver's Travels'' by Jonathan Swift, the novel from which the term was coined
In computing, endianness is the order in which bytes within a word (data type), word of digital data are transmitted over a data comm ...
, if both are supported.
It should be able to compile the software with different compilers against the definitions specified in the ABI and achieve full binary compatibility. Compilers that are
free and open-source software
Free and open-source software (FOSS) is software available under a license that grants users the right to use, modify, and distribute the software modified or not to everyone free of charge. FOSS is an inclusive umbrella term encompassing free ...
are e.g.
GNU Compiler Collection
The GNU Compiler Collection (GCC) is a collection of compilers from the GNU Project that support various programming languages, Computer architecture, hardware architectures, and operating systems. The Free Software Foundation (FSF) distributes ...
,
LLVM
LLVM, also called LLVM Core, is a target-independent optimizer and code generator. It can be used to develop a Compiler#Front end, frontend for any programming language and a Compiler#Back end, backend for any instruction set architecture. LLVM i ...
/
Clang
Clang () is a compiler front end for the programming languages C, C++, Objective-C, Objective-C++, and the software frameworks OpenMP, OpenCL, RenderScript, CUDA, SYCL, and HIP. It acts as a drop-in replacement for the GNU Compiler ...
.
In-kernel APIs
Many kernel-internal APIs exist, allowing kernel subsystems to interface with one another. These are being kept fairly stable, but there is no guarantee for stability. A kernel-internal API can be changed when such a need is indicated by new research or insights; all necessary modifications and testing have to be done by the author.
The Linux kernel is a monolithic kernel, hence device drivers are kernel components. To ease the burden of companies maintaining their (proprietary) device drivers outside of the main kernel tree, stable APIs for the device drivers have been repeatedly requested. The Linux kernel developers have repeatedly denied guaranteeing stable in-kernel APIs for device drivers. Guaranteeing such would have faltered the development of the Linux kernel in the past and would still in the future and, due to the nature of free and open-source software, are not necessary. Ergo, by choice, the Linux kernel has no ''stable'' in-kernel API.
In-kernel ABIs
Since there are no stable in-kernel APIs, there cannot be stable in-kernel ABIs.
Abstraction APIs

For many use cases, the Linux API is considered too low-level, so APIs of higher abstraction must be used. Higher-level APIs must be implemeted on top of lower-level APIs. Examples:
* Implementation of the
OpenGL
OpenGL (Open Graphics Library) is a Language-independent specification, cross-language, cross-platform application programming interface (API) for rendering 2D computer graphics, 2D and 3D computer graphics, 3D vector graphics. The API is typic ...
and
Vulkan specifications in proprietary Linux graphics drivers and the free and open-source implementation in
Mesa.
* Implementation of the
OpenAL specification.
*
Simple DirectMedia Layer: abstraction API for input/sound/etc. available for many operating systems.
*
Simple and Fast Multimedia Library: like above.
See also
*
*
* '
*
*
*
*
*
*
References
External links
The Linux Kernel API 5.0(new
sphinx
A sphinx ( ; , ; or sphinges ) is a mythical creature with the head of a human, the body of a lion, and the wings of an eagle.
In Culture of Greece, Greek tradition, the sphinx is a treacherous and merciless being with the head of a woman, th ...
format)
The API of Linux kernel 2.6.20an
4.12(in deprecated htmldocs format)
API/ABI changes review for LinuxThe Linux Programming Interfacebook
Linux and ''glibc'' API changessince
The Linux Programming Interface was released in 2010
* with main API functions and structures, version
* by Jonathan Corbet, Greg Kroah-Hartman and Alessandro Rubini, 3rd edition
Linux Kernel Linked List Explained
{{DEFAULTSORT:Linux Kernel Api