ArticleslgStudy

science

Linux kernel interfaces

Linux kernel interfaces is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Linux kernel interfaces rather than just read about it. In short: The Linux kernel provides multiple interfaces to user-space and kernel-mode code. The interfaces can be classified as either application programming interface (API) or application binary interface (ABI), and they can be classified as either kernel–user space or kernel-internal.

Linux kernel interfaces — main illustration
Linux kernel interfaces — illustration

Key takeaways

  • Linux kernel interfaces belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Linux kernel interfaces to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Linux kernel interfaces from memory before moving on to harder problems.

Reference excerpt

The Linux kernel provides multiple interfaces to user-space and kernel-mode code. The interfaces can be classified as either application programming interface (API) or application binary interface (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 focus of the development of the Linux API has been to provide the usable features of the specifications defined in POSIX 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. 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 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. People such as Lennart Poettering openly advocate to prefer the Linux API over the POSIX API, where this offers advantages. At FOSDEM 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 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 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 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. 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 distributions 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, MIPS, ARMv7-A (32-Bit), ARMv8-A (64-Bit), etc. with the endianness, 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 are e.g. GNU Compiler Collection, LLVM/Clang.

… excerpt ends here. Continue reading the full article.

Illustrations

Linux kernel interfaces: Linux API, Linux ABI, and in-kernel APIs and ABIs
Linux API, Linux ABI, and in-kernel APIs and ABIs
Linux kernel interfaces: The Linux API is composed of the system call interface of the Linux kernel, the GNU C Library (by GNU), libcgroup,[1] libdrm, libalsa and libevdev[2] (by freedesktop.org).
The Linux API is composed of the system call interface of the Linux kernel, the GNU C Library (by GNU), libcgroup,[1] libdrm, libalsa and libevdev[2] (by freedesktop.org).
Linux kernel interfaces: Linux API vs. POSIX API
Linux API vs. POSIX API
Linux kernel interfaces: The GNU C Library is a wrapper around the Linux kernel system call interface.
The GNU C Library is a wrapper around the Linux kernel system call interface.
Linux kernel interfaces: The Linux API and ABI
The Linux API and ABI

Worked examples

Example 1 — a first encounter with Linux kernel interfaces

Start with the simplest possible case. Write down what Linux kernel interfaces claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Linux kernel interfaces before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Linux kernel interfaces ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Linux kernel interfaces

In research
Linux kernel interfaces appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Linux kernel interfaces in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Linux kernel interfaces is common in secondary-school and first-year university syllabi. It links to neighbouring topics Interfaces of the Linux kernel, so understanding it makes those chapters shorter.
In everyday life
Look for Linux kernel interfaces outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Linux kernel interfaces” →

How to study Linux kernel interfaces in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Linux kernel interfaces means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Linux kernel interfaces out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Linux kernel interfaces in simple terms?

The Linux kernel provides multiple interfaces to user-space and kernel-mode code. The interfaces can be classified as either application programming interface (API) or application binary interface (ABI), and they can be classified as either kernel–user space or kernel-internal.

Why does Linux kernel interfaces matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Linux kernel interfaces?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Linux kernel interfaces.

Tags

  • Interfaces of the Linux kernel

Keep exploring