Memory address conversion method and device in microkernel operating system, equipment and medium

By utilizing a user-mode memory management program in user space to perform memory address translation, the problem of low memory address translation efficiency in microkernel operating systems is solved, achieving efficient memory address translation.

CN115718643BActive Publication Date: 2026-11-06ZEBRED NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211453628.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-21
Publication Date
2026-11-06
Estimated Expiration
2042-11-21

AI Technical Summary

Technical Problem

Existing microkernel operating systems require inter-process communication (IPC) for memory address translation, resulting in low efficiency.

Method used

In user space, the application process calls the driver, the driver thread calls the memory address translation interface of the user-mode memory management program, and the user-mode memory management thread searches for the target memory block from the memory block set based on the virtual memory address, determines the physical memory address, and completes the memory address translation.

Benefits of technology

Memory address translation can be completed without entering kernel space, improving translation efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115718643B_ABST
    Figure CN115718643B_ABST
Patent Text Reader

Abstract

This application provides a method, apparatus, device, and medium for memory address translation in a microkernel operating system. In this method, an application process calls a driver program based on a virtual memory address. The driver program's corresponding thread then calls the memory address translation interface of the user-space memory management program. The user-space memory management thread then searches for the target memory block corresponding to the virtual memory address in a set of memory blocks. Finally, based on the virtual memory address, the starting physical address of the target memory block, and the starting virtual address of the target memory block, the physical memory address corresponding to the virtual memory address is determined. This solution performs memory address translation in the user-space memory management program, eliminating the need to enter kernel space, thus effectively improving memory address translation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computers, and in particular to a method, apparatus, device and medium for memory address translation in a microkernel operating system. Background Technology

[0002] During the execution of an application process, it can directly access the virtual address of memory. However, when the application process performs operations involving hardware peripherals, it needs to access the physical address of memory. This requires the driver process and the memory management process to perform memory address translation between the virtual address and the physical address.

[0003] In existing technologies, for microkernel operating systems, application processes, driver processes, and memory management processes reside in user space. During memory address translation, the application process calls the driver process, which then sends a memory address translation request to the memory management process via inter-process communication (IPC). The memory management process completes the memory address translation and then returns the translated address to the driver process via IPC.

[0004] In summary, existing microkernel operating systems require IPC (Inter-Process Communication) for memory address translation, which involves communication between user space and kernel space, resulting in low memory address translation efficiency. Summary of the Invention

[0005] This application provides a method, apparatus, device, and medium for memory address translation in a microkernel operating system, which solves the problem that existing memory address translation methods in microkernel operating systems require IPC communication, and the IPC needs to travel from user space to kernel space and back to user space, resulting in low memory address translation efficiency.

[0006] In a first aspect, embodiments of this application provide a memory address translation method in a microkernel operating system, applied to an electronic device with a microkernel operating system installed. The microkernel operating system includes applications, drivers, and a user-mode memory management program. The method includes:

[0007] The application process corresponding to the application calls the driver based on the virtual memory address;

[0008] The driver thread corresponding to the driver calls the memory address translation interface of the user-mode memory management program, and the driver includes the user-mode memory management program;

[0009] The user-mode memory management thread corresponding to the user-mode memory management program searches for the target memory block corresponding to the virtual memory address from the memory block set based on the virtual memory address;

[0010] The user-mode memory management thread determines the physical memory address corresponding to the virtual memory address based on the virtual memory address, the starting physical address of the memory block stored in the target memory block, and the starting virtual address of the memory block.

[0011] In one specific implementation, the user-mode memory management thread determines the physical memory address corresponding to the virtual memory address based on the virtual memory address, the starting physical address of the memory block stored in the target memory block, and the starting virtual address of the memory block, including:

[0012] The user-mode memory management thread uses the formula: P = PS + (V - VS) to calculate the physical memory address corresponding to the virtual memory address, where P represents the physical memory address corresponding to the virtual memory address, PS represents the starting physical address of the memory block stored in the target memory block, V represents the virtual memory address, and VS represents the starting virtual address of the memory block stored in the target memory block.

[0013] In one specific embodiment, the method further includes:

[0014] The driver thread obtains the physical memory address of the physical peripheral storage data;

[0015] The driver thread calls the memory address translation interface of the user-mode memory management program;

