Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference between the Linux kernel and the Windows kernel

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

What is the difference between the Linux kernel and the Windows kernel? I believe many inexperienced people don't know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Windows and Linux can be said to be two of our more common operating systems.

Windows basically occupies the market of the computer age and has achieved great commercial success, but it is not open source, so if you want to contact the source code, you have to join the Windows development team.

The operating system used for the server is basically Linux, and the kernel source code is also open source, so anyone can download it and add their own changes or functions. The biggest charm of Linux is that there are many technology bigwigs around the world who contribute code to it.

The two operating systems are neck and neck.

What's at the core of the operating system is the kernel. This time let's see what's the difference between the Linux kernel and the Windows kernel.

Kernel

What is the kernel?

Computers are made up of various external hardware devices, such as memory, cpu, hard disk, and so on. If every application has to dock communication protocols with these hardware devices, it will be too tiring.

Therefore, the middleman is the responsibility of the kernel, and the kernel acts as a bridge between the application and the hardware device. The application only needs to care about the interaction with the kernel and does not care about the details of the hardware.

Kernel

What are the capabilities of the kernel?

In modern operating systems, the kernel generally provides four basic capabilities:

Manage processes and threads, and decide which processes and threads use CPU, that is, the ability to schedule processes

Manage memory, determine the allocation and recycling of memory, that is, the ability to manage memory

Manage hardware devices to provide communication capabilities between processes and hardware devices, that is, hardware communication capabilities

Provide system calls, and if the application is to run a service with higher privileges, then system research is needed, which is the interface between the user program and the operating system.

How does the kernel work?

The kernel has high permissions and can control hardware such as cpu, memory, hard disk, and so on, while applications have very few permissions, so most operating systems divide memory into two areas:

Kernel space, which only kernel programs can access

User space, this memory space is dedicated to applications

Code in user space can only access a local memory space, while code in kernel space can access all memory space.

Therefore, when a program uses user space, we often say that the program executes in user mode, while when a program makes kernel space, it executes in kernel mode.

If an application needs to enter kernel space, it needs to go through "system calls". Let's take a look at the process of system calls:

The kernel program executes in kernel mode, and the user program executes in user mode. When an application uses a system call, an interrupt is generated. When an interrupt occurs, CPU interrupts the currently executing user program and jumps to the interrupt handler, that is, to start executing the kernel program. After the kernel has finished processing, it initiatively triggers the interrupt, returns the CPU execution rights to the user program, and returns to the user mode to continue to work.

The design of Linux

The founder of Linux came from a Finnish young man named Linux Torvalds who wrote the first version of the Linux operating system in C in 1991, when he was 22 years old.

After completing the first version of Linux, Linux Torvalds released the source code of the Linux kernel on the network, which everyone can download and use for free.

The main concepts of Linux kernel design are as follows:

MutiTask, multitasking

SMP, symmetric multiprocessing

ELF, executable file link format

Monolithic Kernel, macro kernel

MutiTask

MutiTask means multitasking, which means that Linux is a multitasking operating system.

Multitasking means that multiple tasks can be executed at the same time, where "simultaneous" can be concurrent or parallel:

For single-core CPU, you can let each task execute for a short period of time, and then switch to another task when the time is up. From a macro point of view, multiple tasks are executed in a period of time, which is called concurrency.

For multi-core CPU, multiple tasks can be executed by different core CPU at the same time, which is called parallel.

SMP

SMP means symmetrical multiprocessing, which means that the status of each CPU is equal, and the right to use resources is the same. Multiple CPU share the same memory, and each CPU can access complete memory and hardware resources.

This feature determines that the Linux operating system will not have a single CPU service application or kernel program, but that each program can be assigned to any CPU to be executed.

ELF

ELF means executable file link format, which is the storage format of executable files in Linux operating system. You can see its structure from the following figure:

ELF file format

ELF divides the file into segments, each of which has its own role. I won't elaborate on the role of each paragraph here. Interested students can read the book "programmer's self-cultivation-Link, load and Library".

In addition, ELF files have two indexes: Program header table records the segments required by the "runtime", while Section header table records the "first address" of each segment in the binary file.

So how is the ELF file generated?

We write the code, first through the "compiler" compiled into assembly code, and then through the "assembler" into the object code, that is, the object file, and finally through the "linker" to link multiple object files and call a variety of function libraries to form an executable file, that is, the ELF file.

So how is the ELF file executed?

When the ELF file is executed, the ELF file is loaded into memory through the "loader", and the CPU reads the instructions and data in memory, so the program is executed.

Monolithic Kernel

Monolithic Kernel means macro kernel, and the Linux kernel architecture is the macro kernel, which means that the kernel of Linux is a complete executable program with the highest permissions.

The characteristic of the macro kernel is that all the modules of the system kernel, such as process scheduling, memory management, file system, device driver, etc., run in the kernel state.

However, Linux also implements the function of dynamically loading kernel modules. For example, most device drivers exist in the form of loadable modules, which are decoupled from other kernel modules, making driver development and driver loading more convenient and flexible.

The operating system structure of macro kernel, micro kernel and hybrid kernel respectively.

In contrast to the macro kernel, the microkernel retains only the most basic capabilities, such as process scheduling, virtual machine memory, interrupts, etc., and puts some applications into user space, such as drivers, file systems, and so on. In this way, the service and the service are isolated, and the failure or complete attack of a single service will not cause the whole operating system to hang up, which improves the stability and reliability of the operating system.

The micro-kernel has few functions and high portability. Compared with the macro kernel, the disadvantage is that because the driver is not in the kernel, and the driver will call the underlying capabilities frequently, so the interaction between the driver and the hardware device needs to be frequently switched to the kernel state, which will lead to performance loss. The kernel architecture of Huawei's Hongmeng operating system is the microkernel.

There is also a kind of kernel called mixed-type kernel, whose architecture is a bit like a microkernel, in which there will be a minimum version of the kernel, and then other modules will be built on this basis, and then the implementation will be similar to the macro kernel. That is, the entire kernel is made into a complete program, and most of the services are in the kernel, which is like a microkernel wrapped in a macro kernel.

Windows design

The kernel used by Windows 7 and Windows 10 today is called Windows NT,NT. Its full name is New Technology.

Below is a picture of the structure of Windows NT:

The structure of Windows NT

Windows, like Linux, also supports MutiTask and SMP, but the difference is that the kernel design of Windows is a hybrid kernel. In the figure above, you can see that there is a MicroKernel module in the kernel, which is the minimum version of the kernel, while the whole kernel implementation is a complete program with a lot of modules.

The format of the executable of Windows is also different from that of Linux, so the executable of the two systems cannot be run on each other.

The executable file format of Windows is called PE, which is called portable executable file, and the extension is usually .exe, .dll, .sys, and so on.

As you can see from the following figure, the structure of PE is a little similar to the structure of ELF.

PE file structure

Summary

There are generally three types of kernel architectures:

Macro kernel, which contains multiple modules, and the whole kernel is like a complete program

Microkernel, which has a minimum version of the kernel, and some modules and services are managed by the user mode

The hybrid kernel is a combination of macro kernel and micro kernel. The concept of micro kernel is abstracted from the kernel, that is, there will be a small kernel in the kernel, other modules are built on this basis, and the whole kernel is a complete program.

The kernel design of Linux uses a macro kernel, while the kernel design of Windows uses a hybrid kernel.

The executable file format of the two operating systems is also different, the Linux executable file format is called ELF,Windows executable file format is called PE.

After reading the above, have you mastered the difference between the Linux kernel and the Windows kernel? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report