Data transmission method, device, computer equipment and storage medium

By obtaining the working status of the data transmission port and utilizing virtual memory mapping technology, the problem of resource consumption during data transmission between user space and kernel space in the Linux operating system is solved, zero-copy data transmission is achieved, and system performance and driver configuration flexibility are improved.

CN115718707BActive Publication Date: 2025-10-03CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202211515051.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-29
Publication Date
2025-10-03
Estimated Expiration
2042-11-29

AI Technical Summary

Technical Problem

In the Linux operating system, data transmission between user space and kernel space involves repeated copying, which results in high consumption of system resources and degrades system performance.

Method used

By obtaining the working status of the data transmission port, the physical memory of the data to be transmitted stored in the kernel space is mapped to the user space using virtual memory, realizing direct data transmission in the user space and avoiding data copying between the user space and the kernel space.

Benefits of technology

It reduces CPU resource consumption, improves system performance, simplifies switch chip driver modification, increases configuration flexibility, and enables data reading and analysis in user space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115718707B_ABST
    Figure CN115718707B_ABST
Patent Text Reader

Abstract

This application relates to a data transmission method, apparatus, computer device, and storage medium. The method comprises: obtaining the operating status of a data transmission port and, based on the operating status, obtaining data to be transmitted; storing the data to be transmitted in virtual memory, wherein the virtual memory is obtained by mapping physical memory in kernel space to corresponding user space; and obtaining the data to be transmitted from the virtual memory and sending it so that the data transmission port receives the data to be transmitted. This method can reduce resource consumption, thereby improving system performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a method, apparatus, computer equipment, and storage medium for data transmission. Background Art

[0002] The operating space of the Linux operating system can be divided into kernel space and user space, among which the switching chip of the Linux operating system is mainly driven in the kernel space. When the user process receives data to be transmitted from the data transmission port, it is necessary to copy the data to be transmitted from the kernel space to the user space, and then read the data in the user space through the user process. Similarly, when the user process sends data to be transmitted from the data transmission port, it is necessary to copy the data to be transmitted from the user space to the kernel space, and then send the data. Furthermore, during the data transmission process, repeated copying between the user space and the kernel space may occur, thereby consuming more system resources, such as the resources of the Central Processing Unit (CPU) or other devices, and reducing system performance. Summary of the Invention

[0003] Based on this, a data transmission method, apparatus, computer equipment and storage medium are provided to improve the problem in the prior art that data transmission between user space and kernel space consumes more system resources.

[0004] In one aspect, a method for data transmission is provided, the method comprising:

[0005] Obtain the working status of the data transmission port and obtain the data to be transmitted according to the working status;

[0006] The data to be transmitted is stored in the virtual memory, wherein the virtual memory is obtained by mapping the physical memory of the kernel space to the corresponding user space;

[0007] The data to be transmitted is obtained from the virtual memory and sent so that the data transmission port receives the data to be transmitted.

[0008] In one embodiment, the virtual memory is obtained by mapping the physical memory to the corresponding user space, including: obtaining the physical address of the physical memory, and mapping the physical address of the physical memory to the corresponding user space, obtaining the virtual address of the physical memory and the corresponding virtual memory, so that the data to be transmitted is transmitted from the user space.

[0009] In one embodiment, obtaining the working status of the data transmission port and obtaining the data to be transmitted based on the working status includes: obtaining the working status of the data transmission port, and if the working status changes, obtaining the data to be transmitted from the physical memory, wherein the working status includes a data receiving status or a data sending status.

[0010] In one embodiment, a physical address of a physical memory is obtained, and the physical address of the physical memory is mapped to a corresponding user space, and a virtual address of the physical memory and a corresponding virtual memory are obtained so that the data to be transmitted are transmitted from the user space, including: obtaining the physical address of the physical memory, and mapping the physical address of the physical memory to a corresponding user space, and obtaining the virtual address of the physical memory; obtaining the physical pin of the data transmission port, and mapping the physical pin of the data transmission port to a corresponding user space, and obtaining the virtual pin of the data transmission port; and transmitting the data to be transmitted from the user space according to the virtual address of the physical memory and the virtual pin of the data transmission port.

