Linux Kernel and Android

Why do we use the Linux Kernel in Android ?

If you spend enough time around Android or even PCs, you'll soon hear the term "Linux kernel." The Linux kernel is also used by Android. In fact, it's a delicate aspect of how your phone functions/operates, but what exactly is it?

Its component is straightforward: it's a pun on Linux and Unix, as in Linus Torvalds, the original designer of the Unix-like OS we now name Linux. But what about the kernel?

Like a seed inside a hard shell, the kernel resides within the OS and conducts all the hardware's main activities, whether it's a phone, laptop, server, or any other sort of computer. Stay tuned as we take you on a journey through this post as we learn more about the Linux kernel.

What is a Linux kernel?

The Linux kernel is the most significant component of a Linux operating system, since it serves as the primary interface between a computer's hardware and its functions (OS). It connects the two, allowing for the most efficient use of resources. Like a seed inside a hard shell, it resides within the OS and conducts all the hardware's critical tasks, whether it's a phone, laptop, server, or any other sort of computer.

The kernel is responsible for low-level operations such as disk management, memory management, task management, and so on. It connects the user to the hardware components of the system. When a process requests anything from the kernel, this is called a System Call.

A kernel has its own protected kernel Region, which is a separate memory space that is unavailable to other applications. As a result, the kernel's code is loaded into the kernel space, which is secure. User space also refers to the RAM used by other programs. Communication is a little slower between them since they are two separate memory regions.

What is the main purpose of the Kernel?

A kernel exists in some form in all multitasking operating systems. Windows has a kernel, as does OS X, iOS has a kernel, and Android, of course, has a kernel. Only Android, however, uses the Linux kernel. Windows has its own kernel, known as the NT kernel, whereas OS X and iOS utilize the Darwin kernel. Other kernels exist, including Unix-like kernels from the FreeBSD, OpenBSD, and NetBSD projects; real-time kernels from FreeRTOS; embedded kernels from Zephyr; and even low-power kernels from Arm, such as the embed OS kernel. This implies that a kernel is used by any computing device, from an IoT gadget or wearable to a supercomputer.

Some functions of the kernel are:

  • A kernel may access a variety of computer resources such as the CPU, I/O devices, and other resources. It serves as a link between the user and the system's resources.
  • Resource Management: It is the responsibility of a kernel to share resources across multiple processes in such a way that each process has uniform access to the resources.
  • Memory Management: Every process necessitates a certain amount of memory. As a result, memory must be allocated and released for it to run. A kernel is in charge of memory management.
  • Device Management: The procedures take advantage of the peripheral devices linked to the system. As a result, the kernel oversees device allocation.

Why is the Linux kernel used in the Android operating system?

The Android operating system is based on the Linux kernel, with certain architectural tweaks by Google. The Linux kernel was chosen for a variety of reasons. Most notably, Linux is a portable operating system that can be quickly built on a variety of hardware.

The kernel serves as a layer of abstraction between the device's software and hardware. Consider the scenario of a camera shutter release. What occurs when you use your device's camera button to snap a photo? The hardware instruction (pressing a button) must be transformed to a software instruction at some point (to take a picture and store it in the gallery).

Drivers are included in the kernel to help with this procedure. When a user pushes a button, the instruction is sent to the kernel's related camera driver, which delivers the required commands to the camera hardware, just as when a key is pushed on a keyboard. The drivers in the kernel command, in basic terms, control the underlying hardware. Android's basic functionality, including process management, memory management, security, and networking, is managed by the Linux kernel. When it comes to security and process management, Linux is a tried-and-true platform.

Android has built a solid basis for its ecosystem by leveraging the existing Linux open-source OS. The underlying Linux kernel is different for each version of Android.

The kernel is the most important component of every operating system. It oversees the computer's and hardware's functions, particularly memory and CPU time. Kernels are divided into two categories: A microkernel provides just minimal functionality; a monolithic kernel comprises many device drivers. Android was created with a strong emphasis on security. Android as a platform provides and enforces various measures that employ multi-layered security to protect user data on mobile devices. There are certain safe defaults that will safeguard the user, as well as some options that the development community may use to construct secure apps.

How Android uses Linux

On the surface, Android appears to be a decent launcher with a few apps, such as the Chrome web browser or social networking apps, and maybe some games. However, there is more to this than meets the eye. There are several subsystems, libraries, and frameworks behind the user interface. For features like alerts, location services, fonts, web rendering, SSL, window management, and so on, Android provides a multitude of libraries and frameworks for apps to run (either natively or through a Java Virtual Machine). A unique service called the SurfaceFlinger is in charge of composing all the different items that need to be drawn into a single buffer, which is subsequently shown on the screen.

The Linux kernel sits behind the Android-specific modules and frameworks. The Linux kernel comprises code for all the numerous chip architectures and device drivers it supports, in addition to controlling processes, memory, and power management. Cameras, Bluetooth, Wi-Fi, flash memory, USB, and audio drivers are among them. To make the Linux kernel more suited for smartphones, Android adds several additional capabilities to it. Low Memory Killer, a process that checks memory status and reacts to high memory demands by killing the least critical programs while keeping the system functioning, and wake locks, a means for apps to inform the kernel that the device needs to stay on, are two examples.

Project Treble, a re-architecture of Android that developed a well-defined interface between the OS framework and device-specific low-level applications, was released in Android 8.0. The SoC and board-specific drivers were separated from the main kernel using Linux kernel modules, allowing smartphone producers to focus on specialized functionality without having to change the core kernel. Treble was created to make it easy for smartphone makers to upgrade their devices without having to worry about low-level code.

Linux Kernel in Android for Business

Because of the wide variety of Android devices, the kernel that runs on each make and model will change significantly. There will be drivers for the SoC as well as additional modules like GPS, audio, and so on. Each smartphone manufacturer will collaborate with the SoC vendor (Qualcomm, MediaTek, and others) to optimize the kernel for each model. Smartphone manufacturers will frequently work on device-specific features, override conventional kernel configurations, and introduce new drivers to the Linux kernel because of this.

One of the disadvantages of Linux's success is that it evolves rapidly. Long Term Support (LTS) versions of the kernel are sustained for several years to give a degree of reliability. The Android Common Kernels (ACKs) change for the Linux kernel that is particular to Android. The ACKs are used to produce Generic Kernel Images starting with Android 11. (GKIs). These are 64-bit Arm kernels that may be used on any device with vendor-supplied SoC and driver support. The goal is to reduce kernel fragmentation by unifying the core kernel and transferring SoC-specific components out of the kernel and into loadable modules.

As a result, OEMs will have less kernel maintenance to deal with, and hardware-specific components will be separated from the core kernel. Some devices with GKI kernels were released for the first time in Android 12. Google has committed to delivering signed boot images with major issue fixes on a regular basis. These images may be installed with no modifications to vendor images due to the binary stability provided by the GKIs.

Consequently, Google's ability to deliver newer Linux kernels for wide usage will improve, which will assist enhance security and perhaps increase the number of years a device receives updates and patches. It functions similarly to Emteria, which can create large-scale Android goods while operating them remotely and maintaining long-term security.

Back to Learning Center