[0016] The user-mode memory management thread searches for the target memory block corresponding to the physical memory address from the memory block set based on the physical memory address;

[0017] The user-mode memory management thread determines the virtual memory address corresponding to the physical memory address based on the physical memory address, the starting physical address of the memory block stored in the target memory block, and the starting virtual address of the memory block.

[0018] The driver thread sends the virtual memory address corresponding to the physical memory address to the application process.

[0019] In one specific implementation, the user-mode memory management thread determines the virtual memory address corresponding to the physical memory address based on the physical memory address, the starting physical address of the memory block stored in the target memory block, and the starting virtual address of the memory block, including:

[0020] The user-mode memory management thread uses the formula: V = VS + (P - PS) to calculate the virtual memory address corresponding to the physical memory address, where V represents the virtual memory address corresponding to the physical memory address, PS represents the starting physical address of the memory block stored in the target memory block, P represents the physical memory address, and VS represents the starting virtual address of the memory block stored in the target memory block.

[0021] In one specific embodiment, the method further includes:

[0022] The user-mode memory management thread obtains the memory block, the starting physical address of the memory block, the starting virtual address of the memory block, and the capacity of the memory block through the kernel-mode memory management program.

[0023] For each physical page in the memory block, the user-mode memory management thread generates a page descriptor corresponding to that physical page.

[0024] The user-mode memory management thread stores the starting physical address of the memory block, the starting virtual address of the memory block, the capacity of the memory block, and the page descriptor corresponding to each physical page in the memory block into the memory block.

[0025] In one specific embodiment, the method further includes:

[0026] The user-mode memory management thread establishes a red-black tree data structure between the memory block and the memory blocks already acquired by the user-mode memory management thread, and stores it in the memory block set.

[0027] Secondly, embodiments of this application provide a memory address translation device in a microkernel operating system, comprising:

[0028] The communication module is used to call the driver program via the virtual memory address of the application process corresponding to the application.

[0029] The conversion module is used for:

[0030] The driver program calls the memory address translation interface of the user-mode memory management program through the driver thread corresponding to the driver program, and the driver program includes the user-mode memory management program;

[0031] The user-mode memory management thread corresponding to the user-mode memory management program searches for the target memory block corresponding to the virtual memory address from the memory block set based on the virtual memory address.

[0032] The user-mode memory management thread determines the physical memory address corresponding to the virtual memory address based on the virtual memory address, the starting physical address of the memory block stored in the target memory block, and the starting virtual address of the memory block.

[0033] Thirdly, embodiments of this application provide an electronic device, including:

[0034] Processor, memory, communication interface;

[0035] The memory is used to store the executable instructions of the processor;

[0036] The processor is configured to execute the memory address translation method in the microkernel operating system described in any of the first aspects by executing the executable instructions.

[0037] Fourthly, embodiments of this application provide a readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the memory address translation method in the microkernel operating system described in any one of the first aspects.

[0038] Fifthly, embodiments of this application provide a computer program product, including a computer program, which, when executed by a processor, is used to implement the memory address translation method in a microkernel operating system as described in any of the first aspects.

[0039] The memory address translation method, apparatus, device, and medium in the microkernel operating system provided in this application embodiment involve an application process calling a driver program based on a virtual memory address. The driver program's corresponding thread then calls the memory address translation interface of the user-space memory management program. The user-space memory management thread then searches for the target memory block corresponding to the virtual memory address in a set of memory blocks. Finally, based on the virtual memory address, the starting physical address of the target memory block, and the starting virtual address of the target memory block, it determines the physical memory address corresponding to the virtual memory address. This solution performs memory address translation in the user-space memory management program, eliminating the need to enter kernel space, thus effectively improving memory address translation efficiency. Attached Figure Description

[0040] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0041] Figure 1A flowchart illustrating an embodiment of the memory address translation method in a microkernel operating system provided in this application;

[0042] Figure 2 A flowchart illustrating Embodiment 2 of the memory address translation method in the microkernel operating system provided in this application;

[0043] Figure 3a A flowchart illustrating Embodiment 3 of the memory address translation method in the microkernel operating system provided in this application;

[0044] Figure 3b A schematic diagram illustrating the contents of a memory block provided in this application;

[0045] Figure 4 The memory block data structure diagram provided in this application;