[0011] In one embodiment, the working status of the data transmission port is obtained. If the working status changes, the data to be transmitted is obtained from the physical memory, wherein the working status includes a data receiving status and a data sending status, including: obtaining the working status of the data transmission port, and determining whether the working status is a data receiving status; if so, obtaining an interrupt signal and a query time threshold of the physical memory, and obtaining the data to be transmitted based on the interrupt signal and the query time threshold.

[0012] In one embodiment, before obtaining the working status of the data transmission port and obtaining the data to be transmitted based on the working status, it also includes: obtaining the physical address of the data transmission port, and obtaining the corresponding network address based on the physical address of the data transmission port; obtaining the corresponding programming interface based on the network address, and establishing a connection relationship between the port physical address and the user space based on the programming interface; and obtaining the working status of the data transmission port based on the connection relationship.

[0013] In one embodiment, if yes, then obtain the interrupt signal and query time threshold of the physical memory, and obtain the data to be transmitted based on the interrupt signal and the query time threshold, including: if yes, then obtain the interrupt signal and query time threshold of the physical memory, and query whether there is data to be transmitted in the physical memory based on the interrupt signal and the query time threshold; if yes, obtain the data to be transmitted.

[0014] In one embodiment, after obtaining the working status of the data transmission port, the method further includes: determining whether the working status is a data sending state; if so, sending the data to be transmitted through the data transmission port so that the virtual memory receives the data to be transmitted.

[0015] On the other hand, a device for data storage backup is provided, which includes: a data acquisition module, used to obtain the working status of the data transmission port and obtain the data to be transmitted according to the working status; a data storage module, used to store the data to be transmitted in a virtual memory, wherein the virtual memory is obtained by mapping the address of the physical memory to the corresponding user space; and a data sending module, used to obtain the data to be transmitted from the virtual memory and send it.

[0016] On the other hand, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are implemented: obtaining the working status of a data transmission port, and obtaining data to be transmitted based on the working status; storing the data to be transmitted in a virtual memory, wherein the virtual memory is obtained by mapping the physical memory of the kernel space to the corresponding user space; obtaining the data to be transmitted from the virtual memory and sending it, so that the data transmission port receives the data to be transmitted.

[0017] On the other hand, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: obtaining the working status of the data transmission port and obtaining the data to be transmitted based on the working status; storing the data to be transmitted in a virtual memory, wherein the virtual memory is obtained by mapping the physical memory of the kernel space to the corresponding user space; obtaining the data to be transmitted from the virtual memory and sending it so that the data transmission port receives the data to be transmitted.

[0018] The above-mentioned data transmission method, device, computer equipment and storage medium obtain the working status of the data transmission port and obtain the data to be transmitted based on the working status; store the data to be transmitted in the virtual memory, wherein the virtual memory is obtained by mapping the physical memory of the kernel space to the corresponding user space; obtain the data to be transmitted from the virtual memory and send it, so that the data transmission port receives the data to be transmitted, thereby improving system performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 A diagram illustrating an application environment of a method for data transmission in one embodiment;

[0020] Figure 2 A schematic flow chart of a data transmission method according to an embodiment;

[0021] Figure 3 A structural block diagram of a data transmission device in one embodiment;

[0022] Figure 4 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0023] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0024] The data transmission method provided by this application can be applied to Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. The virtual address space of the Linux operating system is divided into kernel space and user space. The switch chip of the Linux operating system is mainly driven in the kernel space. This means that when a user process receives data, it needs to copy the data from the kernel space to the user space, and then read the data in the user space through the user process. Similarly, when a user process sends data, it needs to copy the data from the user space to the kernel space before sending the data. This causes data to be copied repeatedly between the user space and the kernel space during transmission, thereby consuming more CPU resources and reducing system performance. The data transmission method provided in this application can obtain the working status of the data transmission port through server 104 and obtain the data to be transmitted based on the working status; store the data to be transmitted in virtual memory, wherein the virtual memory is obtained by mapping the physical memory of the kernel space to the corresponding user space; obtain the data to be transmitted from the virtual memory and send it so that the data transmission port receives the data to be transmitted, thereby improving system performance. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablet computers, and portable wearable devices, and server 104 can be implemented as a standalone server or a server cluster consisting of multiple servers.

