The Linux Kernel

The Kernel

The Linux kernel is the most important component of the Linux system. It’s the part that runs the show behind the scenes. Ironically, given its importance, the kernel remains invisible with little to no mention by end users. Without going into the technicalities, I shall be focusing on the nitty-gritty and theoretical aspects of the kernel and its importance in running the Linux operating system.

The very first version of the kernel was first released by a good soul, Linus Torvalds, who created it in 1991 in response to the restrictive software licensing that was limiting other operating systems’ ability to advance. This led the movement of free software which you can read all about it here.

Setting the record straight first

Linux is a word often used to refer to the operating system when it actually points to the Linux kernel. To techies, the operating system is known as the Linux System where it implies the existence of multiple components including Linux (the kernel). It’s important to note that there is no single system that is called Linux as the kernel, by itself, isn’t as useful without its surrounding components. Instead, we have the Linux Distro which we’ll cover in a later article of this topic.

Computers, both hardware and software, are designed to be modular so they can extend their use by attaching more hardware or installing more software. Modular architecture is somewhat an industry standard and Linux is no exception. In fact, it’s the core where it all gets started.

The kernel is a piece of code (a very large one) and it interacts directly with the hardware, telling it what to do and quite literally controlling and regulating the electrical pulses that go through the CPU and other physical hardware to compute the massive amounts of zeros and ones in a fraction of a second.

There are very specific tasks that the kernel performs but in order to understand them, we first need to establish some basic understanding of how computers generally work. Click here for a refresher on how computers work or get straight to it.

What exactly is the Kernel?

The Kernel is a piece of software or a large piece of code maintained by thousands of contributors worldwide. It is responsible for performing very specific tasks that mainly relate to communicating with the computer hardware and/or translating user instructions into something the hardware can understand.

It is written and structured as a monolith, a common term among those familiar with software architecture. It means the Kernel is designed in a way that requires all of its code in order to work. Hence, the Kernel is not modular and that tells us there is no simple way for us to modify it i.e. by simply taking a part of it away. It is, however, customisable by means of modifying its entire code which you can find on their website.

The Linux Kernel is released using a general public license that is flexible enough to allow the kernel to be used in many ways. It also allows anyone to modify the source code and use it for their own needs. This created an ideal toolbox for hackers and tinkerers to start their pet projects, and soon, organisations began adopting the kernel and modifying it given its versatility in operating on any form of computer hardware, big or small. The licensing is also what contributed to the availability of many different distributions or distros as mentioned earlier.

The Kernel is like a manager that delegates tasks to his team members - in this context, the team members are computer resources. Take a service counter executive, for instance. He is only capable of serving one customer at a time. Multiple customers approaching him at the same time can be overwhelming and possibly even render him paralysed. Hence, it would help if there is a management or queuing system, and that’s what the Kernel is for computers.

The Kernel in action: managing resources

Resources exist in finite amounts with the potential to run out. Computer resources, although virtual, behave in a similar way. In the digital world, resources refer to hardware capacity or more specifically the CPU, RAM and storage capacities.

For instance, storage refers to any device capable of storing data for long periods of time such as HDD, SSD, DVD, USB drives, SD cards and so on. Computers usually use the first 2 types as they can be mounted on permanently and packaged elegantly. All storage devices share one thing in common that is their capacity which is measured typically in gigabytes e.g. 250GB, 500GB or even in terabytes e.g. 1TB.

For every file you store on a storage device, it requires a specific amount of storage that accumulates over time until the device is full and can no longer contain any further information. Other resources such as the CPU and RAM share similar qualities. For example, CPU capacity is measured in Gigahertz e.g. 1.5GHz or 2.0GHz. On the other hand, RAM is measured using the same unit as storage i.e. giga- or terabytes, though they perform very distinct tasks.

Like a tool, a resource serves a very specific purpose and when it is not in use, it is either in an idle state, or faulty where it has to be replaced.