[0046] Figure 5 A schematic diagram of the structure of an embodiment of the memory address translation device in the microkernel operating system provided in this application;

[0047] Figure 6 This is a schematic diagram of the structure of an electronic device provided in this application. Detailed Implementation

[0048] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments made by those skilled in the art under the guidance of these embodiments are within the scope of protection of this application.

[0049] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0050] With the rapid development of technology, operating systems have evolved from monolithic kernel operating systems to microkernel operating systems. Regardless of whether it is a monolithic kernel operating system or a microkernel operating system, when running applications, the conversion between virtual memory addresses and physical memory addresses is involved.

[0051] In monolithic kernel operating systems, all driver processes and memory management processes reside in kernel space, allowing for unified management of physical memory within the kernel. The memory management process performs a unified linear mapping of physical memory addresses to virtual memory addresses within kernel space; this conversion can be achieved by adding or subtracting an offset constant. However, since this memory address translation occurs within kernel space, if an application needs to perform memory address translation, it must enter kernel mode via a system call, resulting in low translation efficiency.

[0052] In microkernel operating systems, driver processes reside in user space. Drivers primarily manage various hardware peripherals. When peripherals transmit data, they must provide the necessary physical memory for read and write access. In other words, user-space driver processes must be able to allocate and release physical memory. Furthermore, while the CPU uses virtual memory addresses to access memory, peripherals use physical memory addresses. This necessitates that driver processes be able to translate between physical and virtual memory addresses. High-speed peripherals, such as network cards and USB flash drives, access memory very frequently; therefore, efficient memory access is crucial and is one of the performance bottlenecks.

[0053] In existing technologies, for microkernel operating systems, application processes, driver processes, and memory management processes reside in user space. During memory address translation, the application process calls the driver process, which then sends a memory address translation request to the memory management process via inter-process communication (IPC). The memory management process completes the memory address translation and then returns the translated address to the driver process via IPC. Because IPC requires traversing from user space to kernel space and back to user space, it results in low efficiency for memory address translation.

[0054] To address the problems existing in the prior art, the inventors, during their research on memory address translation methods in microkernel operating systems, discovered that to improve memory address translation efficiency, the translation can be completed in user space, bypassing the kernel space. In the microkernel operating system of this scheme, user program processes and driver threads reside in user space. The driver includes a user-mode memory management program, and the kernel space includes a kernel-mode memory management program. The user-mode memory management thread, corresponding to the user-mode memory management program, obtains the memory block through the kernel-mode memory management program and manages the memory block. When memory address translation is required, the application process calls the driver, and the driver thread calls the memory address translation interface of the user-mode memory management program. The user-mode memory management thread then searches for the target memory block corresponding to the virtual memory address from the memory block set based on the virtual memory address. Then, based on the virtual memory address, the starting physical address of the memory block stored in the target memory block, and the starting virtual address of the memory block, it determines the physical memory address corresponding to the virtual memory address, completing the memory address translation in user space, effectively improving memory address translation efficiency. Based on the above inventive concept, the memory address translation scheme in the microkernel operating system of this application was designed.

[0055] The execution subject of the memory allocation method in the microkernel operating system in this application can be a smartphone terminal, or a device such as a tablet computer or computer that can run a microkernel operating system. This application does not limit it. The following description uses a smartphone terminal as an example.

[0056] The following describes the application scenarios of the memory allocation method in the microkernel operating system provided in this application.

[0057] For example, in this application scenario, when an application process wants to obtain target data stored in physical memory by a physical peripheral, it needs to perform memory address translation because the application process can only access virtual memory addresses.

[0058] The application process calls the driver based on the virtual memory address. The driver thread then calls the memory address translation interface of the user-mode memory manager.

[0059] The user-mode memory management thread, corresponding to the user-mode memory management program, searches for the target memory block corresponding to the virtual memory address in the memory block set. Then, based on the virtual memory address, the starting physical address of the memory block stored in the target memory block, and the starting virtual address of the memory block, it determines the physical memory address corresponding to the virtual memory address, completing the memory address translation. Subsequently, the driver thread obtains the target data based on the physical memory address and sends it to the application process.

[0060] It should be noted that the above scenario is only an example of an application scenario provided by the embodiments of this application. The embodiments of this application do not limit the actual form of the various devices included in the scenario, nor do they limit the interaction methods in the devices. In the specific application of the solution, it can be set according to actual needs.