[0025] In one embodiment, Figure 2 As shown, a method for data transmission is provided, which is applied to Figure 1 The following steps are used as an example to illustrate the terminal in the figure:

[0026] Step 201, obtaining the working status of the data transmission port, and obtaining the data to be transmitted according to the working status;

[0027] Step 202: storing the data to be transmitted in a virtual memory, wherein the virtual memory is obtained by mapping the physical memory of the kernel space to the corresponding user space;

[0028] Step 203: Obtain the data to be transmitted from the virtual memory and send it so that the data transmission port receives the data to be transmitted.

[0029] In step 201, it is exemplified that the working status of the data transmission port is obtained, and the data to be transmitted is obtained according to the working status. For example, the data transmission port can be a user space input / output (I / O) device port in the Linux operating system. When data is transmitted between the I / O device and the user space, the working status of the data transmission port becomes a data receiving state or a data sending state, that is, when the user process needs to read or write data, the data transmission port will send an I / O request to the CPU, and then the CPU will send the corresponding I / O request to the corresponding physical memory to obtain the data to be transmitted. In this process, the data transmission work is performed by the physical memory and the corresponding device, and the CPU does not participate in the data transmission work, thereby reducing the consumption of CPU resources.

[0030] In step 202, it is exemplified that the data to be transmitted is stored in the virtual memory, wherein the virtual memory is obtained by mapping the physical memory of the kernel space to the corresponding user space. For example, the physical memory can be the physical memory corresponding to the direct memory access (DMA) of the switching chip. Since the data will be copied repeatedly when the switching chip is driven in the kernel space, the physical address of the switching chip and the physical address of the physical memory of the DMA can be mapped to the corresponding operating space, that is, the user space, to obtain the virtual address of the switching chip in the user space and the virtual memory corresponding to the physical memory of the DMA, thereby realizing the data transmission work in the user space. Specifically, the CPU sends an I / O request to the DMA controller, and the DMA controller further sends the I / O request to the physical memory. Then, after receiving the I / O request, the physical memory sends the data to be transmitted to the corresponding virtual memory.

[0031] In step 203, it is exemplarily explained that the data to be transmitted is obtained from the virtual memory and sent so that the data transmission port receives the data to be transmitted. For example, when the data to be transmitted in the virtual memory meets the data threshold, the DMA controller can send a corresponding signal to the CPU, and then the CPU sends the data to be transmitted in the virtual memory.

[0032] The above-described data transmission method can be applied to the user space of the Linux operating system, achieving zero-copy data transmission within the user space. The method obtains the operating status of the data transmission port and, based on the operating status, obtains the data to be transmitted; stores the data to be transmitted in virtual memory, which is obtained by mapping the physical memory of the kernel space to the corresponding user space; and obtains the data to be transmitted from the virtual memory and sends it so that the data transmission port receives the data to be transmitted, thereby reducing CPU resource consumption and improving system performance.

[0033] As a specific implementation method of step 202, the virtual memory is obtained by mapping the physical memory to the corresponding user space, including: obtaining the physical address of the physical memory, and mapping the physical address of the physical memory to the corresponding user space, obtaining the virtual address of the physical memory and the corresponding virtual memory, so that the data to be transmitted is transmitted from the user space.

