The kernel, or system core, ensures the smooth running of the operating system within a computer and is the interface between the software and the hardware. It is used in all devices with an operating system, for example, computers, laptops, smartphones, smartwatches, etc.
Which Tasks does the Kernel perform?
The kernel is mainly the interface between the operating system, i.e. the software, and the hardware components in a device. This results in various tasks that have to be accomplished. For the end user, however, this work is not visible and is only expressed by whether all programs run correctly or not.
When we use a program on a computer, such as Excel, we handle it on the so-called Graphical User Interface (GUI). The program converts every button click or other action into machine code and sends it to the operating system kernel. If we want to add a new column in an Excel table, this call goes to the system core. This in turn passes the call on to the computer processing unit (CPU), which executes the action.
If several programs are running at the same time, the system core also ensures that the programs’ requests are processed one after the other and the user is given the feeling that the processes are running simultaneously. So, in our example, if a browser window is also open at the same time as Excel, the system kernel ensures that the programs’ demands on the CPU and other hardware are processed in a coordinated manner.
In addition, there are other more detailed tasks, such as:
- Management of externally connected devices, such as keyboards, mouse, or monitors, and their proper functioning.
- Solving memory usage errors, for example, when the memory usage of a program increases too much.
- Optimization of CPU usage
What Layers does the Kernel consist of?
The kernel works in several layers that build on each other. These include:
- Hardware: The lowest layer forms the interface to the system hardware that the operating system has access to. This includes, for example, the PCI Express controller or memory.
- Memory Management: In the next layer, dedicated amounts of the available main memory are allocated to the running processes. Furthermore, the virtual main memory can also be distributed here.
- Process Management: In this layer, the times of the programs are managed and incoming requests are timed so that they appear parallel to us as users.
- Device Management: In this layer, device management takes place. In contrast to the hardware layer, this involves externally connected devices, such as monitors or printers, whose communication is ensured via special drivers.
- File System: In the topmost layer, processes are assigned to designated areas on the hard disk, i.e. HDD or SSD.
These layers operate in such a way that each higher layer relies on and builds upon the layers below it. For example, the process management layer also accesses processes in the hardware layer. However, the opposite is not true.
What are the Kernel Types?
As a rule, three different kernel types are distinguished depending on how many processes and users can be managed simultaneously.
The micro-kernel only performs minimal tasks, such as memory management and CPU process management. Other functionalities, such as the file system or device management, are outsourced to the operating system itself. The advantage is that it cannot lead to total system failure, as is the case with Windows, for example.
The operating system of Apple computers, macOS, for example, is based on a micro-core architecture.
The monolithic kernel centrally handles all the tasks already described, is responsible for all memory and process management, and also handles the hardware management of externally connected devices. The Windows operating system is based on a monolithic kernel.
Due to the central design, monolithic cores are usually significantly faster than micro cores, but this can also lead to system crashes if a single process does not function properly.
As the name already suggests, the hybrid kernel is a mixture of these two concepts. It is basically also a large kernel that takes over all tasks, but is much more compact and can be split into different modules.
How does the Kernel work in a Jupyter notebook?
When working with data and machine learning, people often turn to Jupyter Notebook. It is a web-based platform for creating and sharing programming code. It is so often used for data science applications because individual blocks of code can be executed and their results, for example, graphs, are directly visible. This is particularly advantageous for model creation or data set analysis when the next programming steps depend on the previous results.
When using Jupyter Notebook, a kernel is also started, which can sometimes lead to problems, such as in the following example when establishing a connection. However, this is completely different from that of an operating system as described so far in this article.
The Jupyter Notebook Kernel is an engine that executes notebook code and is specific to a particular programming language, such as Python. However, it does not perform the comprehensive interface functions described so far.
The following commands are particularly useful when dealing with the Jupyter Notebook kernel:
- Interrupt: This command stops the processes that are currently running in a cell. This can be used, for example, to stop the training of a model, even if not all training epochs have been reached yet.
- Restart & Run All: With this command, all cells can be executed again and the previous variables were deleted. This can be useful if you want to read a newer data set into the existing program.
- Restart: The sole command “Restart” leads to the same result, but not all cells are executed again.
Reconnect: When training large models, the kernel can “die” because the memory is full. Then a reconnect makes sense.
- Shutdown: As long as a kernel is still running, it also ties up memory. If you run other programs in parallel for which you want to free memory, the “Shutdown” command can make sense.
This is what you should take with you
- A kernel ensures the smooth running of the operating system within a computer and is the interface between the software and the hardware.
- It is divided into different layers, which build on each other.
- The tasks include the management of parallel running processes or the proper functioning of externally connected devices.
- The Jupyter Notebook kernel is not a system kernel in the described sense, since it is only used to execute programming code.