[0061] The technical solution of this application will now be described in detail through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.

[0062] Figure 1 This is a flowchart illustrating an embodiment of the memory address translation method in a microkernel operating system provided in this application. This embodiment describes the process where an application process needs to translate a virtual memory address into a physical memory address, and then calls a driver program. The driver program thread calls the memory address translation interface of the user-mode memory management program, and the user-mode memory management thread searches for the target memory block corresponding to the virtual memory address from the memory block set, and then determines the physical memory address corresponding to the virtual memory address from the target memory block. The method in this embodiment can be implemented through software, hardware, or a combination of both. Figure 1 As shown, the memory address translation method in this microkernel operating system specifically includes the following steps:

[0063] S101: The application process calls the driver based on the virtual memory address.

[0064] In this step, when the application process needs to perform memory address translation, it calls the driver based on the virtual memory address.

[0065] It should be noted that this application applies to electronic devices with a microkernel operating system installed. The microkernel operating system includes applications, drivers, and user-mode memory management programs. The drivers include user-mode memory management programs.

[0066] S102: The driver thread corresponding to the driver calls the memory address translation interface of the user-mode memory management program.

[0067] In this step, after the application process calls the driver, in order to achieve memory address translation, the driver thread calls the memory address translation interface of the user-mode memory management program based on the virtual memory address.

[0068] S103: The user-mode memory management thread corresponding to the user-mode memory management program searches for the target memory block corresponding to the virtual memory address from the memory block set based on the virtual memory address.

[0069] In this step, after the driver thread calls the memory address translation interface of the user-mode memory management program, the user-mode memory management thread corresponding to the user-mode memory management program can search for the target memory block corresponding to the virtual memory address from the memory block set based on the virtual memory address.

[0070] Since each memory block stores the starting physical address, starting virtual address, and size, the physical address range and virtual address range of each memory block can be determined. Therefore, the target memory block corresponding to the virtual memory address can be found from the set of memory blocks based on the virtual memory address.

[0071] It should be noted that the storage data structure of the memory block can be a red-black tree data structure, a binary tree data structure, a complete binary tree data structure, etc. This application embodiment does not limit the storage data structure between memory blocks; it can be selected according to the actual situation. If a red-black tree data structure is used, when searching for the target memory block corresponding to the virtual memory address, the search method corresponding to the red-black tree data structure can be used, improving search efficiency.

[0072] S104: The user-mode memory management thread determines the physical memory address corresponding to the virtual memory address based on the virtual memory address, the starting physical address of the memory block stored in the target memory block, and the starting virtual address of the memory block.

[0073] In this step, after the user-mode memory management thread finds the target memory block corresponding to the virtual memory address from the memory block set, since the physical memory address and virtual memory address of the memory block are contiguous and the physical memory address and its corresponding virtual memory address are linearly mapped, the physical memory address corresponding to the virtual memory address can be determined based on the virtual memory address, the starting physical address of the memory block stored in the target memory block, and the starting virtual address of the memory block.

[0074] Specifically, the user-mode memory management thread uses the formula: P = PS + (V - VS) to calculate the physical memory address corresponding to the virtual memory address, where P represents the physical memory address corresponding to the virtual memory address, PS represents the starting physical address of the memory block stored in the target memory block, V represents the virtual memory address, and VS represents the starting virtual address of the memory block stored in the target memory block.

[0075] For example, if the starting physical address of the target memory block is 0, the starting virtual address of the memory block is 7, and the virtual memory address is 9, then the physical memory address corresponding to the virtual memory address is calculated as: 0 + (9 - 7) = 2.

[0076] It should be noted that the above examples are merely illustrations of calculating physical memory addresses. This application does not limit the starting physical address of the memory block, the starting virtual address of the memory block, or the virtual memory address, etc., and these can be determined according to the actual situation.

[0077] The memory address translation method in the microkernel operating system provided in this embodiment involves the application process calling the driver. The driver thread then calls the memory address translation interface of the user-mode memory management program. The user-mode memory management thread then searches for the target memory block in the memory block set based on the virtual memory address, thereby determining the physical memory address corresponding to the virtual memory address. Compared to existing technologies that require IPC communication (which involves movement between user space and kernel space), this solution uses the application process, driver thread, and user-mode memory management program located in user space to complete the memory address translation, eliminating the need to enter kernel space and effectively improving memory address translation efficiency.