[0034] It should be noted that after mapping the physical address of the switching chip and the physical address of the physical memory of the DMA to the user space, in order to enable the user process to directly read and / or write data in the user space, the switching chip registers need to be initialized. Specifically, this includes configuring the corresponding clock for the switching chip to enable the switching chip to work; initializing the corresponding registers of the switching chip; initializing the ring buffer corresponding to the DMA and configuring the DMA registers so that the data to be transmitted can be transmitted through the DMA; and finally, enabling the corresponding interrupts and data transmission and reception so as to send interrupt signals to realize data transmission. First, since it is difficult to modify the driver when implementing the switching chip driver in the kernel space of the Linux operating system, the above method improves the problem of difficult driver modification by configuring the corresponding driver of the switching chip in the user space and improves the flexibility of the switching chip configuration; secondly, traditional data transmission requires copying to the kernel space after receiving the I / O request, which makes data reading and analysis difficult, while the above method can directly realize the reading and analysis of all information of the switching chip in the user space.

[0035] As a specific implementation method of step 201, the working status of the data transmission port is obtained, and the data to be transmitted is obtained according to the working status, including: obtaining the working status of the data transmission port, and if the working status changes, obtaining the data to be transmitted from the physical memory, wherein the working status includes a data receiving status or a data sending status.

[0036] It should be noted that when data is transmitted between the I / O device and the user space, the working state of the data transmission port becomes the data receiving state or the data sending state. That is, when the user process needs to read or write data, the data transmission port will send an I / O request to the CPU, and then the CPU will send the corresponding I / O request to the corresponding physical memory. After receiving the I / O request, the physical memory transfers the data to be transmitted to the virtual memory, and the data transmission port obtains the corresponding data to be transmitted from the virtual memory.

[0037] As a specific implementation method of the above embodiment, the physical address of the physical memory is obtained, and the physical address of the physical memory is mapped to the corresponding user space, and the virtual address of the physical memory and the corresponding virtual memory are obtained so that the data to be transmitted are transmitted from the user space, including: obtaining the physical address of the physical memory, and mapping the physical address of the physical memory to the corresponding user space to obtain the virtual address of the physical memory; obtaining the physical pin of the data transmission port, and mapping the physical pin of the data transmission port to the corresponding user space to obtain the virtual pin of the data transmission port; transmitting the data to be transmitted from the user space according to the virtual address of the physical memory and the virtual pin of the data transmission port.

[0038] It should be noted that the physical address of the physical memory is mapped to the corresponding user space, including the mapping of the physical address of the switching chip and the mapping of the physical memory of the DMA. The physical pin of the data transmission port refers to the I / O interrupt pin corresponding to the user space I / O device. After the above mapping is completed, the clock address corresponding to the user space I / O device also needs to be mapped to the user space so that the user space I / O device sends the corresponding signal.

[0039] As a specific implementation method of the above embodiment, the working status of the data transmission port is obtained. If the working status changes, the data to be transmitted is obtained from the physical memory, wherein the working status includes the data receiving status and the data sending status, including: obtaining the working status of the data transmission port, and judging whether the working status is the data receiving status; if so, obtaining the interrupt signal and query time threshold of the physical memory, and obtaining the data to be transmitted according to the interrupt signal and the query time threshold.

[0040] It should be noted that when the user process needs to read or write data, the physical memory transfers the data to be transmitted to the virtual memory. At this time, the interrupt and polling method can be used to determine whether the data to be transmitted can be sent, that is, the interrupt signal after the physical memory transmits the data and the query time threshold is set, and the transmission status of the physical memory and the virtual memory is periodically queried according to the query time threshold, so as to determine whether the data to be transmitted has been transmitted to the virtual memory, and send the data to be transmitted from the virtual memory.

[0041] As a specific implementation method of the above embodiment, before obtaining the working status of the data transmission port and obtaining the data to be transmitted based on the working status, it also includes: obtaining the physical address of the data transmission port, and obtaining the corresponding network address based on the physical address of the data transmission port; obtaining the corresponding programming interface based on the network address, and establishing a connection relationship between the port physical address and the user space based on the programming interface; obtaining the working status of the data transmission port based on the connection relationship.

