[This is ZY’s 14th original technical article]

Operating system and kernel

Operating System is defined as follows: Operating System (English: Operating System, abbreviated: OS) is the System software that manages computer hardware and software resources, and is also the kernel and cornerstone of computer System. Operating systems need to handle such basic tasks as managing and configuring memory, prioritizing the supply and demand of system resources, controlling input and output devices, operating networks, and managing file systems. The operating system also provides an interface for users to interact with the system. For us, the most intuitive feeling of the operating system is the desktop system, and the application of the upper layer, and then the resource processing is the black box behind the operating system.

Readers are reading this in a browser or an application. An application is meant to run on a specific operating system. Operating systems, on the other hand, run on hardware. So the relationship is shown here.

A kernel is a piece of system software that provides hardware abstraction, disk and file system control, multitasking, and so on. The kernel is the most basic part of an operating system. It is a piece of software that provides a wide range of applications with secure access to computer hardware that is limited, and the kernel determines when and for how long a program operates on certain parts of hardware. Operating directly on the hardware is very complex, so the kernel usually provides a hardware abstraction method to accomplish these operations. Hardware abstraction hides complexity and provides a concise, unified interface for application software and hardware, making programming simpler.

Simply put, the kernel is the core of an operating system. It is responsible for the management of system processes, memory, device drivers, files and network systems, etc., determines the performance and stability of the system. It is the bridge between the application and the hardware. The kernel is the core of the black box behind the operating system.

Now let’s go back to the definition of operating system and kernel.

Kernel classification

Now that we know what a kernel is, let’s look at the classification of kernels. There are four main categories of kernels: macrokernels (single kernels), microkernels, hybrid kernels, and external kernels.

What is a macro kernel

As we mentioned above, the kernel manages the operating system’s memory, files, IO, network, etc. Each function can be thought of as a module. In a macro kernel, these modules are all integrated and run in the kernel process, and the interaction between modules is directly called by methods.

What is a microkernel

In the micro kernel, the kernel only provides the most core functions, such as task scheduling, memory management and so on. Other modules are removed from the kernel and run in different processes, so that even if a module has problems, as long as the process of this module can restart, will not affect other modules, stability greatly increased. You can even replace the implementation of existing modules while the system is running. And because of the independent nature of modules, modules can be loaded on demand. However, the mutual invocation between modules requires interprocess communication, and the communication efficiency is relatively low.

What is a hybrid kernel

We looked at the implementation of macrokernels and microkernels above, and found that each has its own advantages and disadvantages, so a hybrid kernel is a combination of the characteristics of both, allowing some of the core modules in the microkernel to run in the kernel, thus making the kernel more efficient.

What is an outer kernel

The outer kernel is to expose the hardware to the application program, the application program can directly access the hardware, the outer kernel provides protection for the system. It’s still in the research stage.

Macro kernel microkernel comparison

Having seen the implementation of macrokernel and microkernel above, we can conclude that the biggest characteristic of macrokernel is module integration, while microkernel is module separation. Based on this point, the comparison is as follows:

Macro kernel The microkernel
The efficiency of communication High (function call) Low (interprocess communication)
The stability of Low (modules integrated together) High (modules do not affect each other)
scalability Low (modules integrated together) High (modules do not affect each other)
Amount of code Multiple (need to implement all modules) Less (only core functionality needed)

Current mainstream operating system kernel

Macro kernel Linux Windows 9X series MacOS prior to version 8.6

Microkernel Fuchsia hongmeng Minix

Hybrid kernel Windows XP Windows 7 Mac OS X XNU

Outside the kernel Nemesis

The resources

Zh.wikipedia.org/wiki/ operating system www.cnblogs.com/smwikipedia… Zh.wikipedia.org/wiki/ kernel www.oschina.net/news/108946…