[0078] Figure 2 This is a flowchart illustrating a second embodiment of the memory address translation method in a microkernel operating system provided in this application. Based on the above embodiments, this application describes the case where the driver thread obtains the physical memory address and converts it into a virtual memory address through a user-mode memory management thread. For example... Figure 2 As shown, the memory address translation method in this microkernel operating system specifically includes the following steps:

[0079] S201: The driver thread obtains the physical memory address of the physical peripheral storage data.

[0080] In this step, after the physical peripheral stores new data in physical memory, if the application process wants to obtain the data, it needs to obtain the virtual memory address corresponding to the physical memory address. This requires the driver thread to obtain the physical memory address where the physical peripheral stores the data.

[0081] S202: The driver thread calls the memory address translation interface of the user-mode memory manager.

[0082] In this step, after the driver thread obtains the physical memory address, it needs to call the memory address translation interface of the user-mode memory management program in order to perform memory address translation.

[0083] S203: The user-mode memory management thread searches for the target memory block corresponding to the physical memory address from the memory block set based on the physical memory address.

[0084] In this step, after the driver thread calls the memory address translation interface of the user-mode memory management program, the user-mode memory management thread can search for the target memory block corresponding to the physical memory address from the memory block set based on the physical memory address.

[0085] Since each memory block stores the starting physical address, starting virtual address, and size of the memory block, the physical address range and virtual address range of each memory block can be determined. Therefore, the target memory block corresponding to the physical memory address can be found from the set of memory blocks based on the physical memory address.

[0086] S204: The user-mode memory management thread determines the virtual memory address corresponding to the physical memory address based on the physical memory address, the starting physical address of the memory block stored in the target memory block, and the starting virtual address of the memory block.

[0087] In this step, after the user-mode memory management thread finds the target memory block corresponding to the physical memory address from the memory block set, since the physical memory address and virtual memory address of the memory block are contiguous and the physical memory address and its corresponding virtual memory address are linearly mapped, the virtual memory address corresponding to the physical memory address can be determined based on the physical memory address, the starting physical address of the memory block stored in the target memory block, and the starting virtual address of the memory block.

[0088] Specifically, the user-mode memory management thread uses the formula V = VS + (P - PS) to calculate the virtual memory address corresponding to the physical memory address, where V represents the virtual memory address corresponding to the physical memory address, PS represents the starting physical address of the memory block stored in the target memory block, P represents the physical memory address, and VS represents the starting virtual address of the memory block stored in the target memory block.

[0089] For example, if the starting physical address of the target memory block is 1, the starting virtual address of the memory block is 6, and the physical memory address is 5, then the virtual memory address corresponding to the physical memory address is calculated as: 6 + (5 - 1) = 10.

[0090] It should be noted that the above examples are merely illustrations of calculating virtual memory addresses. This application does not limit the starting physical address of the memory block, the starting virtual address of the memory block, or the virtual memory address, etc., and these can be determined according to the actual situation.

[0091] S205: The driver thread sends the virtual memory address corresponding to the physical memory address to the application process.

[0092] In this step, after the user-mode memory management thread determines the virtual memory address corresponding to the physical memory address, the driver thread sends the virtual memory address corresponding to the physical memory address to the application process so that the application process can access the virtual memory address subsequently.

[0093] The memory address translation method in the microkernel operating system provided in this embodiment obtains the physical memory address through the driver thread, calls the memory address translation interface of the user-space memory management program, and then determines the target memory block corresponding to the physical memory address. Finally, it determines the virtual memory address corresponding to the physical memory address based on the storage content in the target memory block. The memory address translation is completed through the application process, driver thread, and user-space memory management program located in user space, without needing to enter kernel space, effectively improving the efficiency of memory address translation.

[0094] Figure 3a This is a flowchart illustrating a third embodiment of the memory address translation method in a microkernel operating system provided in this application. Based on the above embodiments, this application describes the case where the user-mode memory management thread obtains a memory block from the kernel-mode memory management program and generates a page descriptor to store in the memory block. For example... Figure 3a As shown, the memory address translation method in this microkernel operating system specifically includes the following steps:

[0095] S301: The user-mode memory management thread obtains the memory block, the starting physical address of the memory block, the starting virtual address of the memory block, and the capacity of the memory block through the kernel-mode memory management program.

[0096] In this step, when the application process needs to be allocated memory, the application process can call the driver. The user-mode memory management thread corresponding to the user-mode memory management program in the driver will determine whether there is available memory space in the existing memory block that meets the requirements of the application process. If there is no available memory space in the existing memory block that meets the requirements of the application process, the user-mode memory management thread needs to obtain a new memory block, the starting physical address of the memory block, the starting virtual address of the memory block, and the capacity of the memory block through the kernel-mode memory management program.

[0097] S302: For each physical page in a memory block, the user-mode memory management thread generates a page descriptor corresponding to that physical page.

[0098] In this step, to facilitate the management of each physical page in the memory block, it is necessary to generate a page descriptor corresponding to each physical page in the memory block.

[0099] S303: The user-mode memory management thread stores the starting physical address of the memory block, the starting virtual address of the memory block, the capacity of the memory block, and the page descriptor corresponding to each physical page in the memory block into the memory block.

[0100] In this step, after the user-mode memory management thread generates the page descriptor, it stores the starting physical address of the memory block, the starting virtual address of the memory block, the capacity of the memory block, and the page descriptor corresponding to each physical page in the memory block into the memory block for subsequent use.

[0101] For example, Figure 3b A schematic diagram illustrating the contents of a memory block provided in this application; as shown. Figure 3b As shown, a memory block includes the starting physical address of the memory block, the starting virtual address of the memory block, the capacity of the memory block, and a set of page descriptors, wherein the set of page descriptors includes page descriptors corresponding to 4 physical pages.

[0102] It should be noted that the above examples are merely illustrations of the contents contained in the memory block, and the embodiments of this application do not limit them. They can be set according to the actual situation.

[0103] The memory address translation method in the microkernel operating system provided in this embodiment generates and stores page descriptors when the user-mode memory management thread acquires a memory block. Compared to the prior art where the operating system generates and stores page descriptors for all physical pages of memory during initialization, this solution only stores the page descriptors corresponding to the acquired memory block, effectively reducing memory waste and saving memory resources.

[0104] The following describes the process of storing the memory block in a red-black tree data structure after the user-mode memory management thread provided in this application stores the starting physical address of the memory block, the starting virtual address of the memory block, the capacity of the memory block, and the page descriptor corresponding to each physical page in the memory block into the memory block.

[0105] After the user-mode memory management thread stores the starting physical address of the memory block, the starting virtual address of the memory block, the capacity of the memory block, and the page descriptor corresponding to each physical page in the memory block into the memory block, in order to improve the efficiency of subsequent memory block lookups, a red-black tree data structure can be established between the memory block and the memory blocks already acquired by the user-mode memory management thread and stored in the memory block set.

[0106] For example, Figure 4 The memory block data structure diagram provided in this application; such as Figure 4 As shown, there are a total of 7 memory blocks, which are stored using a red-black tree data structure. This embodiment does not limit the number of memory blocks; it can be determined based on actual circumstances.

[0107] The memory address translation method in the microkernel operating system provided in this embodiment improves the efficiency of memory block lookup by storing memory blocks in a red-black tree data structure.

[0108] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.

[0109] Figure 5 This is a schematic diagram illustrating the structure of an embodiment of the memory address translation device in a microkernel operating system provided in this application; this device can be integrated into the terminal device in the above method embodiments, or it can be implemented through the terminal device in the above method embodiments. Figure 5 As shown, the memory address translation device 50 in this microkernel operating system includes:

[0110] Communication module 51 is used to call the driver program based on the virtual memory address through the application process corresponding to the application program;

[0111] Conversion module 52 is used for:

[0112] The driver program calls the memory address translation interface of the user-mode memory management program through the driver thread process corresponding to the driver program, and the driver program includes the user-mode memory management program;

[0113] The user-mode memory management thread corresponding to the user-mode memory management program searches for the target memory block corresponding to the virtual memory address from the memory block set based on the virtual memory address.

[0114] The user-mode memory management thread determines the physical memory address corresponding to the virtual memory address based on the virtual memory address, the starting physical address of the memory block stored in the target memory block, and the starting virtual address of the memory block.