[0042] It should be noted that in a specific network environment configuration, the data transmission port can be a virtual network card port. When data transmission is required in user space, a virtual network card needs to be created and the physical address and network address of the virtual network card port need to be configured, that is, the Media Access Control (MAC) address and the Internet Protocol (IP) address. Then, based on the IP address, the corresponding programming interface is obtained. The programming interface refers to a socket. Then, a connection is established with the corresponding gateway or server through the socket. The socket performs corresponding exchange configuration based on the configuration data sent by the server or gateway, thereby realizing the transmission of virtual network card data in user space. In some implementation processes, the data of the virtual network card can be read in a blocking manner.

[0043] As a specific implementation method of the above embodiment, after obtaining the working status of the data transmission port, it also includes: judging whether the working status is a data sending state, and if so, sending the data to be transmitted through the data transmission port so that the virtual memory receives the data to be transmitted.

[0044] It should be noted that the data transmission method involved in this application is not limited to sending data from virtual memory to a data transmission port, but also includes sending data from a data transmission port to virtual memory and then storing data from the virtual memory to physical memory.

[0045] It should be understood that although Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0046] In one embodiment, Figure 3 As shown, a data transmission device is provided, comprising: a data acquisition module, a data storage module and a data sending module, wherein:

[0047] The data acquisition module is used to obtain the working status of the data transmission port and obtain the data to be transmitted according to the working status;

[0048] A data storage module is used to store the data to be transmitted in a virtual memory, wherein the virtual memory is obtained by mapping the address of the physical memory to the corresponding user space;

[0049] The data sending module is used to obtain the data to be transmitted from the virtual memory and send it.

[0050] Optionally, the data storage module is further used to obtain the physical address of the physical memory, and map the physical address of the physical memory to the corresponding user space, to obtain the virtual address of the physical memory and the corresponding virtual memory, so that the data to be transmitted is transmitted from the user space.

[0051] Optionally, the data acquisition module is further configured to acquire the working status of the data transmission port, and if the working status changes, obtain the data to be transmitted from the physical memory, wherein the working status includes a data receiving status and a data sending status.

[0052] Optionally, the data storage module is also used to obtain the physical address of the physical memory, and map the physical address of the physical memory to the corresponding user space to obtain the virtual address of the physical memory; obtain the physical pin of the data transmission port, and map the physical pin of the data transmission port to the corresponding user space to obtain the virtual pin of the data transmission port; according to the virtual address of the physical memory and the virtual pin of the data transmission port, transmit the data to be transmitted from the user space.

[0053] Optionally, the data acquisition module is also used to obtain the working status of the data transmission port and determine whether the working status is a data receiving state or a data sending state; if so, obtain the interrupt signal and query time threshold of the physical memory, and obtain the data to be transmitted based on the interrupt signal and query time threshold.

[0054] Optionally, the data acquisition module is also used to obtain the physical address of the data transmission port, and obtain the corresponding network address based on the physical address of the data transmission port; obtain the corresponding programming interface based on the network address, and establish a connection relationship between the port physical address and the user space based on the programming interface; and obtain the working status of the data transmission port based on the connection relationship.

[0055] Optionally, the data acquisition module is also used to obtain the interrupt signal and query time threshold of the physical memory, and obtain the data to be transmitted based on the interrupt signal and query time threshold. If so, the interrupt signal and query time threshold of the physical memory are obtained, and the physical memory is queried based on the interrupt signal and query time threshold whether there is data to be transmitted; if so, the data to be transmitted is obtained.

[0056] Optionally, the data acquisition module is further configured to determine whether the working state is a data sending state, and if so, to send the data to be transmitted through the data transmission port so that the virtual memory receives the data to be transmitted.

[0057] For the specific definition of the data transmission device, please refer to the definition of the data transmission method above and will not be repeated here. The various modules in the above-mentioned data transmission device can be implemented in whole or in part by software, hardware, or a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of the above modules.

[0058] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, memory, network interface, display screen and input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a method for data transmission is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse.

[0059] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0060] In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented: obtaining the working status of a data transmission port and obtaining data to be transmitted based on the working status; storing the data to be transmitted in a virtual memory, wherein the virtual memory is obtained by mapping the physical memory of the kernel space to the corresponding user space; obtaining the data to be transmitted from the virtual memory and sending it so that the data transmission port receives the data to be transmitted.