There are other types of resources besides the 3 main ones such as graphics processing unit (GPU), sound card, network communication cards and many others. These resources are normally packaged together with the purchase of a new computer, and as such, may be mistaken to be essential parts of a computer. In reality, they are not exactly required to get a computer to work.

All these hardware devices or resources share one thing in common, that is an interface to interact with, known as a driver. The Linux Kernel is constantly being updated to contain a wide variety of drivers and hardware instructions. It may sound a lot but there is no single kernel that contains all hardware drivers that exist in the market. Instead, we have different versions of the kernel that support specific standard architectures where modern hardware are built to these specifications.

The Kernel is a manager that is responsible for resource access, or in other words, the Kernel controls what applications are allowed to access, what resources, when and for how long.

It’s hard to imagine a computer without the ability to multitask. With it, we can run multiple windows on screen and have them perform different tasks at the same time. While that is true for the human eye, all these different applications are in fact sharing the same pool of CPU, RAM and other computer resources.

Multitasking is made possible by the Kernel’s ability to manage resources. It allocates a specific amount of time for each application to occupy the CPU. Each application is known to the CPU as a process, and each process gets scheduled into a queue for a specific amount of milliseconds before it gets the opportunity to be addressed by the CPU.

Similarly, it manages other resources in whichever way they’re designed and programmed. Depending on the resource configurations, it allocates specific block addresses in the storage devices for each file you store. It also allocates addresses in the RAM for every variable your code creates.

All of such operations happen in a fraction of a second, the faster it is the more reactive the computer is and in turn, increases the amount of multitasking and productivity we can enjoy.

Where is the Kernel in my computer?

Let’s get something straight first. The kernel is not something that most computer users would interact with, and even if you intend to modify it, it’s unlikely that you’d interact with it directly. For most users, the kernel would just sit behind the scene and do what it’s supposed to do without being noticed.

I’ve mentioned before that the kernel is a large piece of code i.e. a file that must be stored somewhere, typically on the hard disk drive of your computer or other primary storage unit you may have such as solid state drive.

As soon as the computer is turned on, it boots up - a specific process that loads the kernel into the RAM which then starts the system manager (also known as initialisation system) that takes control of all operations. The system manager then initiates other components such as network interfaces, storage devices, graphic cards and other peripherals before taking the computer into a state where it becomes ready to be interacted with and receive user inputs.

Why modify the Kernel?

Technology is ever evolving and hardware technology represents a crucial part of it. We all know how hardware is advancing daily with the release of new graphic cards, processors and other peripheral devices. Hardware manufacturers and developers make a good example of why one might need to modify the Linux Kernel. They need to include a new set of instructions that allows the kernel to communicate with a new piece of hardware in creation.

The introduction of single-board-computers like the Raspberry Pi has also made it necessary for developers to open the hood and tweak the kernel in a way that allows it to run on a small piece of hardware. Such computers are small in size and have limited storage capacity, thus they require the kernel to be trimmed down.

The need to modify the kernel does not stop there as we continue to advance in the areas of robotics, embedded solutions and IoT devices - all of which are small pieces of hardware that are intended to perform very small and specific tasks and nothing else. Having a widely compatible kernel within them would be a waste of resources as such devices are unlikely to require any additional hardware attachments.

Other operating systems have their own version of the kernel or its equivalent, and though they may not share naming conventions, they are essentially a piece of code that is used to send instructions to the hardware of a computer system. Unlike the Linux System, other operating systems such as Windows or MacOS are proprietary and thus only engineers working at the manufacturing company may be exposed to their source code and tinker around it.

Final thoughts

People choose to modify the Linux Kernel for many reasons and they revolve around the creation of new hardware or new components for it. For those who wish to modify your kernel, you might be interested in taking a scientific approach in testing hypotheses and proposing certain changes to meet the desired outcome. If you wish to dive deeper into this topic or perhaps modify the kernel yourself, you can start with the source code here. I’d be posting more articles in this topic which will include some use cases for modifying the kernel.

Was this page helpful?

Most Viewed Articles