preface

At huawei’s Mate X2 launch, the company said the system will be available in April. And yesterday, that is, April 27, hongmeng system finally push upgrade, pollen ecstasy, black powder spray.

If you ask me about the performance of the Hongmeng system, I have my reservations. If you ask me if I want to upgrade hongmeng system, I will charge directlyThis boot screen is pretty cool! Power by Android has also been removed.

However, the target of this upgrade is still developers. It is not recommended for ordinary consumers to upgrade with the main model. Friends who only have a Huawei machine in their hands strongly do not suggest.

There is no need to pay attention to the debate about pollen and black powder, because both opinions are of little value. As long as pollen is huawei’s stuff, I will blow it fiercely. Although I also stand for Huawei, I have to say that some blows are too awkward. As for the pink, it’s either stupid or bad or just plain idle and not worth mentioning.

So I’m not taking sides in this article, but I’m trying to popularize what an operating system is. Ninety-nine percent of the people who are making a lot of noise online don’t know what a microkernel is, or even the concept of an operating system kernel, or the bedrock of their arguments.

The microkernel

Resources about micro-kernel, not many, in the actual work and life, research and development of large Internet companies have no chance to come into contact with the microkernel, let alone a regular user, even many senior programmers have a few people can access to the microkernel operating system, Internet firms used widely in the Linux kernel is a typical macro kernel, Windows is a hybrid kernel, and there’s really no good platform for learning microkernels.

A good place to start is Wiki: zh.wikipedia.org/wiki/%E5%BE…

An excerpt from a classic comparison of operating system microkernels and macrokernels:

I have collected a PPT about Minix, if you are interested, you can click to get it and have a look. However, if you are not good enough in English, you may have to use translation tools to understand it

Almost every article on microkernels uses this figure, but beyond that, it’s a pretty hollow summary, with microkernels being easier to scale and more stable, and macrokernels performing better and so on. But this does not give the reader a sense of the essence of the microkernel, because these summative theories are usually for people who already know them, and they do not give the beginner a sensory experience.

Microkernel operating system

The basic principle behind microkernels is that only the most basic operating system functions are put into the kernel. Non-basic services and applications are built on top of the kernel and run in user mode. About what should be put to detail the kernel function, different design have different ways, but the common characteristic is that many traditionally belong to the function of the part of the operating system are now external subsystem, including device drivers, file systems, virtual memory management procedures, window system and security services, they can interact with the kernel, can also interact with each other.

The microkernel structure uses a horizontal layer instead of the traditional vertical layer. All operating system components outside the microkernel are implemented as service processes that can interact with each other by passing messages through the microkernel. As a result, the microkernel can also validate messages and authorize access to hardware, and it performs protection to prevent illegal messages, among other things.

For example, if an application wants to open a file, it sends a message to the file system service, and if it wants to create a process or thread, it sends a message to the process server. Each server process can communicate with each other and invoke functions in the microkernel.

Advantages of microkernels:

Provide a consistent interface: The microkernel is designed to provide a consistent interface for process requests, and processes no longer need to distinguish between kernel-level services and user-level services, since both are via messaging;

Extensibility: The use of microkernel structure, when the need to add a new service to the system, just add a new service process, rather than modify the kernel;

Flexibility: Different service processes can be customized according to needs. For example, a distributed system needs to add security-related services.

Portability: In the microkernel architecture, most processor-specific code is in the microkernel, and very little code needs to be modified if it needs to be ported to another processor.

Reliability: Modular architecture helps increase stability, and microkernels that are small enough to be adequately tested provide more stable code for external system services. Moreover, it provides only a small number of apis and interaction methods for programmers to reduce the interaction between components;

Distributed system support: If a customer sends a message to a server process, the message contains the identifier of the requested service. In distributed systems configured with unique identifiers for all processes and services, there is effectively a single system image at the microkernel level, and processes can send information without knowing which machine the target service resides on;

Suitable for object-oriented design: microkernel design and operating system modular development can use object-oriented principle. For example, one way is to construct components, which interact with each other by building interfaces. They can build software by building blocks.

Microkernel performance:

Constructing and sending messages through the microkernel takes more time than making a system call directly. One solution is to put some of the key services and drivers back into the kernel, reducing user-kernel mode and the number of transitions between processes, but at the expense of the design strength of the microkernel; Another solution is to build a very small kernel, with the right design, that eliminates the performance penalty and improves flexibility.