[0061] In one embodiment, when the processor executes the computer program, it also implements the following steps: obtaining the physical address of the physical memory, and mapping the physical address of the physical memory to the corresponding user space, obtaining the virtual address of the physical memory and the corresponding virtual memory, so that the data to be transmitted is transmitted from the user space.

[0062] In one embodiment, when executing the computer program, the processor further implements the following steps: obtaining the working status of the data transmission port, and if the working status changes, obtaining the data to be transmitted from the physical memory, wherein the working status includes a data receiving status or a data sending status.

[0063] In one embodiment, a physical address of a physical memory is obtained, and the physical address of the physical memory is mapped to a corresponding user space to obtain a virtual address of the physical memory; a physical pin of a data transmission port is obtained, and the physical pin of the data transmission port is mapped to a corresponding user space to obtain a virtual pin of the data transmission port; and data to be transmitted is transmitted from the user space according to the virtual address of the physical memory and the virtual pin of the data transmission port.

[0064] In one embodiment, the working status of the data transmission port is obtained to determine whether the working status is a data receiving state; if so, the interrupt signal and query time threshold of the physical memory are obtained, and the data to be transmitted is obtained according to the interrupt signal and the query time threshold.

[0065] In one embodiment, the physical address of the data transmission port is obtained, and the corresponding network address is obtained based on the physical address of the data transmission port; the corresponding programming interface is obtained based on the network address, and a connection relationship between the port physical address and the user space is established based on the programming interface; based on the connection relationship, the working status of the data transmission port is obtained.

[0066] In one embodiment, the interrupt signal and query time threshold of the physical memory are obtained, and the data to be transmitted is obtained based on the interrupt signal and the query time threshold, including: if yes, the interrupt signal and query time threshold of the physical memory are obtained, and the physical memory is queried based on the interrupt signal and the query time threshold whether there is data to be transmitted; if yes, the data to be transmitted is obtained.

[0067] In one embodiment, it is determined whether the working state is a data transmission state. If so, the data to be transmitted is sent through the data transmission port so that the virtual memory receives the data to be transmitted.

[0068] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: obtaining the working status of a data transmission port and obtaining data to be transmitted based on the working status; storing the data to be transmitted in a virtual memory, wherein the virtual memory is obtained by mapping the physical memory of the kernel space to the corresponding user space; obtaining the data to be transmitted from the virtual memory and sending it so that the data transmission port receives the data to be transmitted.

[0069] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: obtaining the physical address of the physical memory, and mapping the physical address of the physical memory to the corresponding user space, obtaining the virtual address of the physical memory and the corresponding virtual memory, so that the data to be transmitted is transmitted from the user space.

[0070] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: obtaining the working status of the data transmission port, and if the working status changes, obtaining the data to be transmitted from the physical memory, wherein the working status includes a data receiving status or a data sending status.

[0071] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: obtaining the physical address of the physical memory, and mapping the physical address of the physical memory to the corresponding user space to obtain the virtual address of the physical memory; obtaining the physical pin of the data transmission port, and mapping the physical pin of the data transmission port to the corresponding user space to obtain the virtual pin of the data transmission port; transmitting the data to be transmitted from the user space according to the virtual address of the physical memory and the virtual pin of the data transmission port.

[0072] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: obtaining the working status of the data transmission port, and determining whether the working status is a data receiving state; if so, obtaining the interrupt signal and query time threshold of the physical memory, and obtaining the data to be transmitted based on the interrupt signal and the query time threshold.

[0073] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: obtaining the physical address of the data transmission port, and obtaining the corresponding network address based on the physical address of the data transmission port; obtaining the corresponding programming interface based on the network address, and establishing a connection relationship between the port physical address and the user space based on the programming interface; and obtaining the working status of the data transmission port based on the connection relationship.

[0074] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: obtaining the interrupt signal and query time threshold of the physical memory, and obtaining the data to be transmitted based on the interrupt signal and the query time threshold, including: if yes, obtaining the interrupt signal and query time threshold of the physical memory, and querying whether there is data to be transmitted in the physical memory based on the interrupt signal and the query time threshold; if yes, obtaining the data to be transmitted.

