Search results for

All search results
Best daily deals

Affiliate links on Android Authority may earn us a commission. Learn more.

What is a kernel and why does it matter?

Here's what you need to know.

Published onMay 31, 2022

What is a kernel? Android is an example of an OS that uses a kernel
C. Scott Brown / Android Authority

Spend enough time around Android, or even PCs, and eventually, you will come across the term, “the Linux kernel.” Android uses the Linux kernel too. In fact, it’s an integral part of the way your phone works, but what is it?

The “Linux” part is easy enough to understand — it is a play-on-words between Linus and Unix, as in Linus Torvalds, the original creator of the Unix-like OS we call Linux. But kernel? What is a kernel in computers and other devices? What do we mean by the Linux kernel? Let’s find out!

In a nutshell, a kernel is the core program that manages your phone’s CPU resources, the system memory, and the system devices (including the file systems and networking). It is also responsible for managing all the processes or tasks that are running on your smartphone. That means that when you start an app, it is the kernel that loads the app into memory, creates the processes needed, and starts the app running. When an app needs memory, it is the kernel that allocates it. When the app wants networking, it is the kernel that does all the low-level processing.

A kernel is the core program that manages your phone's CPU resources, memory, and system devices.

The driver for devices like Bluetooth is also in the kernel. When the app wants to perform a task in the background, it is the kernel that handles the background threads. When the app closes, it is the kernel that cleans up all the memory and other resources that were used by the app. As you can see, a kernel is a fundamental part that ensures your Android phone actually does what you expect.

What is a kernel: A closer look

All multi-tasking operating systems have a kernel of one form or another. Windows has a kernel, OS X has a kernel, iOS has a kernel, and of course Android has a kernel. But of those, only Android uses the Linux kernel. Windows has its kernel, often referred to as the NT kernel, while OS X and iOS use a kernel known as Darwin.

There are other kernels out there, including Unix-like kernels from the FreeBSD, OpenBSD, and NetBSD projects; real-time kernels from projects like FreeRTOS; embedded kernels from projects like Zephyr; and even low power kernels like the mbed OS kernel from Arm. What this means is that any computing device from an IoT thing or wearable right up to a supercomputer uses a kernel.

All multi-tasking operating systems have a kernel of one form or another.

The Linux kernel is a complex piece of software. It contains millions of lines of source code. That includes all the drivers (the majority of the code) plus the support for the different system architectures (ARM, x86, RISC-V, PowerPC, etc). When the kernel is built for a particular device, say a smartphone, not all of that source code is used, however even when you strip away what isn’t needed for a particular build, it is still complex.

Related: Arm vs x86 — Instruction sets, architecture, and all key differences explained

Monolithic vs microkernel

balanced scale with performance on one side and battery on the other

As with all complex systems, there are different approaches that can be used when it comes to designing a kernel. The Linux kernel is what is known as a monolithic kernel. This means that the kernel is one program using one memory space. The main alternative is the microkernel approach. With microkernels, the essentials of the kernel are placed in the smallest possible program and they interact with other kernel-level programs which run as separate servers or services.

Back in 1992 when Linux was in its early days, Linus Torvalds and Professor Andrew Tanenbaum (who is famous for his books on operating system design and networking) had an online discussion (some say a flame war) about the different merits of monolithic kernel designs versus microkernels. Tanenbaum preferred microkernels and Linus was writing a monolithic kernel. That is now all history as Linux has remained a monolithic kernel, as is the kernel used in Android. If you are interested in a Unix-like microkernel operating system then you should check out Minix 3.

Monolithic vs Microkernel OS structure

Since Linux is a monolithic kernel there needs to be a way to enable and disable certain parts of the kernel depending on your needs. This is done at compile time using a system that allows the kernel to be tuned, trimmed, and configured as needed. Some of the configurations do more than just activate or deactivate certain functions — they actually change the behavior of the kernel. This is useful when it comes to building and changing smartphone hardware features.

As Linux is open-source, and because the core of Android is itself is open-source thanks to the Android Open Source Project (AOSP), there is a community of developers and enthusiasts that provide alternative kernels for Android smartphones. However, their popularity and availability are dependent on the exact make and model of your device.

How Android uses Linux

Android 12 version numbers running on Pixel 3 XL
Gary Sims / Android Authority

On the surface, Android is a nice launcher, some apps like the Chrome web browser or your social media apps, and maybe some games. But there is more going on than meets the eye. Underneath the user interface, there are lots of subsystems, libraries, and frameworks.

For apps to run (either natively or in a Java Virtual Machine) Android provides lots of libraries and frameworks for things like notifications, location services, fonts, web rendering, SSL, window management, and so on. There is also a special service called the SurfaceFlinger, which is responsible for compositing all the different things that need to be drawn into a single buffer that is then displayed on the screen.