[0115] Furthermore, the conversion module 52 is specifically used for:

[0116] The user-mode memory management thread calculates the physical memory address corresponding to the virtual memory address using the formula: P = PS + (V - VS), where P represents the physical memory address corresponding to the virtual memory address, PS represents the starting physical address of the memory block stored in the target memory block, V represents the virtual memory address, and VS represents the starting virtual address of the memory block stored in the target memory block.

[0117] The acquisition module 53 is used to acquire the physical memory address of the physical peripheral storage data through the driver thread;

[0118] Furthermore, the conversion module 52 is also used for:

[0119] The driver thread calls the memory address translation interface of the user-mode memory management program;

[0120] The user-mode memory management thread searches for the target memory block corresponding to the physical memory address from the memory block set based on the physical memory address.

[0121] The user-mode memory management thread determines the virtual memory address corresponding to the physical memory address based on the physical memory address, the starting physical address of the memory block stored in the target memory block, and the starting virtual address of the memory block.

[0122] Furthermore, the communication module 51 is also used to send the virtual memory address corresponding to the physical memory address to the application process through the driver thread.

[0123] Furthermore, the conversion module 52 is also used for:

[0124] The user-mode memory management thread calculates the virtual memory address corresponding to the physical memory address using the formula: V = VS + (P - PS), where V represents the virtual memory address corresponding to the physical memory address, PS represents the starting physical address of the memory block stored in the target memory block, P represents the physical memory address, and VS represents the starting virtual address of the memory block stored in the target memory block.

[0125] Furthermore, the acquisition module 53 is also used for:

[0126] The user-mode memory management thread obtains the memory block, the starting physical address of the memory block, the starting virtual address of the memory block, and the capacity of the memory block through the kernel-mode memory management program.

[0127] The user-mode memory management thread generates a page descriptor for each physical page in the memory block.

[0128] The user-mode memory management thread stores the starting physical address of the memory block, the starting virtual address of the memory block, the capacity of the memory block, and the page descriptor corresponding to each physical page in the memory block into the memory block.

[0129] Furthermore, the acquisition module 53 is also used for:

[0130] The user-mode memory management thread establishes a red-black tree data structure between the memory block and the memory blocks already acquired by the user-mode memory management thread, and stores it in the memory block set.

[0131] The memory address translation device in the microkernel operating system provided in this embodiment is used to execute the technical solutions in any of the aforementioned method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.

[0132] Figure 6 This is a schematic diagram of the structure of an electronic device provided in this application. Figure 6 As shown, the electronic device 60 includes:

[0133] Processor 61, memory 62, and communication interface 63;

[0134] The memory 62 is used to store the executable instructions of the processor 61;

[0135] The processor 61 is configured to execute the technical solutions in any of the foregoing method embodiments by executing the executable instructions.

[0136] Optionally, the memory 62 can be either standalone or integrated with the processor 61.

[0137] Optionally, when the memory 62 is a device independent of the processor 61, the electronic device 60 may further include:

[0138] Bus 64, memory 62 and communication interface 63 are connected to processor 61 through bus 64 and complete communication with each other. Communication interface 63 is used to communicate with other devices.

[0139] Optionally, the communication interface 63 can be implemented using a transceiver. The communication interface is used to enable communication between the database access device and other devices (e.g., clients, read-write databases, and read-only databases). The memory may include random access memory (RAM) and may also include non-volatile memory, such as at least one disk drive.

[0140] Bus 64 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, only one thick line is used in the diagram, but this does not indicate that there is only one bus or one type of bus.

[0141] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0142] The electronic device is used to execute the technical solutions in any of the foregoing method embodiments. Its implementation principle and technical effect are similar, and will not be repeated here.

[0143] This application also provides a readable storage medium storing a computer program thereon, which, when executed by a processor, implements the technical solutions provided in any of the foregoing method embodiments.

[0144] This application also provides a computer program product, including a computer program, which, when executed by a processor, is used to implement the technical solutions provided in any of the foregoing method embodiments.