Microkernel design:

Low-level memory management: The microkernel must control the address space on the hardware so that the operating system can be protected at the process level. The microkernel is only responsible for mapping each virtual page to a physical page frame, while storage management is implemented outside the kernel, including protecting one process’s address space from interference by other processes, page replacement algorithms, and paging logic. For example, virtual storage outside the kernel is responsible for when a page is brought into storage or paged out, and the kernel is responsible for mapping these page indexes to physical addresses.

When an application references a page that is not in main memory, the kernel generates a page miss error and executes a trap, and the kernel sends a message to the page manager’s process. The page manager decides to load the page and assign a page frame, and the page manager interacts with the kernel to map the logical operations of the page manager to physical storage. Once the page is available, the page manager sends an interrupt recovery message to the application.

  

This technique allows files and databases to be mapped to user address Spaces without invoking kernel operations. The microkernel provides three kernel operations to support out-of-core paging and virtual memory management:

Authorization: The owner of an address space can authorize other processes to use some of its pages. The kernel removes these pages from the authorizer’s address space and assigns them to the specified process;

Mapping: A process can map any of its pages to another process’s address space so that both processes can access the pages, forming shared memory. The kernel assigns these pages to the original owner, providing a map for other processes to access them;

Refresh: a process can reclaim any page that is authorized or mapped to another process.

Interprocess communication: The basic mode of communication between processes or threads in microkernel operating systems is messages. A message includes a header and a body: the header describes the process that sends and receives the message. The message body contains data or Pointers to data.

Interprocess communication can be thought of as being based on ports associated with a process (a sequence of messages for a process) that indicate which processes can communicate with that process. The identity and functionality of the port is maintained by the kernel, the process can send a message to the kernel specifying the functionality of the new port, and the process can grant itself new access.

Interprocess messaging with non-overlapping address Spaces involves memory-to-memory replication, which is therefore much slower than the processor speed due to the speed of the memory.

I/O and interrupt management: In a kernel architecture, hardware interrupts may be handled as messages. The microkernel recognizes interrupts but does not handle interrupts; it generates a message to the user-level thread associated with the interrupt. Thus, when an interrupt is allowed, a specific user-level process is assigned to the interrupt and the kernel maintains the mapping. The work of converting interrupts to messages must be done by the microkernel, but the microkernel does not involve device-specific interrupt handling.

Think of the hardware as a set of threads with a unique identifier and send messages to the relevant software threads in user space. The receiving thread determines whether the message is from an interrupt and which interrupt it is.

 

To follow the normal steps of understanding an operating system, first you have to get one running before anything else, or at least know what it looks like. Minix is currently available in three major versions:

  • Minix1 github.com/gdevic/mini…

This is the demo code for the operating Systems: Design and Implementation textbook, which focuses on teaching and learning. Old, difficult to compile and install.

  • Minix 2.0.4 download.minix3.org/previous-ve…

Focus on a version of self-study, installation a little trouble, need to do their own floppy disk. But here is a more detailed installation guide, you can refer to: mmmyddd. Making. IO/wiki/debian… It feels good to read its source code.

  • Minix 3.2.1 download.minix3.org/iso/minix_R…

This is a utility version, which means it is actually available, has an ISO image for download, and is very easy to install.

Interested friends can be installed to test, read through the source code.


Write this, on the hongmeng system line of the problem, support to apply for user testing, all day on the Internet with no hair blowing. Don’t support just watch, if really not, you can see him one day tall buildings, see him dinner guests, see his building collapse, why worry

Here are some good resources to read:

The microkernel IPC/RPC: pdfs.semanticscholar.org/1cd7/edefcd…

Micro kernel network related: ieeexplore.ieee.org/stamp/stamp…

The microkernel IO related: pdfs.semanticscholar.org/8559/e6c101…

QNX Architecture: cseweb.ucsd.edu/~voelker/cs…

In addition to these empty operating system theory concepts, we have a living Minix.

Minix introduction

Minix is the example code for Andrew S. Tanenbaum’s textbook operating Systems: Design and Implementation. Anyone who likes operating systems should read this book. This book is very rare to a complete operating system implementation of operating system principles teaching materials, style is very unusual. Linus’s Linux kernel itself references Minix, and if you look at early Linux code like 0.1/1.0, you’ll see how similar it is to Minix, with many of the function names being the same. More details, see: Minix Wiki page: zh.wikipedia.org/wiki/MINIX