Beneath the Android-specific libraries and frameworks is the Linux kernel. As well as managing the processes, the memory, and power management, the Linux kernel contains code for all the different chip architectures and hardware drivers it supports. These drivers include the cameras, Bluetooth, Wi-Fi, flash memory, USB, and audio drivers.

See also: Every Android 12 feature you should know about

Android also adds some special features to the Linux kernel to make it more suitable for smartphones. These include the Low Memory Killer, a process that monitors the memory state and reacts to high memory demands by killing the least essential processes and so keeps the system running, and wake locks, a way for apps to tell the kernel that the device needs to stay on.

Android adds special features to the Linux kernel to make it more suitable for smartphones.

Android 8.0 introduced Project Treble, a re-architecture of Android that created a well-defined interface between the OS framework and device-specific low-level software. Using Linux kernel modules, the SoC and the board-specific drivers were split away from the main kernel, meaning that smartphone makers could work on specific features of a device without needing to alter the core kernel. Treble was designed to make it easier for manufacturers to update their smartphones without worrying about the low-level code.

Android 12 Android version showing Linux kernel 4.9.270
Gary Sims / Android Authority

How do smartphone companies tweak the kernel?

Due to the vast diversity of Android devices, the kernel running on each make and model will be slightly different. There will be specific drivers for the SoC, as well as for other modules like GPS, audio, etc. Each smartphone maker will work together with the SoC provider (Qualcomm, MediaTek, etc) to configure the kernel in the most optimal way for any particular model. This means that smartphone makers will often work on device-specific features, override common kernel configurations, and add new drivers to the Linux kernel.

A good example of a common tweak is the CPU scheduler. When the kernel needs to decide which task should run next, and on which CPU core, it uses a scheduler. Most Android smartphones are heterogeneous multi-processor (HMP) systems. That means that not all the cores in the processor are equal. Some are high-performance, while others offer greater energy efficiency. Using the Energy-Aware Scheduler (EAS), the kernel can predict the impact of its decisions on the energy consumed by CPUs, as well as the performance level available.

Every smartphone has a slightly different kernel that caters to its unique hardware.

The parameters for the EAS can be tweaked by smartphone makers to favor greater performance while using more energy, or lower performance while saving battery. The smartphone makers also have the option to replace the scheduler with one of their own devising.

Every smartphone maker strives to configure the kernel in the best way to enable all the features needed while offering the best performance with the highest possible efficiency. Together with the SoC maker, there are engineers who work to tune the software to get the most from the hardware.

Related: Snapdragon SoC guide — All of Qualcomm’s smartphone processors explained

Having said that, smartphone makers aren’t beyond making mistakes or making bad decisions about the way they configure the Linux kernel. OEMs have been known to use setups that are too aggressive in the pursuit of good battery life. For example, OnePlus was caught throttling the performance of the OnePlus 9 Pro to preserve battery life, while others have been known to cheat and artificially boost the CPU performance when a benchmark is running.

The future of how Android uses the Linux kernel

One of the negative sides to the success of Linux is that it changes quickly. To provide a level of stability, there are Long Term Support (LTS) versions of the kernel that are supported for several years. The Android Common Kernels (ACKs) are taken from the main Linux kernel and include patches specific to Android.

Starting with Android 11, the ACKs are used to create Generic Kernel Images (GKIs). These are 64-bit Arm kernels that can be used on any device, if the SoC and driver support are implemented in vendor modules. The idea is to address the issue of kernel fragmentation by unifying the core kernel and moving SoC-specific parts out of the kernel and into loadable modules. This in turn will reduce the kernel maintenance burden for OEMs, while separating hardware-specific components from the core kernel.

One of the negative sides to the success of Linux is that it changes quickly.

Android 12 saw the first release of some devices with GKI kernels. Google has committed to regularly releasing signed boot images with critical bug fixes. Because of the binary stability offered by the GKIs, these images can be installed with no changes to vendor images.

GKI 2.0 was introduced in Android 12 for devices that ship with Linux 5.10 kernels (or later). GKI 2.0 aims to ship kernels that don’t introduce significant performance or power regressions, enable Google’s partners to deliver kernel security fixes and bug fixes without vendor involvement, and allow for a single GKI kernel binary per architecture. It is likely that Android 13 will devices will also ship with at least Linux kernel 5.10.

The result will be an improvement in the way Google can release newer Linux kernels for general use, which in turn will help improve security, and has the potential to increase the number of years that a device receives updates and fixes. Fingers crossed.

Up next: What are Android security updates, and why do they matter?

You might like