[0145] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0146] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A memory address translation method in a microkernel operating system, characterized in that, The method, applicable to electronic devices running a microkernel operating system, wherein the microkernel operating system includes applications, drivers, and user-mode memory management programs, comprises: The application process corresponding to the application calls the driver based on the virtual memory address; The driver thread corresponding to the driver calls the memory address translation interface of the user-mode memory management program, and the driver includes the user-mode memory management program; The user-mode memory management thread corresponding to the user-mode memory management program searches for the target memory block corresponding to the virtual memory address from the memory block set based on the virtual memory address; The user-mode memory management thread determines the physical memory address corresponding to the virtual memory address based on the virtual memory address, the starting physical address of the memory block stored in the target memory block, and the starting virtual address of the memory block, including: The user-mode memory management thread uses the following formula: The physical memory address corresponding to the virtual memory address is calculated, where P represents the physical memory address corresponding to the virtual memory address, PS represents the starting physical address of the memory block stored in the target memory block, V represents the virtual memory address, and VS represents the starting virtual address of the memory block stored in the target memory block.

2. The method according to claim 1, characterized in that, The method further includes: The driver thread obtains the physical memory address of the physical peripheral storage data; The driver thread calls the memory address translation interface of the user-mode memory management program; The user-mode memory management thread searches for the target memory block corresponding to the physical memory address from the memory block set based on the physical memory address; The user-mode memory management thread determines the virtual memory address corresponding to the physical memory address based on the physical memory address, the starting physical address of the memory block stored in the target memory block, and the starting virtual address of the memory block. The driver thread sends the virtual memory address corresponding to the physical memory address to the application process.

3. The method according to claim 2, characterized in that, The user-mode memory management thread determines the virtual memory address corresponding to the physical memory address based on the physical memory address, the starting physical address of the memory block stored in the target memory block, and the starting virtual address of the memory block, including: The user-mode memory management thread uses the following formula: The virtual memory address corresponding to the physical memory address is calculated, where V represents the virtual memory address corresponding to the physical memory address, PS represents the starting physical address of the memory block stored in the target memory block, P represents the physical memory address, and VS represents the starting virtual address of the memory block stored in the target memory block.

4. The method according to claim 1, characterized in that, The method further includes: The user-mode memory management thread obtains the memory block, the starting physical address of the memory block, the starting virtual address of the memory block, and the capacity of the memory block through the kernel-mode memory management program. For each physical page in the memory block, the user-mode memory management thread generates a page descriptor corresponding to that physical page. The user-mode memory management thread stores the starting physical address of the memory block, the starting virtual address of the memory block, the capacity of the memory block, and the page descriptor corresponding to each physical page in the memory block into the memory block.

5. The method according to claim 4, characterized in that, The method further includes: The user-mode memory management thread establishes a red-black tree data structure between the memory block and the memory blocks already acquired by the user-mode memory management thread, and stores it in the memory block set.

6. A memory address translation device in a microkernel operating system, characterized in that, include: The communication module is used to call the driver program based on the virtual memory address through the application process corresponding to the application. The conversion module is used for: The driver program calls the memory address translation interface of the user-mode memory management program through the driver thread corresponding to the driver program, and the driver program includes the user-mode memory management program; The user-mode memory management thread corresponding to the user-mode memory management program searches for the target memory block corresponding to the virtual memory address from the memory block set based on the virtual memory address. The user-mode memory management thread determines the physical memory address corresponding to the virtual memory address based on the virtual memory address, the starting physical address of the memory block stored in the target memory block, and the starting virtual address of the memory block. This includes the user-mode memory management thread using the following formula: The physical memory address corresponding to the virtual memory address is calculated, where P represents the physical memory address corresponding to the virtual memory address, PS represents the starting physical address of the memory block stored in the target memory block, V represents the virtual memory address, and VS represents the starting virtual address of the memory block stored in the target memory block.

7. An electronic device, characterized in that, include: Processor, memory, communication interface; The memory is used to store the executable instructions of the processor; The processor is configured to execute the memory address translation method in a microkernel operating system according to any one of claims 1 to 5 by executing the executable instructions.

8. A readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the memory address translation method in the microkernel operating system according to any one of claims 1 to 5.

9. A computer program product, characterized in that, Includes a computer program, which, when executed by a processor, is used to implement the memory address translation method in a microkernel operating system as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method and system for safely transmitting data among parallel-running multiple user operating systems

    CN102110196A

  • Address mapping method and device of shared memory

    CN107729159A