Search

CN-122019212-A - Communication method, computing device, storage medium and computer program product

CN122019212ACN 122019212 ACN122019212 ACN 122019212ACN-122019212-A

Abstract

The embodiment of the specification provides a communication method applied to a hardware virtualization system. The system isolates two partitions respectively running a first operating system and a second operating system through a virtual machine monitor program, and creates a first device file for the user program of the first operating system to access based on a shared memory. The method comprises the steps of mapping the shared memory to an address space of the user program through the device file, so that the user program can directly read data written into the shared memory by the second operating system or directly write the data and inform the second operating system of reading. According to the scheme, the intervention of the kernel of the first operating system is avoided, the data copying and the context switching between the kernel mode and the user mode are eliminated, so that the communication delay is remarkably reduced, the throughput is improved, and the efficient communication among different operating systems is realized.

Inventors

  • WEN HUAIZHI
  • ZHU HONGLEI

Assignees

  • 飞腾信息技术有限公司

Dates

Publication Date
20260512
Application Date
20260213

Claims (14)

  1. 1. The communication method is characterized by being applied to a target system based on hardware virtualization, wherein the target system comprises a first partition and a second partition which are isolated by a virtual machine monitoring program, the first partition is used for running a first operating system, the second partition is used for running a second operating system, the first operating system and the second operating system communicate through a shared memory, the virtual machine monitoring program creates a target virtual device based on the shared memory, after the first operating system finds the target virtual device, a first device file is created, and the first device file is an interaction interface of a user program of the first operating system to the shared memory, and the communication method comprises the following steps: Mapping the shared memory to an address space of the user program based on the first device file; Based on the shared memory mapped to the address space of the user program, the user program directly reads the received data written to the shared memory by the second operating system, and/or the user program directly writes the transmission data in the shared memory and notifies the second operating system to read the transmission data from the shared memory.
  2. 2. The method of claim 1, wherein the user program directly reading the received data written to the shared memory by the second operating system comprises: And responding to the occurrence of a target event aiming at the first equipment file, wherein the user program of the first operating system directly reads the received data from the shared memory and processes the received data, the target event is triggered by the second operating system, and the target event characterizes the second operating system to write the first target data in the shared memory.
  3. 3. The method of claim 2, wherein the process of the second operating system triggering the target event comprises: Writing a doorbell register into the second operating system, wherein the doorbell register is formed by virtualization of the virtual machine monitor; the virtual machine monitoring program monitors the second operating system to write into a doorbell register and sends a first interrupt to the first operating system; the kernel of the first operating system generates the target event in response to the first interrupt.
  4. 4. The method of claim 1, wherein the user program writing the send data directly in the shared memory and informing the second operating system to read the send data from the shared memory comprises: the user program directly writes the sending data in the shared memory, and writes a value of a doorbell register to trigger a second interrupt, wherein the doorbell register is formed by virtualization of the virtual machine monitor, and the second interrupt is used for notifying the second operating system to read the sending data from the shared memory.
  5. 5. The method of claim 1, wherein the creating of the first device file comprises: the virtual machine monitoring program registers target virtual equipment to the kernel of the first operating system, and the target virtual equipment is identified based on an identity; loading and initializing a device driving module corresponding to the target communication device when the kernel of the first operating system detects the target virtual device; The device driver module is configured to register a user space input/output UIO device with a kernel of the first operating system, so as to generate a first device file for access by a user program in a device file system.
  6. 6. The method of claim 5, wherein the device driver module binds with the target virtual device via the identity and invokes a probe function to complete initialization; The device driving module is specifically configured to read configuration information of the target virtual device to obtain a physical address and a size parameter of a shared memory area, and request physical address space resources of the shared memory area according to the parameter; initializing a user space input/output (UIO) information structure body, setting memory area parameters and interrupt processing functions, and registering UIO equipment with the first operating system kernel to generate the first equipment file in an equipment file system; the interrupt handling function triggers a UIO event notification when an interrupt of the target virtual device arrives, enabling the user program to detect a target event based on the first device file.
  7. 7. The method of claim 5, wherein the device driver module is further configured to disable a primary interrupt mode of the target virtual device.
  8. 8. The method of any of claims 1-7, wherein the second operating system is configured to process a real-time task in communication with the first operating system via the shared memory, and wherein the real-time task is configured to have a highest priority; The kernel of the second operating system enables preemptive scheduling to ensure that the highest priority real-time tasks are preferentially executed.
  9. 9. The method of claim 8, wherein the second operating system comprises a ring buffer for accumulating data to be sent to the first operating system; When the data quantity accumulated in the ring buffer reaches a preset threshold, the second operating system writes the data accumulated in the ring buffer into the shared memory, and triggers a third interrupt, wherein the third interrupt is used for notifying the first operating system to read the data written by the second operating system in the shared memory.
  10. 10. The method of claim 9, wherein the second operating system performs an atomic operation to update a write pointer and a valid data length of a buffer when writing data to the ring buffer, and performs a write doorbell register operation to trigger the third interrupt when the valid data length reaches the preset threshold.
  11. 11. The method of any one of claims 1-7, further comprising: The virtual machine monitor optimizes an interrupt handling mechanism, the optimizing including at least one of: Setting an interrupt for the shared memory communication as a high priority interrupt; clearing an active state of a soft interrupt for inter-core communication upon initializing the interrupt controller; In the interrupt reinjection process, if the interrupt to be injected is detected to be in an active state currently, the interrupt is marked as an active and pending state.
  12. 12. A computing device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the communication method of any one of claims 1 to 11 when the computer program is executed.
  13. 13. A storage medium having a computer program stored thereon, which when executed by a processor implements the communication method of any of claims 1 to 11.
  14. 14. A computer program product, characterized in that the computer program product comprises a computer program which, when being executed by a processor, implements the communication method according to any of claims 1-11.