[0075] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: determining whether the working state is a data sending state, and if so, sending the data to be transmitted through the data transmission port so that the virtual memory receives the data to be transmitted.

[0076] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0077] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0078] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.

Claims

1. A data transmission method, applied to user space, characterized in that: include: Acquiring the working status of the data transmission port, and obtaining the data to be transmitted according to the working status; Obtaining a physical address of a physical memory in a kernel space, and mapping the physical address of the physical memory to a corresponding user space, to obtain a virtual address of the physical memory and a corresponding virtual memory; obtaining a physical pin of the data transmission port, and mapping the physical pin of the data transmission port to the corresponding user space, to obtain a virtual pin of the data transmission port, so as to transmit the data to be transmitted from the user space according to the virtual address of the physical memory and the virtual pin of the data transmission port; wherein the physical pin is an I / O interrupt pin; and storing the data to be transmitted in the virtual memory; The data to be transmitted is obtained from the virtual memory and sent, so that the data transmission port receives the data to be transmitted.

2. The data transmission method according to claim 1, wherein: Acquiring the working status of the data transmission port and obtaining the data to be transmitted according to the working status, including: The working state of the data transmission port is obtained, and if the working state changes, the data to be transmitted is obtained from the physical memory, wherein the working state includes a data receiving state or a data sending state.

3. The data transmission method according to claim 2, wherein: Acquire the working state of the data transmission port, and if the working state changes, obtain the data to be transmitted from the physical memory, wherein the working state includes a data receiving state and a data sending state, including: Acquire the working state of the data transmission port, and determine whether the working state is the data receiving state; If so, an interrupt signal and a query time threshold of the physical memory are obtained, and the data to be transmitted is obtained according to the interrupt signal and the query time threshold.

4. The data transmission method according to claim 1, wherein: Before obtaining the working status of the data transmission port and obtaining the data to be transmitted according to the working status, the method further includes: Obtaining the physical address of the data transmission port, and obtaining a corresponding network address according to the physical address of the data transmission port; Obtaining a corresponding programming interface according to the network address, and establishing a connection relationship between the physical address of the data transmission port and the user space according to the programming interface; The working status of the data transmission port is obtained according to the connection relationship.

5. The data transmission method according to claim 3, wherein: If yes, obtaining an interrupt signal and a query time threshold of the physical memory, and obtaining the data to be transmitted according to the interrupt signal and the query time threshold, including: If so, obtaining the interrupt signal and the query time threshold of the physical memory, and querying whether the physical memory has the data to be transmitted according to the interrupt signal and the query time threshold; If so, the data to be transmitted is obtained.

6. The data transmission method according to claim 2, wherein: After obtaining the working status of the data transmission port, it also includes: It is determined whether the working state is the data sending state. If so, the data to be transmitted is sent through the data transmission port so that the virtual memory receives the data to be transmitted.

7. A data transmission device, characterized in that: include: A data acquisition module is used to acquire the working status of the data transmission port and obtain the data to be transmitted according to the working status; a data storage module, configured to obtain a physical address of a physical memory in a kernel space, and map the physical address of the physical memory to a corresponding user space to obtain a virtual address of the physical memory and a corresponding virtual memory; and to obtain a physical pin of the data transmission port, map the physical pin of the data transmission port to the corresponding user space to obtain a virtual pin of the data transmission port, so as to transmit the data to be transmitted from the user space according to the virtual address of the physical memory and the virtual pin of the data transmission port; wherein the physical pin is an I / O interrupt pin; and to store the data to be transmitted in the virtual memory; The data sending module is used to obtain the data to be transmitted from the virtual memory and send it.

8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Method for realizing user-state receiving and transmission of messages for ARM (Advanced RISC Machine) CPU (Central Processing Unit)

    CN104050101A

  • Video processing method in Linux system

    CN105450986A

  • Data transmission method, device and equipment based on Linux operating system

    CN114911568A