The structure of the microkernel operating system developed in the late 1980s. Because it can effectively support multiprocessor operation, it is very suitable for distributed system environments.
Most of the currently popular operating systems that support multiprocessor operation have adopted the microkernel structure, such as the Mach OS developed by Carnegie Mellon University, which belongs to the microkernel structure operating system; and the widely used Windows operating system also adopts the microkernel structure.
So, the question arises, does the RTOS in the embedded field belong to the microkernel operating system?
To understand this question, you first need to understand what a microkernel operating system is.
1. Basic Concept of Microkernel Operating System
In order to improve the “correctness”, “flexibility”, “maintainability”, and “expandability” of the operating system, modern operating system structure design mostly adopts a microkernel structure based on client/server model (C/S model), even in a single processor environment, dividing the operating system into two main parts: the microkernel and multiple servers.
As for what a microkernel operating system structure is, there is currently no universally recognized definition, but we can describe microkernel structured operating systems from the following four aspects.
1) A sufficiently small kernel
In a microkernel operating system, the kernel refers to the carefully designed part that can implement the most basic core functions of a modern OS.
The microkernel is not a complete OS, but only the most basic part of the operating system, which is usually used to:
① Implement hardware-related processing;
② Implement some basic functions;
③ Responsible for communication between clients and servers.
They only provide an important foundation for building a general OS, ensuring that the operating system kernel can be kept small.
2) Based on client/server model
Due to the many advantages of the client/server model, almost without exception, single machine microkernel operating systems adopt the client/server model, placing the most basic parts of the operating system in the kernel and implementing the vast majority of the operating system functions outside the microkernel in a group of servers (processes). For example, there are process (thread) servers for managing processes (threads), virtual memory servers for providing virtual memory management functions, and I/O device management servers for managing I/O devices, all of which are implemented as processes running in user mode, with communication between clients and servers achieved through the message-passing mechanism provided by the microkernel.
3) Application of the principle of “mechanism and policy separation”
In the structural design of modern operating systems, the principle of “mechanism and policy separation” is often used to construct OS structures. The so-called mechanism refers to the specific execution agency for implementing a certain function. The policy, on the other hand, is the optimization of that function based on certain parameters and algorithms. Typically, mechanisms are at the lower levels of a system, while policies are at the higher levels. In traditional OS, mechanisms are placed at the lower levels of the OS kernel, while policies are placed at higher levels of the kernel. In microkernel operating systems, mechanisms are usually placed in the microkernel. This is why it is possible to keep the kernel small.
4) Use of object-oriented technology
The operating system is an extremely complex large software system. We can not only decompose the complexity of the operating system through structural design but also control the complexity of the system based on the principles of “abstraction” and “encapsulation” in object-oriented technology. Furthermore, concepts like “objects”, “encapsulation”, and “inheritance” can be used to ensure the “correctness”, “reliability”, “modifiability”, and “expandability” of the operating system, while also improving the speed of operating system design. Because object-oriented technology brings so many benefits, it is widely used in the design of modern operating systems.
2. Basic Functions of Microkernel
1) Process (Thread) Management
Most microkernel OS implement process management functions based on the principle of “mechanism and policy separation”. For example, to implement process (thread) scheduling functions, one or more process (thread) priority queues must be set up in process management; it can take a specified priority process (thread) from the queue and put it into execution. Since this part belongs to the mechanism of scheduling functions, it should be placed in the microkernel. How to determine the priority of each type of user (process) and how to modify their priorities are policy issues that can be placed in the process (thread) management server outside the microkernel.
2) Low-level memory management
Typically, only the most basic low-level memory management mechanisms are configured in the microkernel. For example, the page table mechanism and address transformation mechanism used to implement the transformation of user space logical addresses to memory space physical addresses are placed in the microkernel. The strategies for implementing virtual memory management, such as which page replacement algorithm to use and what memory allocation and recycling strategies to adopt, should be implemented in the memory management server outside the microkernel.
3) Interrupt and trap handling
Most microkernel operating systems place a small part closely related to hardware in the microkernel for processing. At this point, the main function of the microkernel is to capture interrupts and trap events that occur and perform corresponding preliminary processing. For example, perform interrupt context protection, identify the type of interrupt and trap, and then convert the information of relevant events into messages and send them to the corresponding servers. The servers then call the corresponding handlers for further processing based on the type of interrupt or trap.
In microkernel OS, process management, memory management, and I/O management functions are divided into two parts, with a very small part belonging to the mechanism placed in the microkernel and the vast majority placed in various servers outside the microkernel. In fact, most of these servers are larger than the microkernel. This further explains why the microkernel can still be kept small even after adopting the client/server model.
3. Advantages of Microkernel Operating Systems
1) Improved system scalability
Since many functions of the microkernel OS are implemented by relatively independent server software, when new hardware and software are developed, the microkernel OS only needs to add new functions in the corresponding server or add a dedicated server. At the same time, this will inevitably improve the flexibility of the system, allowing for the addition of new functions to the operating system, modification of existing functions, and removal of outdated functions to create a more streamlined and effective operating system.
2) Enhanced system reliability
This is partly because the microkernel is carefully designed and rigorously tested, making it easy to ensure its correctness; on the other hand, it provides a standardized and streamlined application programming interface (API), creating conditions for external programs to compile high-quality code for the microkernel. In addition, since all servers run in user mode and communicate between servers using a message-passing mechanism, when a certain server encounters an error, it will not affect the kernel or other servers.
3) Portability
With the rapid development of hardware, various hardware platforms have emerged. A good operating system must have portability, allowing it to run easily on different computer hardware platforms. In microkernel structured operating systems, all code related to specific CPU and I/O device hardware is placed in the kernel and the hardware abstraction layer below the kernel, while the vast majority of the operating system (i.e., various servers) is hardware platform-independent. Therefore, the modifications required to port the operating system to another computer hardware platform are relatively small.
4) Support for distributed systems
Since in microkernel OS, communication between clients and servers, as well as between servers, is conducted using message-passing communication mechanisms, microkernel OS can well support distributed systems and network systems. In fact, as long as each process and server in a distributed system is assigned a unique identifier, and a system mapping table (i.e., a correspondence table between process and server identifiers and the machines they reside on) is configured in the microkernel, when communicating between clients and servers, it is only necessary to mark the identifiers of the sending and receiving processes in the sent message. The microkernel can use the system mapping table to send the message to the target, regardless of which machine the target resides on.
5) Incorporation of object-oriented technology
When designing microkernel OS, object-oriented technology is adopted, where “encapsulation”, “inheritance”, “object classes”, and “polymorphism”, as well as the use of a message-passing mechanism between objects, are very beneficial for improving the system’s “correctness”, “reliability”, “modifiability”, and “expandability”, and can significantly reduce the costs of developing systems.
4. Problems with Microkernel Operating Systems
It should be pointed out that in microkernel OS, due to the adoption of a very small kernel, as well as the client/server model and message-passing mechanism, while these bring many advantages to microkernel OS, they also lead to potential drawbacks. The most significant is that compared to early OS, the running efficiency of microkernel OS has decreased.
The main reason for the decrease in efficiency is that completing a client service request to the OS requires multiple interactions using messages and multiple switches between user/kernel modes and contexts. However, in early OS, user processes generally only need to perform two context switches when requesting OS services: once when transitioning from user mode to system mode after executing a system call; and once when returning to user mode from system mode after the system completes the user’s service request. In microkernel OS, because communication between clients and servers, as well as between servers, must go through the microkernel, the same service request requires at least four context switches. The first occurs when the client sends a request message to the kernel to request a specific service from a server; the second occurs when the kernel sends the client’s request message to the server; the third occurs when the server completes the client’s request and sends the response message back to the kernel; and the fourth occurs when the kernel sends the response message to the client.
In practice, this often leads to even more context switches. For example, when a certain server is unable to complete the client’s request and requires assistance from other servers, the file server may need assistance from the disk server, which would then require eight context switches.
Source: https://www.cnblogs.com/heartstill/archive/2010/09/17/1829594.html
Leave a Comment
Your email address will not be published. Required fields are marked *