This article comes from the public number: Hook hook Java universe (wechat: Javagogo), mo to promote, all dry goods!

Original link: mp.weixin.qq.com/s/Q0gzT_xMa… By Lin 䭽


Windows and Linux are two of the most popular server operating systems today.

Both operating systems have their own strengths. Every time I learn the technical knowledge of two operating systems, I really feel that programming is really an art, and learning programming is like exploring art.

Today I started with an interview question “What’s the difference between the Linux kernel and the Windows kernel?” Start with, to understand the design of the two operating system kernel.

What is the kernel?

When it comes to operating systems, you have to say the kernel. The kernel is the bridge between applications and hardware devices in the operating system.

For a modern operating system, the kernel should provide at least four basic capabilities:

  • Manage processes and threads (deciding which processes and threads use the CPU)

  • Managing memory (deciding what memory is used for)

  • Connect hardware devices (to provide communication between processes and devices)

  • Provide system calls (system calls sent by the receiving process)

From the above four capabilities of the operating system and the relationship between the kernel, usually can be divided into three layers of operating system, the lowest layer of hardware device abstraction, the middle kernel and the highest layer of applications.

So, how does the kernel work? Let’s think about a question

Is the relationship between the process and the kernel the same as the browser asking the server to serve it?

The kernel has very high permissions, manages the process and has direct access to all memory, so it does require some separation from the process.

This isolation uses a request/response-like model, which makes perfect sense.

The difference is that in the browser-server model, the browser and server are executed on different machines and therefore do not need to share a CPU. However, there is resource sharing in the process of calling the kernel.

  • For example, if a machine has four cpus, it is not possible for the kernel to use one CPU and other processes to use the remaining CPU. It’s a waste of resources

  • For example, if a process asks the kernel for 100 MB of memory, the kernel sends back 100 MB of data. This model is not feasible because the transmission is too slow

As a result, most operating systems here are designed according to one principle:

The process makes a request to the kernel and cedes CPU execution rights to the kernel. The kernel takes over CPU execution permission, completes the request, and transfers CPU execution permission to the calling process.

Linux kernel design

There are a lot of interesting terms when it comes to Linux kernel design. Most of them sound complicated and technical, but they’re really easy to understand. Let’s talk about them all.

  1. Multitask and SMP (Symmetric MultiProcessing)

MultiTask means that multiple tasks can be executed at the same time. (Of course Linux supports concurrency.)

SMP refers to symmetric multiprocessing, which means that under Linux, each processor has equal status, memory is shared by multiple processors, and each processor has access to complete memory and hardware resources.

This feature determines that there is no specific processor for user programs or kernel programs on Linux; they can be assigned to any processor for execution.

  1. ELF (Executable and Linkable Format)

ELF translates as “executable file link format”. ELF is a Unix inherited storage format for executable files. ELF divides files into segments, each of which has its own function.

  1. Monolithic Kernel

This translates to “macro kernel” and is the opposite of Microkernel.

The Linux kernel is a complete executable program, and the kernel runs with the highest permissions.

The feature of a macro kernel is that many programs are packaged in the kernel, such as file systems, drivers, memory management, and so on. Of course, this does not mean that you need to recompile the kernel every time you install a driver. Linux can now load kernel modules dynamically as well. So which modules are in the kernel layer and which modules are in the user layer, this is a system layer split, not a strong physical isolation.

The microkernel retains only the most basic capabilities, such as process scheduling, virtual memory, and interrupts. Most applications, even drivers and file systems, are managed in user space.

Windows kernel design

Windows also has a kernel, which is written in C/C++. The kernel of Windows 7, Windows 10 that we use today is called Windows NT.

Windows also supports Multitask and SMP (Symmetric multiprocessing).

The Windows kernel design is a hybrid type, and you can see that there is a Microkernel module in the kernel. And the whole kernel implementation, like the macro kernel, contains a lot of capabilities, is a complete whole.

Windows also has its own Executable file format called Portable Executable (PE) with.exe,.dll,.sys, and so on.

The PE file structure and ELF structure have a lot in common, I found a picture to help you understand more intuitively.

In addition, Windows has many unique capabilities, such as Hyper-V virtualization technology.


Welcome big guys to pay attention to the public account of the Java universe (wechat: Javagogo), refuse hydrology, harvest dry goods!