Description

Communication method, computing device, storage medium and computer program product Technical Field The present disclosure relates to the field of computer application technology, and in particular, to a communication method between operating systems based on a multi-core processor, and more particularly, to a communication method, a computing device, a storage medium, and a computer program product. Background The multi-Core processor refers to a processor architecture in which two or more processor cores (CPU cores) are integrated on a single chip, each processor Core can independently execute an instruction stream, and coordination of hardware resources and data interaction between the cores can be realized through an on-chip bus and the like. Taking an embedded multi-core system as an example, in some scenarios, the embedded multi-core system needs to consider both real-time tasks and non-real-time tasks. Common scenes needing real-time tasks are industrial control, sensor data acquisition and the like, and the application scenes have high requirements on real-time performance. Common non-real-time tasks are graphical interfaces, background data processing, logging and analysis, etc., where these scenarios are highly tolerant of latency. The multi-system mixed deployment scheme on the embedded multi-core system can meet the requirements of the two application scenes, namely a General-purpose operating system (Purpose Operating System, GPOS) and a Real-time operating system (Real-Time Operating System, RTOS) can be deployed in the embedded multi-core system at the same time, wherein the General-purpose operating system is particularly suitable for processing non-Real-time tasks by taking the characteristics of taking the overall throughput, the resource utilization rate and the human-computer interaction experience of concurrent multi-tasks into consideration as cores, and has no hard deterministic time constraint on task response, and the Real-time operating system has strong certainty on task scheduling and external event response and can finish execution within a predetermined time constraint, so that the Real-time operating system is particularly suitable for processing Real-time tasks. But in the actual use process, the communication efficiency among a plurality of operating systems which are deployed based on the multi-core system in a mixed way is found to be lower. Disclosure of Invention Embodiments of the present disclosure provide a communication method, a computing device, a storage medium, and a computer program product, so as to achieve the purpose of improving communication efficiency between different operating systems. In order to achieve the technical purpose, the embodiment of the specification provides the following technical scheme: In a first aspect, an embodiment of the present disclosure provides a communication method applied to a target system based on hardware virtualization, where the target system includes a first partition and a second partition that are isolated by a virtual machine monitor, the first partition is used to run a first operating system, the second partition is used to run a second operating system, the first operating system and the second operating system communicate through a shared memory, the virtual machine monitor creates a target virtual device based on the shared memory, and when the first operating system discovers the target virtual device, a first device file may be created, where the first device file is an interactive interface of a user program of the first operating system to the shared memory, and the communication method includes: Mapping the shared memory to an address space of the user program based on the first device file; Based on the shared memory mapped to the address space of the user program, the user program directly reads the received data written to the shared memory by the second operating system, and/or the user program directly writes the transmission data in the shared memory and notifies the second operating system to read the transmission data from the shared memory. In a second aspect, an embodiment of the present disclosure provides a communication apparatus applied to a target system based on hardware virtualization, where the target system includes a first partition and a second partition that are isolated by a virtual machine monitor, the first partition is used to run a first operating system, the second partition is used to run a second operating system, the first operating system and the second operating system communicate through a shared memory, the virtual machine monitor creates a target virtual device based on the shared memory, after the first operating system discovers the target virtual device, a first device file is created, and the first device file is an interactive interface between a user program of the first operating system and the shared memory, where the communication apparatus includes: a first modu