Data transmission method and device, terminal equipment and storage medium

By competing with multiple processes in the autonomous driving system to open the shared memory of each Topic and being managed by one process, the system robustness problem caused by the centralized shared memory allocation strategy is solved, and more efficient and reliable data transmission is achieved.

CN119473653APending Publication Date: 2025-02-18NIO TECH ANHUI CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411527822.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-29
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

Most of the data transmission methods through shared memory in autonomous driving systems adopt centralized shared memory allocation strategies, resulting in poor system robustness.

Method used

By starting multiple processes simultaneously opening the shared memory corresponding to each Topic, and one process configures and manages each shared memory, ensuring that the shared memory of each Topic is managed by one process.

Benefits of technology

It improves the robustness of the system, avoids system crashes caused by central node failure, and improves the efficiency and reliability of data transmission under high concurrency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473653A_ABST
    Figure CN119473653A_ABST
Patent Text Reader

Abstract

The invention is suitable for the technical field of automatic driving communication, and provides a data transmission method and device, terminal equipment and a storage medium, and the method comprises the steps: starting a plurality of processes, opening a shared memory corresponding to each first Topic at the same time, and configuring the shared memory corresponding to each first Topic through a first process, the first process is a process of successfully opening the shared memory corresponding to each first Topic, then writing data of the first Topic in the shared memory corresponding to each configured first Topic through the first process, and finally notifying the plurality of second processes to read the data from the shared memory corresponding to the configured first Topic through the first process. The second process is other processes except the first process in the plurality of processes. The shared memory corresponding to each Topic is opened through competition of a plurality of processes, it is ensured that the shared memory of each Topic is managed by one process, and therefore the robustness of the system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of autonomous driving communication technology, and in particular, relates to a data transmission method, apparatus, terminal device and storage medium. Background Art

[0002] At present, shared memory data transmission is commonly used in the communication middleware domain of autonomous driving systems. At the same time, most shared memory data transmission methods adopt a centralized shared memory allocation strategy, which leads to poor system robustness. Summary of the invention

[0003] The embodiments of the present application provide a data transmission method, apparatus, terminal device and storage medium, which can solve the problem that the current data transmission method through shared memory in autonomous driving systems mostly adopts a centralized shared memory allocation strategy, resulting in poor system robustness.

[0004] In a first aspect, an embodiment of the present application provides a data transmission method, including: starting multiple processes to simultaneously open the shared memory corresponding to each first Topic; configuring the shared memory corresponding to each first Topic through a first process, the first process being the process that successfully opens the shared memory corresponding to each first Topic; writing the data of the first Topic into the configured shared memory corresponding to each first Topic through the first process; notifying multiple second processes to read data from the configured shared memory corresponding to the first Topic through the first process, the second processes being the other processes among the multiple processes except the first process.

[0005] In a possible implementation manner of the first aspect, configuring the shared memory corresponding to each first topic through the first process includes:

[0006] When the first process successfully obtains the file lock of the shared memory corresponding to each first Topic, the shared memory corresponding to each first Topic is mapped to the virtual address space of the first process to create a first shared memory;

[0007] An initialization operation is performed on the first shared memory to complete an initialization operation on the shared memory corresponding to each first Topic.

[0008] Optionally, in another possible implementation manner of the first aspect, the initializing operation on the first shared memory to complete the initialization operation on the shared memory corresponding to each first Topic includes:

[0009] Write the header data of the shared memory corresponding to each first Topic into the first shared memory;

[0010] According to the header data of the shared memory corresponding to each first Topic, each data structure in each first Topic is allocated in the first shared memory, and the header data of the shared memory corresponding to the first Topic includes the offset of each data structure in the first Topic.

[0011] Optionally, in another possible implementation manner of the first aspect, after configuring the shared memory corresponding to each first Topic through the first process, the method further includes:

[0012] Mapping the shared memory corresponding to any first Topic to the virtual address space of the second process through the second process to create a second shared memory;

[0013] Obtaining header data of the shared memory corresponding to any first Topic from the second shared memory through the second process;

[0014] The header data of the shared memory corresponding to any first Topic is read by the second process, so that a communication connection is established between the second process and the first process.

[0015] Optionally, in another possible implementation of the first aspect, before mapping the shared memory corresponding to any first Topic to the virtual address space of the second process by the second process to create the second shared memory, the method further includes:

[0016] When any second process successfully opens the shared memory corresponding to any first Topic in read-only mode, determining whether any second process obtains the file lock of the shared memory corresponding to any first Topic;

[0017] Mapping any shared memory corresponding to the first topic to the virtual address space of the second process through the second process to create a second shared memory includes:

[0018] When any second process can obtain the file lock of the shared memory corresponding to any first Topic, the shared memory corresponding to any first Topic is mapped to the virtual address space of the second process through the second process to create a second shared memory.

[0019] Optionally, in another possible implementation manner of the first aspect, the reading, by the second process, header data of a shared memory corresponding to any first Topic so as to establish a communication connection between the second process and the first process includes:

[0020] Determine, according to the initialization flag bit in the header data of the shared memory corresponding to the first Topic, whether the shared memory corresponding to the first Topic has completed the initialization operation;

[0021] Determine the consistency of the second memory and the first memory according to the offset of each data structure in the first Topic;

[0022] According to the offset of each data structure in the first topic, the virtual address of each data structure in the first topic in the second shared memory is calculated.

[0023] Optionally, in another possible implementation manner of the first aspect, the data type of the data of the first Topic is set to a POD type, and the data of the first Topic is set to a C++ structure.

[0024] Optionally, in another possible implementation manner of the first aspect, the data of the first Topic is stored in a preset custom container.

[0025] Optionally, in another possible implementation manner of the first aspect, writing the data of the first topic into the shared memory corresponding to each configured first topic through the first process includes:

[0026] Get the SmartMemory associated with the shared memory corresponding to the first configured Topic;

[0027] Write the data of the first topic into the shared memory corresponding to the configured first topic through SmartMemory;

[0028] Accordingly, the first process notifies the plurality of second processes to read data from the shared memory corresponding to the configured first Topic, including:

[0029] An update signal is sent to the plurality of second processes, where the update signal is used to indicate that data in the shared memory corresponding to the first Topic is updated.

[0030] In the second aspect, an embodiment of the present application provides a data transmission device, including: an opening module, used to start multiple processes to simultaneously open the shared memory corresponding to each first Topic; a configuration module, used to configure the shared memory corresponding to each first Topic through a first process, the first process being the process that successfully opens the shared memory corresponding to each first Topic; a writing module, used to write the data of the first Topic in the shared memory corresponding to each configured first Topic through the first process; a notification module, used to notify multiple second processes through the first process to read data from the configured shared memory corresponding to the first Topic, the second process being the other processes among the multiple processes except the first process.

[0031] In a possible implementation manner of the second aspect, the configuration module includes:

[0032] A first mapping unit is used to map the shared memory corresponding to each first Topic to the virtual address space of the first process to create a first shared memory when the first process successfully obtains the file lock of the shared memory corresponding to each first Topic;

[0033] The initialization unit is used to perform an initialization operation on the first shared memory to complete the initialization operation on the shared memory corresponding to each first Topic.

[0034] Optionally, in a possible implementation manner of the second aspect, the initialization unit is specifically used to:

[0035] Write the header data of the shared memory corresponding to each first Topic into the first shared memory;

[0036] According to the header data of the shared memory corresponding to each first Topic, each data structure in each first Topic is allocated in the first shared memory, and the header data of the shared memory corresponding to the first Topic includes the offset of each data structure in the first Topic.

[0037] Optionally, in another possible implementation manner of the second aspect, the apparatus further includes:

[0038] A mapping module, used for mapping the shared memory corresponding to any first Topic to the virtual address space of the second process through the second process to create a second shared memory;

[0039] An acquisition module, used for acquiring header data of a shared memory corresponding to any first Topic from a second shared memory through a second process;

[0040] The reading module is used to read the header data of the shared memory corresponding to any first Topic through the second process, so as to establish a communication connection between the second process and the first process.

[0041] Optionally, in another possible implementation manner of the second aspect, the apparatus further includes:

[0042] In the case where any second process successfully opens the shared memory corresponding to any first Topic in read-only mode, a judgment module is used to judge whether any second process obtains the file lock of the shared memory corresponding to any first Topic;

[0043] The above mapping module includes:

[0044] In the case where any second process can obtain the file lock of the shared memory corresponding to any first Topic, the second mapping unit is used to map the shared memory corresponding to any first Topic to the virtual address space of the second process through the second process to create a second shared memory.

[0045] Optionally, in another possible implementation of the second aspect, the reading module includes:

[0046] A first determining unit, configured to determine, according to an initialization flag bit in header data of the shared memory corresponding to the first Topic, whether the shared memory corresponding to the first Topic has completed the initialization operation;

[0047] A second determining unit, configured to determine the consistency between the second memory and the first memory according to the offset of each data structure in the first Topic;

[0048] The calculation unit is used to calculate the virtual address of each data structure in the first topic in the second shared memory according to the offset of each data structure in the first topic.

[0049] Optionally, in another possible implementation manner of the second aspect, the data type of the data of the first Topic is set to a POD type, and the data of the first Topic is set to a C++ structure.

[0050] Optionally, in another possible implementation manner of the second aspect, the data of the first Topic is stored in a preset custom container.

[0051] Optionally, in another possible implementation of the second aspect, the writing module includes:

[0052] An acquisition unit, used to acquire a SmartMemory associated with a shared memory corresponding to a configured first Topic;

[0053] A writing unit, used to write the data of the first Topic into the shared memory corresponding to the configured first Topic through SmartMemory;

[0054] Correspondingly, the notification module includes:

[0055] The sending unit is used to send an update signal to the plurality of second processes, wherein the update signal is used to indicate that data in the shared memory corresponding to the first Topic is updated.

[0056] In a third aspect, an embodiment of the present application provides a terminal device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the aforementioned data transmission method when executing the computer program.

[0057] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the data transmission method as described above is implemented.

[0058] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the method for generating a planned path as described above.

[0059] In the technical solution of the present application, multiple processes are first started to simultaneously open the shared memory corresponding to each first Topic, and then the shared memory corresponding to each first Topic is configured through the first process. The first process is the process that successfully opens the shared memory corresponding to each first Topic. Then, the first process writes the data of the first Topic into the shared memory corresponding to each configured first Topic, and finally, the first process notifies multiple second processes to read data from the shared memory corresponding to the configured first Topic. The second process is the other process among the multiple processes except the first process. By having multiple processes compete to open the shared memory corresponding to each Topic, it is ensured that the shared memory of each Topic is managed by one process, thereby improving the robustness of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0061] Figure 1 It is a flowchart of a data transmission method provided by an embodiment of the present application;

[0062] Figure 2 is a flowchart of a data transmission method provided by another embodiment of the present application;

[0063] Figure 3 It is a flowchart of a data transmission method provided in yet another embodiment of the present application;

[0064] Figure 4 is a flowchart of a data transmission method provided by another embodiment of the present application;

[0065] Figure 5 It is a flowchart of a method for generating a shared memory provided in an embodiment of the present application;

[0066] Figure 6It is a flowchart of a data transmission device provided by an embodiment of the present application;

[0067] Figure 7 It is a structural diagram of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0068] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0069] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0070] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0071] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.

[0072] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0073] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0074] In the field of autonomous driving communication middleware, shared memory communication has been widely used. Shared memory is an efficient data transmission method that eliminates the overhead of data copying by sharing a memory area between multiple processes, greatly improving the efficiency of data transmission. This is especially important for autonomous driving systems that need to process large amounts of data in real time. For example, autonomous vehicles need to obtain a large amount of data from sensors (such as lidar, cameras, and radars), which must be quickly transmitted and processed between multiple processing modules, making shared memory communication an ideal choice.

[0075] Currently, most autonomous driving communication middleware adopts a centralized shared memory allocation strategy. In this strategy, a central node (usually a Publisher) is responsible for creating and managing shared memory, and other processes (Subscribers) exchange data through the central node. For example, Baidu cyberRT is a typical autonomous driving middleware architecture that relies on a central node to manage shared memory and schedule data flows. This approach simplifies the management and allocation of shared memory because all resource allocation and management are concentrated on one node, making the system architecture design and implementation relatively simple.

[0076] However, the centralized shared memory allocation strategy also has significant disadvantages. First, it is highly dependent on the reliability of the central node. If the central node fails, the communication of the entire system will be affected, and even cause the system to crash. In the actual application of autonomous driving, this situation is unacceptable because any interruption in communication may have a serious impact on the safe operation of the vehicle. For example, if the central node fails when processing data from lidar and cameras, the vehicle may not be able to obtain the necessary environmental information in time, resulting in delayed or incorrect decision-making.

[0077] Secondly, as the scale of the system expands, the load on the central node will increase significantly, becoming a performance bottleneck. Autonomous driving systems usually need to process and transmit large amounts of data, and the central node may face problems such as insufficient resources and processing delays when processing this data. This will not only reduce the real-time performance of the system, but may also cause data loss or delays, affecting the overall performance of the system. For example, in the case of high concurrency, the central node may not be able to process data from multiple sensors in a timely manner, thus affecting the timeliness and accuracy of the data.

[0078] In summary, although the centralized shared memory allocation strategy has been widely used in autonomous driving communication middleware, its inherent defects have promoted the development of semi-centralized strategies. By decentralizing resource management and improving the robustness of the system, the semi-centralized shared memory allocation strategy provides a more flexible and reliable communication solution for autonomous driving systems.

[0079] The data transmission method, apparatus, terminal device and storage medium provided in the present application are described in detail below with reference to the accompanying drawings.

[0080] Figure 1 A flow chart of a data transmission method provided by an embodiment of the present application is shown.

[0081] like Figure 1 As shown, the data transmission method comprises the following steps:

[0082] Step 101: Start multiple processes to simultaneously open the shared memory corresponding to each first Topic, and determine the process that successfully opens the shared memory corresponding to the first Topic as the first process.

[0083] The first process may refer to a central node of a shared memory corresponding to the first Topic, which is responsible for the management of the shared memory (writing data of the first Topic and transmitting the data of the first Topic, etc.).

[0084] It should be noted that the system includes multiple first topic data, for example, in the automatic driving system, including vehicle speed data, direction data, outside temperature data, tire pressure data, etc., and each first topic data will be allocated a section of shared memory in advance. For each of the above categories of data, when the above data needs to be transmitted, multiple processes can be started to open the shared memory corresponding to each category of data at the same time, and the process that successfully opens the shared memory corresponding to each category of data is determined as the first process.

[0085] In one embodiment, because multiple processes simultaneously open the shared memory corresponding to each first Topic, and there can only be one first process that is successfully opened, when multiple processes simultaneously open the shared memory, as an example, each process can call the posixshm_open interface to open the shared memory corresponding to the first Topic of each process, and the interface parameter oflag of the posixshm_open interface needs to be set to O_CREAT and O_EXCL at the same time, wherein O_CREAT is used to indicate the current process, and if the shared memory corresponding to the first Topic is not opened by any other process, the current process is made to open the shared memory corresponding to the first Topic, and O_EXCL is used to if the current process attempts to open the shared memory corresponding to the first Topic, and finds that the shared memory corresponding to the first Topic has been opened by other processes, then the function call fails and returns an error message. Thus, when multiple processes simultaneously attempt to open the shared memory corresponding to the first Topic, only one process can successfully complete the operation, and the other processes will receive an error return value, indicating that the shared memory corresponding to the first Topic already exists. This mechanism ensures the uniqueness of the shared memory when it is opened, thereby avoiding the conflict of multiple processes opening the same shared memory at the same time.

[0086] In the embodiment of the present application, multiple processes can be started to open the shared memory corresponding to each first Topic at the same time, and the process that successfully opens the shared memory corresponding to the first Topic is determined as the first process, and each first Topic has its own shared memory. This method ensures the isolation and independence of data, so that the data transmission and management of each Topic do not interfere with each other.

[0087] Step 102: configure a shared memory corresponding to the first Topic through the first process.

[0088] It should be noted that after determining the first process, by configuring the shared memory corresponding to the first Topic, it is ensured that the data structure in the shared memory is configured correctly and the shared memory is in a known and correct state before data transmission, so as to prepare for subsequent data transmission.

[0089] Step 103: Write the data of the first Topic into the shared memory corresponding to the first Topic through the first process, and notify multiple second processes.

[0090] The second process may refer to other processes among the multiple processes except the first process, that is, the process that fails to successfully open the shared memory corresponding to the first Topic.

[0091] It should be noted that after the first process completes the configuration of the shared memory corresponding to the first Topic, the first process can perform data transmission through the shared memory corresponding to the first Topic. The data to be transmitted (for example, the data of the first Topic of the first process) is written into the shared memory corresponding to the first Topic, and the other multiple second processes are notified so that the multiple second processes obtain the data of the first Topic from the shared memory corresponding to the first Topic, thereby completing the data transmission process.

[0092] In a possible scenario of the present application, because each first Topic has opened its own shared memory through its own first process, when the first process associated with a first Topic crashes, it will not affect other first Topics in the system to perform shared memory communication according to their own first processes. For example, there are three Topics in the autonomous driving system: temperature data, speed data, and position data. Each Topic has a corresponding first process to open and manage its shared memory. Assuming that the first process corresponding to the temperature data suddenly crashes, only the transmission of the temperature data will be affected. The other two Topics: speed data and position data will not be affected because they have their own independent first processes and shared memories.

[0093] In another possible scenario of the present application, if the process associated with a first topic crashes in one of the multiple second processes, it will not affect the shared memory communication between the first process and other second processes. For example, there is a Topic of temperature data in the autonomous driving system. The temperature data is published by the first process, and three second processes subscribe to it, namely the second process A, the second process B and the second process C. At this time, if the second process B suddenly crashes, it will not affect the first process writing the temperature data into the shared memory of the temperature data, nor will it affect the second process A and the second process C obtaining the temperature data from the shared memory.

[0094] The present application provides a data transmission method, which first starts multiple processes to simultaneously open the shared memory corresponding to each first Topic, determines the process that successfully opens the shared memory corresponding to the first Topic as the first process, then configures the shared memory corresponding to the first Topic through the first process, and finally writes the data of the first Topic into the shared memory corresponding to the first Topic through the first process, and notifies multiple second processes. By having multiple processes compete to open the shared memory corresponding to each Topic, it is ensured that the shared memory of each Topic is managed by one process, thereby improving the robustness of the system.

[0095] Figure 2 A flow chart of a data transmission method provided in another embodiment of the present application is shown.

[0096] like Figure 2 As shown, the data transmission method comprises the following steps:

[0097] Step 201 , start multiple processes to simultaneously open the shared memory corresponding to each first Topic, and determine the process that successfully opens the shared memory corresponding to the first Topic as the first process.

[0098] The specific implementation process and principle of the above step 201 can refer to the detailed description of the above embodiment, which will not be repeated here.

[0099] Step 202: Acquire and open the file lock of the shared memory corresponding to the first Topic through the first process.

[0100] Among them, file locks can refer to ensuring the synchronization and consistency of multiple processes when accessing shared memory, preventing data competition and inconsistency problems. For example, suppose there are two processes, process A and process B, both of which need to access the same shared memory to read and write data. In the absence of file locks, process A starts writing to the shared memory. During the process of process A writing, process B also starts writing to the shared memory. Since there is no file lock, process A and process B may modify the same memory at the same time, resulting in data confusion or inconsistency. However, in the case of file locks, process A attempts to write to the shared memory, but first checks whether the file lock is available. If the file lock is not occupied, process A obtains the file lock and starts writing to the shared memory. While process A holds the file lock, process B attempts to write to the shared memory, but because the file lock is occupied, process B must wait. After process A completes writing, it releases the file lock, and process B obtains the file lock and starts writing to the shared memory. In this way, process A and process B will not modify the shared memory at the same time, ensuring data consistency.

[0101] In the embodiment of the present application, the file lock of the shared memory corresponding to the first Topic is obtained and opened by the first process, thereby ensuring that the first process is the only process currently accessing the shared memory corresponding to the first Topic.

[0102] Step 203: Map the shared memory corresponding to the first Topic to the virtual address space of the first process through the first process to obtain the first shared memory.

[0103] The virtual address space of the first process may refer to a memory address range used when the first process is running, and these addresses are virtual.

[0104] The first shared memory may refer to a virtual memory address obtained after the first process maps the shared memory corresponding to the first Topic into its own virtual address space, and may be represented as a continuous memory area.

[0105] It should be noted that the shared memory corresponding to the first Topic is mapped to the virtual address space of the first process. The above mapping process actually allocates an address range (the first shared memory) in the virtual address space of the first process. The first process can directly access the shared memory corresponding to the first Topic through the first shared memory.

[0106] In an embodiment of the present application, the shared memory corresponding to the first Topic is mapped to the virtual address space of the first process through the first process to obtain the first shared memory, so that the shared memory corresponding to the first Topic can be accessed according to the first shared memory.

[0107] Step 204: Initialize the first shared memory through the first process, and release the file lock of the shared memory corresponding to the first Topic after the initialization operation.

[0108] It should be noted that, because the first shared memory is generated by mapping the shared memory corresponding to the first Topic to the virtual address space of the first process, the initialization operation of the first shared memory is performed by the first process, and the initialization operation of the shared memory corresponding to the first Topic can also be implemented. By initializing the first shared memory by the first process, the correctness and consistency of the structure of the shared memory corresponding to the first Topic can be ensured, so that other processes can correctly access and use the data in the shared memory corresponding to the first Topic.

[0109] In addition, in an embodiment of the present application, after the first shared memory is initialized, the file lock of the shared memory corresponding to the first Topic is released. Due to the file lock mechanism, when the first process performs the initialization operation on the first shared memory, other processes are prohibited from accessing the shared memory corresponding to the first Topic. After the initialization operation is completed, the file lock of the shared memory corresponding to the first Topic is released, so that other processes can access and use the data in the shared memory corresponding to the first Topic and perform normal read and write operations.

[0110] In an embodiment of the present application, the first shared memory is initialized by the first process, and the file lock of the shared memory corresponding to the first Topic is released after the initialization operation. Thus, the first shared memory is initialized to ensure data structure consistency and avoid data errors. The file lock is released after the initialization operation, which can improve the system concurrency performance and prevent deadlock, so that other processes can smoothly access the shared memory.

[0111] Furthermore, in a possible implementation of the embodiment of the present application, the above step 204 may include:

[0112] Writing the header data of the shared memory corresponding to the first Topic into the first shared memory through the first process;

[0113] Each data structure in the first Topic is allocated in the first shared memory through the first process according to the header data of the shared memory corresponding to the first Topic.

[0114] Among them, the header data of the shared memory corresponding to the first Topic may refer to metadata about the shared memory corresponding to the first Topic, and the above metadata includes the total size of the shared memory corresponding to the first Topic, the size of the header data itself, the offset of the data area, and the offset of other data structures.

[0115] It should be noted that, because the first shared memory is obtained by mapping the shared memory corresponding to the first Topic in the virtual address space of the first process, the header data of the shared memory corresponding to the first Topic is written into the first shared memory, which also means that the header data of the shared memory corresponding to the first Topic is written into the shared memory corresponding to the first Topic, and the operation is only performed through the first shared memory.

[0116] Similarly, the first process allocates each data structure in the first Topic in the first shared memory according to the header data of the shared memory corresponding to the first Topic, and the allocation of each data structure in the shared memory corresponding to the first Topic is also achieved by operating in the first shared memory.

[0117] For example, the first Topic includes three data structures, namely tire temperature data, outside environment temperature data and motor temperature data. The header data of the shared memory corresponding to the first Topic includes the offset and size information of the tire temperature data, the offset and size information of the outside environment temperature data and the offset and size information of the motor temperature data. Then, according to the offset and size information of each data structure in the header data, each data structure is allocated on the first shared memory, thereby realizing the allocation of each data structure in the shared memory corresponding to the first Topic. It should be understood that the above embodiment is only exemplary and the present application does not limit this.

[0118] In an embodiment of the present application, the header data of the shared memory corresponding to the first Topic is written into the first shared memory by the first process, and then each data structure in the first Topic is allocated in the first shared memory according to the header data of the shared memory corresponding to the first Topic by the first process. Thus, by performing the initialization operation on the first shared memory, the initialization operation of the shared memory corresponding to the first Topic is realized, and by performing the initialization operation on the first shared memory, the consistency of the data structure in the shared memory corresponding to the first Topic can be ensured to avoid data errors.

[0119] Step 205: Write the data of the first Topic into the shared memory corresponding to the first Topic through the first process, and notify multiple second processes.

[0120] The specific implementation process and principle of the above step 205 can refer to the detailed description of the above embodiment, which will not be repeated here.

[0121] The data transmission method provided by the present application first starts multiple processes to simultaneously open the shared memory corresponding to each first Topic, determines the process that successfully opens the shared memory corresponding to the first Topic as the first process, then obtains and opens the file lock of the shared memory corresponding to the first Topic through the first process, and then maps the shared memory corresponding to the first Topic to the virtual address space of the first process through the first process to obtain the first shared memory, then initializes the first shared memory through the first process, and releases the file lock of the shared memory corresponding to the first Topic after the initialization operation, and finally writes the data of the first Topic into the shared memory corresponding to the first Topic through the first process, and notifies multiple second processes. Thus, the first shared memory is initialized by the first process, thereby realizing the initialization operation of the shared memory corresponding to the first Topic, so as to ensure the consistency of the data structure in the shared memory corresponding to the first Topic, avoid data errors, and thus improve the robustness of the system.

[0122] Figure 3 A flow chart of a data transmission method provided in yet another embodiment of the present application is shown.

[0123] like Figure 3 As shown, the data transmission method comprises the following steps:

[0124] Step 301 , start multiple processes to simultaneously open the shared memory corresponding to each first Topic, and determine the process that successfully opens the shared memory corresponding to the first Topic as the first process.

[0125] Step 302: configure a shared memory corresponding to the first Topic through the first process.

[0126] The specific implementation process and principle of the above steps 301-302 can refer to the detailed description of the above embodiment, which will not be repeated here.

[0127] Step 303: When multiple second processes open the shared memory corresponding to the first Topic in read-only mode, call the second process to obtain and open the file lock of the shared memory corresponding to the first Topic.

[0128] As a possible implementation manner, the second process may call the posixshm_open interface to open the shared memory corresponding to the first Topic in a read-only manner.

[0129] It should be noted that when the second process opens the shared memory corresponding to the first Topic in read-only mode, it is also necessary to call the second process to obtain and open the file lock of the shared memory corresponding to the first Topic, so as to ensure that the second process is the only process currently accessing the shared memory corresponding to the first Topic.

[0130] In an embodiment of the present application, when multiple second processes open the shared memory corresponding to the first Topic in read-only mode, the second process is called to obtain and open the file lock of the shared memory corresponding to the first Topic, thereby ensuring that in the process of reading the shared memory corresponding to the first Topic, the first process will not perform write operations at the same time, thereby avoiding read-write conflicts. In addition, when the second process reads the shared memory corresponding to the first Topic, it is ensured that the data therein will not be modified in the middle, thereby ensuring that the data read by the second process is in a complete and stable state. Finally, it can also ensure that multiple second processes will not read the shared memory corresponding to the first Topic at the same time, thereby avoiding competition conditions.

[0131] Step 304: Map the shared memory corresponding to the first Topic to the virtual address space of the second process through the second process to obtain the second shared memory.

[0132] The virtual address space of the second process may refer to a memory address range used when the second process is running, and these addresses are virtual.

[0133] The second shared memory may refer to a virtual memory address obtained after the second process maps the shared memory corresponding to the first Topic into its own virtual address space, and may be represented as a continuous memory area.

[0134] It should be noted that the shared memory corresponding to the first Topic is mapped to the virtual address space of the second process. The above mapping process actually allocates an address range (the second shared memory) in the virtual address space of the second process. The second process can directly access the shared memory corresponding to the first Topic through the second shared memory.

[0135] In an embodiment of the present application, the shared memory corresponding to the first Topic is mapped to the virtual address space of the second process through the second process to obtain the second shared memory, so that the shared memory corresponding to the first Topic can be accessed according to the second shared memory.

[0136] Step 305: Obtain header data of the shared memory corresponding to the first Topic from the second shared memory through the second process.

[0137] It should be noted that, because the second shared memory is obtained by mapping the shared memory corresponding to the first Topic in the virtual address space of the second process, the header data of the shared memory corresponding to the first Topic can be directly obtained from the second shared memory.

[0138] Step 306: Read the header data of the shared memory corresponding to the first Topic through the second process to ensure that a communication connection is established between the second process and the first process, and release the file lock of the shared memory corresponding to the first Topic after the communication connection is established.

[0139] It should be noted that by reading the header data of the shared memory corresponding to the first Topic through the second process, the consistency and synchronization between the shared memory corresponding to the first Topic read by the second process and the shared memory corresponding to the first Topic initialized by the first process can be ensured based on the information in the header data. After establishing a communication connection with the first process, the second process releases the file lock of the shared memory corresponding to the first Topic, so that other second processes acquire and open the file lock, and establish a communication connection with the first process, ensuring the consistency and synchronization between the shared memory read by other second processes and the shared memory corresponding to the first Topic initialized by the first process.

[0140] In the embodiment of the present application, the header data of the shared memory corresponding to the first Topic is read by the second process to ensure that a communication connection is established between the second process and the first process, and the file lock of the shared memory corresponding to the first Topic is released after the communication connection is established. Thus, after ensuring that a communication connection is established between the second process and the first process, preparations can be made for subsequent data transmission through the shared memory.

[0141] The establishment of a communication connection between the second process and the first process in the above embodiment will be further described below.

[0142] Furthermore, in a possible implementation of the embodiment of the present application, the above step 306 may include:

[0143] The second process determines that the shared memory corresponding to the first Topic has completed the initialization operation according to the initialization flag bit in the header data of the shared memory corresponding to the first Topic;

[0144] The second process determines the consistency of the second memory and the first memory according to the offset of each data structure in the first Topic;

[0145] The second process calculates the virtual address of each data structure in the first topic in the second shared memory according to the offset of each data structure in the first topic.

[0146] The initialization flag may refer to a specific field in the header data of the shared memory corresponding to the first Topic, which is used to indicate whether the shared memory has been correctly initialized.

[0147] In one embodiment, after the shared memory corresponding to the first Topic completes the initialization operation, the first process may set the is_initialized flag in the header data of the shared memory corresponding to the first Topic to true, indicating that the shared memory has been initialized.

[0148] It should be noted that in order to determine the consistency between the second memory and the first memory, the second process obtains the offset of each data structure in the first Topic from the second shared memory, and checks the offset of each data structure in the second shared memory. When the offset of each data structure in the second shared memory is the same as the offset of each data structure in the first Topic, the consistency between the second memory and the first memory is determined.

[0149] In one embodiment, there is a first Topic in the autonomous driving system, including three data structures: a temperature data structure, a humidity data structure and a status data structure. The header data of the shared memory corresponding to the first Topic includes the offset of each of the above data structures: the offset of the temperature data structure is 0, the offset of the humidity data structure is 4, and the offset of the status data structure is 12. After the second process reads the offset of each data structure in the first Topic, the address of each data structure in the second shared memory is calculated, wherein the initial address of the second shared memory is 0×20000000, then the virtual address of the temperature data structure is: 0×20000000+0=0×20000000; the virtual address of the humidity data structure is: 0×20000000+4=0×20000004; the virtual address of the status data structure is: 0×20000000+12=0×2000000C.

[0150] In an embodiment of the present application, the second process determines that the shared memory corresponding to the first Topic has completed the initialization operation based on the initialization flag in the header data of the shared memory corresponding to the first Topic, so that the first process and the second process can effectively synchronize the usage status of the shared memory corresponding to the first Topic, ensuring the correctness and consistency of data transmission; the second process determines the consistency between the second memory and the first memory based on the offset of each data structure in the first Topic, thereby ensuring that the second process can correctly access the data in the shared memory corresponding to the first Topic after the first process is initialized; the second process calculates the virtual address of each data structure in the first Topic in the second shared memory based on the offset of each data structure in the first Topic, thereby, the second process can ensure that the positions of each data structure in the shared memory corresponding to the first Topic accessed through the second shared memory are consistent with the positions of each data structure in the shared memory corresponding to the first Topic after the first process is initialized, thereby avoiding the problem of data format mismatch or memory access error.

[0151] To summarize, the embodiment of the present application ensures that a communication connection is established between the second process and the first process by determining that the shared memory corresponding to the first Topic completes the initialization operation, determining the consistency of the second memory and the first memory, and calculating the virtual address of each data structure in the first Topic in the second shared memory.

[0152] Step 307: Write the data of the first Topic into the shared memory corresponding to the first Topic through the first process, and notify multiple second processes.

[0153] The specific implementation process and principle of the above step 307 can be referred to the detailed description of the above embodiment, which will not be repeated here.

[0154] The data transmission method provided by the present application first starts multiple processes to simultaneously open the shared memory corresponding to each first Topic, determines the process that successfully opens the shared memory corresponding to the first Topic as the first process, configures the shared memory corresponding to the first Topic through the first process, and when multiple second processes open the shared memory corresponding to the first Topic in read-only mode, calls the second process to obtain and open the file lock of the shared memory corresponding to the first Topic, and then maps the shared memory corresponding to the first Topic to the virtual address space of the second process through the second process to obtain the second shared memory, and then obtains the header data of the shared memory corresponding to the first Topic from the second shared memory through the second process, and then reads the header data of the shared memory corresponding to the first Topic through the second process, ensures that a communication connection is established between the second process and the first process, and releases the file lock of the shared memory corresponding to the first Topic after the communication connection is established, and finally writes the data of the first Topic into the shared memory corresponding to the first Topic through the first process, and notifies multiple second processes. Thus, by establishing a communication connection between the second process and the first process, the accuracy of subsequent data transmission through the shared memory corresponding to the first Topic is ensured, thereby improving the robustness of the system.

[0155] Figure 4 A flow chart of a data transmission method provided by another embodiment of the present application is shown.

[0156] like Figure 4 As shown, the data transmission method comprises the following steps:

[0157] Step 401: Start multiple processes to simultaneously open the shared memory corresponding to each first Topic, and determine the process that successfully opens the shared memory corresponding to the first Topic as the first process.

[0158] Step 402: configure a shared memory corresponding to the first Topic through the first process.

[0159] The specific implementation process and principle of the above steps 401-402 can refer to the detailed description of the above embodiment, which will not be repeated here.

[0160] Step 403: request the shared memory corresponding to the first Topic through the first process and obtain the SmartMemory associated with the shared memory corresponding to the first Topic.

[0161] Among them, SmartMemory may refer to a lightweight smart pointer that can be associated with a certain shared memory to be communicated, wherein the shared memory stores the message data to be transmitted. The design purpose of SmartMemory is to simplify the read and write operations of the shared memory, so that users can access the data in the shared memory as easily as using a normal pointer.

[0162] In the embodiment of the present application, because the data of the first Topic needs to be transmitted, it is necessary to first request the shared memory corresponding to the first Topic. When the request is successful, a SmartMemory associated with the shared memory corresponding to the first Topic is returned.

[0163] Step 404: Write the data of the first Topic into the shared memory corresponding to the first Topic according to SmartMemory through the first process.

[0164] It should be noted that the data of the first Topic is set as a C++ structure, which can be used to define and store the data to be transmitted. In one embodiment, the above C++ structure can be described by the following code:

[0165] struct Student{

[0166] int age;

[0167] int height;

[0168] std::vector <phone>phones;

[0169] };

[0170] struct Phone{

[0171] Phone(Type_type,std::string&&_number){

[0172] type = _type;

[0173] number = _number;

[0174] }

[0175] Type type;

[0176] std::string number;

[0177] };

[0178] enum Type{

[0179] HOME,

[0180] OFFICE

[0181] };

[0182] 2) The publisher applies for a section of memory and assigns the message to this section of memory:

[0183] void*ptr=getSharedMemory(); / / apply for a free memory

[0184] Student*student=reinterpret_cast<Student*> (ptr);

[0185] / / Production data

[0186] student->age=20;

[0187] student->height=175;

[0188] student->phones.emplace_back(Home,"1234");

[0189] student->phones.emplace_back(OFFICE,"4321");

[0190] 3) The subscriber obtains the data from this memory address:

[0191] void*ptr=getSharedMemory(); / / Get the shared memory filled with data by publisher in 2)

[0192] Student*student=reinterpret_cast<Student*> (ptr);

[0193] / / Consumption data

[0194] std::cout< <student->age<<std::endl;

[0195] std::cout< <student->height< <std::endl;

[0196] for(const auto&phone:student->phones){

[0197] std::cout< <phone.type<<std::endl;

[0198] std::cout< <phone.number<<std::endl;

[0199] }

[0200] The above code shows the process of data communication through shared memory. In this embodiment, the publisher applies for a section of memory in the shared memory and fills the data into a Student structure instance, including basic data types (such as age and height) and complex data types (such as phones). Then, the subscriber obtains this section of shared memory, reads and processes the data in it. In this way, publishers and subscribers can efficiently share complex data structures without serializing and deserializing the data.

[0201] In addition, shared memory data transmission needs to ensure that data can be passed between processes through simple byte copies. Some data types (such as structures containing pointers) cannot be directly passed between processes through byte copies because the virtual address spaces of different processes are different. Therefore, the data type of the first Topic's data is set to the POD type. The C++ standard defines three data types: POD, Trival, and Standard-layout. The POD type can provide the same ease of use, clear memory layout, and consistent performance as the built-in basic data. The Trival data type can use memcpy for byte copy assignment, can be copied into a character array, and can simply restore the data based on the character data. The Standard-layout data type can be cross-language because of its standard memory layout. If an object is both a trivial type and a standard layout type, then the object is a POD type.

[0202] It should be noted that the data of the first topic is stored in the preset custom containers, which include the custom Vector class container and the custom String class container. The container types of std::vector and std::string will dynamically allocate memory at runtime, which makes them unsuitable for passing as POD types in shared memory, because the data in shared memory needs to be continuous and fixed in size.

[0203] Therefore, the preset custom container can only store POD type data, ensuring that the data can be simply copied and assigned. At the same time, the container uses a fixed-size byte array to store data to avoid dynamic memory allocation. When used, the data in the byte array is serialized into a POD type object, and the byte array is deserialized back to a POD type object when received. In addition, the preset custom container is compatible with the standard library container (such as std::vector and std::string) interface.

[0204] Step 405: Sending a shared memory update signal corresponding to the first Topic to multiple second processes through the first process.

[0205] As a possible implementation, after the first process sends the update signal of the shared memory corresponding to the first Topic to multiple second processes, the second processes can obtain the data of the first Topic according to SmartMemory.

[0206] In one embodiment, after the first process writes data into the shared memory through SmartMemory, the process in which the second process receives data through SmartMemory can be described by the following code:

[0207] / / Communication data structure

[0208] struct Data

[0209] {

[0210] double x=0.0;

[0211] double y=0.0;

[0212] double z=0.0;

[0213] };

[0214] / / publisher

[0215] auto result = publisher.get(); / / Get shared memory

[0216] if(result)

[0217] {

[0218] SmartMemory&memory=result.value();

[0219] memory->x = ct;

[0220] memory->y=ct;

[0221] memory->z=ct;

[0222] memory.publish();

[0223] }

[0224] / / subscriber

[0225] auto takeResult = subscriber.take(); / / Get the shared memory with new data published

[0226] if(takeResult)

[0227] {

[0228] SmartMemory&memory=takeResult.value();

[0229] std::cout< <APP_NAME<<"got value:"< <memory->x< <std::endl;

[0230] }

[0231] The data transmission method provided by the present application first starts multiple processes to simultaneously open the shared memory corresponding to each first Topic, determines the process that successfully opens the shared memory corresponding to the first Topic as the first process, then configures the shared memory corresponding to the first Topic through the first process, then requests the shared memory corresponding to the first Topic through the first process and obtains the SmartMemory associated with the shared memory corresponding to the first Topic, then writes the data of the first Topic into the shared memory corresponding to the first Topic according to the SmartMemory through the first process, and finally sends the update signal of the shared memory corresponding to the first Topic to multiple second processes through the first process. Therefore, when data transmission is performed through the shared memory, SmartMemory is used for data transmission, and there is no need to perform the serialization and deserialization process. SmartMemory allows users to read and write data directly in the shared memory, avoiding multiple copies of data and improving communication efficiency.

[0232] Figure 5 A schematic flow chart of a method for generating a shared memory provided in an embodiment of the present application is shown.

[0233] like Figure 5 The following figure shows the process of two concurrent processes (Process 1 and Process 2) trying to open the shared memory of a Topic at the same time. Figure 5 The method of generating shared memory is shown in FIG.

[0234] When Process 1 successfully opens the shared memory of the Topic, but Process 2 fails to open the shared memory of the Topic:

[0235] Process 1 successfully opens the shared memory using the shm_open interface, then obtains the file lock of the shared memory and opens it, maps the shared memory to the virtual address space, writes the header data of the shared memory to the virtual address space, allocates each data structure in the shared memory according to the header data of the shared memory and calculates the offset of each data structure, thereby completing the initialization operation of the shared memory.

[0236] Process 2 fails to open the shared memory using the shm_open interface, and returns the failure reason that the shared memory has been opened. At this time, shm_open is used to open the shared memory in read-only form, and the file lock of the shared memory is obtained and opened. The shared memory is mapped to the virtual address space, and the header data of the shared memory is read. The header data is used to determine whether the shared memory is initialized, whether the address range mapped in the virtual address space of process 2 is consistent with the address range mapped in the virtual address space of process 1, and the virtual address of each data structure in the virtual address space of process 2 is calculated to ensure that a communication connection is established between process 2 and process 1.

[0237] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0238] Corresponding to the data transmission method of the above embodiment, Figure 6 A structural block diagram of a data transmission device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.

[0239] Reference Figure 6 , the device 600 comprises:

[0240] An opening module 601 is used to start multiple processes and simultaneously open the shared memory corresponding to each first Topic;

[0241] A configuration module 602 is used to configure the shared memory corresponding to each first Topic through a first process, where the first process is a process that successfully opens the shared memory corresponding to each first Topic;

[0242] A writing module, used for writing the data of the first topic in the shared memory corresponding to each configured first topic through the first process;

[0243] The notification module is used to notify multiple second processes through the first process to read data from the shared memory corresponding to the configured first Topic, and the second processes are other processes among the multiple processes except the first process.

[0244] In actual use, the data transmission device provided in the embodiment of the present application can be configured in any terminal device to execute the aforementioned data transmission method.

[0245] The data transmission device provided by the present application first starts multiple processes to simultaneously open the shared memory corresponding to each first Topic, then configures the shared memory corresponding to each first Topic through the first process, the first process is the process that successfully opens the shared memory corresponding to each first Topic, then writes the data of the first Topic into the shared memory corresponding to each configured first Topic through the first process, and finally notifies multiple second processes through the first process to read data from the shared memory corresponding to the configured first Topic, the second process is the other process among the multiple processes except the first process. By having multiple processes compete to open the shared memory corresponding to each Topic, it is ensured that the shared memory of each Topic is managed by one process, thereby improving the robustness of the data transmission device.

[0246] In a possible implementation of the embodiment of the present application, the configuration module 602 includes:

[0247] A first mapping unit is used to map the shared memory corresponding to each first Topic to the virtual address space of the first process to create a first shared memory when the first process successfully obtains the file lock of the shared memory corresponding to each first Topic;

[0248] The initialization unit is used to perform an initialization operation on the first shared memory to complete the initialization operation on the shared memory corresponding to each first Topic.

[0249] Furthermore, in a possible implementation of the embodiment of the present application, the initialization unit is specifically used to:

[0250] The above initialization unit is specifically used for:

[0251] Write the header data of the shared memory corresponding to each first Topic into the first shared memory;

[0252] According to the header data of the shared memory corresponding to each first Topic, each data structure in each first Topic is allocated in the first shared memory, and the header data of the shared memory corresponding to the first Topic includes the offset of each data structure in the first Topic.

[0253] Furthermore, in another possible implementation of the embodiment of the present application, the apparatus 600 further includes:

[0254] A mapping module, used for mapping the shared memory corresponding to any first Topic to the virtual address space of the second process through the second process to create a second shared memory;

[0255] An acquisition module, used for acquiring header data of a shared memory corresponding to any first Topic from a second shared memory through a second process;

[0256] The reading module is used to read the header data of the shared memory corresponding to any first Topic through the second process, so as to establish a communication connection between the second process and the first process.

[0257] Furthermore, in another possible implementation of the embodiment of the present application, the above-mentioned device further includes:

[0258] A judgment module, used for judging whether any second process obtains a file lock of the shared memory corresponding to any first Topic when any second process successfully opens the shared memory corresponding to any first Topic in a read-only manner;

[0259] The above mapping module includes:

[0260] The second mapping unit is used to map the shared memory corresponding to any first Topic to the virtual address space of the second process through the second process to create a second shared memory when any second process can obtain the file lock of the shared memory corresponding to any first Topic.

[0261] Furthermore, in another possible implementation of the embodiment of the present application, the reading module includes:

[0262] A first determining unit, configured to determine, according to an initialization flag bit in header data of the shared memory corresponding to the first Topic, whether the shared memory corresponding to the first Topic has completed the initialization operation;

[0263] A second determining unit, configured to determine the consistency between the second memory and the first memory according to the offset of each data structure in the first Topic;

[0264] The calculation unit is used to calculate the virtual address of each data structure in the first topic in the second shared memory according to the offset of each data structure in the first topic.

[0265] Furthermore, in another possible implementation of the embodiment of the present application, the data type of the data of the first Topic is set to a POD type, and the data of the first Topic is set to a C++ structure.

[0266] Furthermore, in another possible implementation of the embodiment of the present application, the data of the first Topic is stored in a preset custom container.

[0267] Furthermore, in another possible implementation of the embodiment of the present application, the writing module 603 includes:

[0268] An acquisition unit, used to acquire a SmartMemory associated with a shared memory corresponding to a configured first Topic;

[0269] A writing unit, used to write the data of the first Topic into the shared memory corresponding to the configured first Topic through SmartMemory;

[0270] Accordingly, the notification module 604 includes:

[0271] The sending unit is used to send an update signal to the plurality of second processes, wherein the update signal is used to indicate that data in the shared memory corresponding to the first Topic is updated.

[0272] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0273] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0274] In order to implement the above embodiments, the present application also proposes a terminal device.

[0275] Figure 7 A schematic diagram of the structure of a terminal device according to an embodiment of the present application.

[0276] like Figure 7 As shown, the terminal device 200 includes:

[0277] A memory 210 and at least one processor 220, a bus 230 connecting different components (including the memory 210 and the processor 220), the memory 210 stores a computer program, and when the processor 220 executes the program, the method for generating a planned path described in an embodiment of the present application is implemented.

[0278] Bus 230 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.

[0279] The terminal device 200 typically includes a variety of electronic device readable media, which can be any available media that can be accessed by the terminal device 200, including volatile and non-volatile media, removable and non-removable media.

[0280] The memory 210 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 240 and / or cache memory 250. The terminal device 200 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 260 may be used to read and write non-removable, non-volatile magnetic media ( Figure 7 not shown, usually called a "hard drive"). Although Figure 7 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical medium) may be provided. In these cases, each drive may be connected to bus 230 via one or more data medium interfaces. Memory 210 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present application.

[0281] A program / utility 280 having a set (at least one) of program modules 270 may be stored, for example, in the memory 210, such program modules 270 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 270 generally perform the functions and / or methods of the embodiments described herein.

[0282] The terminal device 200 can also communicate with one or more external devices 290 (e.g., keyboard, pointing device, display 291, etc.), and can also communicate with one or more devices that enable users to interact with the terminal device 200, and / or communicate with any device that enables the terminal device 200 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be carried out through an input / output (I / O) interface 292. In addition, the terminal device 200 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN) and / or public network, such as the Internet) through a network adapter 293. As shown in the figure, the network adapter 293 communicates with other modules of the terminal device 200 through a bus 230. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the terminal device 200, including but not limited to: microcode, device driver, redundant processing unit, external disk drive array, RAID system, tape drive, and data backup storage system, etc.

[0283] The processor 220 executes various functional applications and data processing by running the programs stored in the memory 210 .

[0284] It should be noted that the implementation process and technical principles of the terminal device of this embodiment refer to the aforementioned explanation of the data transmission method of the embodiment of the present application, and will not be repeated here.

[0285] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0286] An embodiment of the present application provides a computer program product. When the computer program product runs on a terminal device, the terminal device can implement the steps in the above-mentioned method embodiments when executing the computer program product.

[0287] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / terminal device, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0288] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0289] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0290] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0291] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0292] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application. < / phone>

Claims

1. A data transmission method, characterized in that: The method comprises: Start multiple processes and open the shared memory corresponding to each first topic at the same time; Configuring the shared memory corresponding to each of the first topics through a first process, where the first process is the process that successfully opens the shared memory corresponding to each of the first topics; Writing the data of the first Topic into the shared memory corresponding to each configured first Topic through the first process; The first process notifies multiple second processes to read data from a shared memory corresponding to the configured first Topic, where the second processes are other processes among the multiple processes except the first process.

2. The method according to claim 1, characterized in that The configuring the shared memory corresponding to each of the first topics through the first process includes: When the first process successfully obtains the file lock of the shared memory corresponding to each of the first topics, mapping the shared memory corresponding to each of the first topics to the virtual address space of the first process to create a first shared memory; An initialization operation is performed on the first shared memory to complete an initialization operation on the shared memory corresponding to each of the first topics.

3. The method according to claim 2, characterized in that The initializing operation on the first shared memory to complete the initialization operation on the shared memory corresponding to each of the first topics includes: Writing header data of the shared memory corresponding to each of the first topics into the first shared memory; According to header data of the shared memory corresponding to each of the first topics, each data structure in each of the first topics is allocated in the first shared memory, and the header data of the shared memory corresponding to the first topic includes an offset of each data structure in the first topic.

4. The method according to any one of claims 1 to 3, characterized in that: After configuring the shared memory corresponding to each of the first topics through the first process, the method further includes: Mapping, by the second process, a shared memory corresponding to any one of the first topics into a virtual address space of the second process to create a second shared memory; Obtaining header data of any shared memory corresponding to the first Topic from the second shared memory through the second process; The header data of the shared memory corresponding to any one of the first topics is read by the second process, so that a communication connection is established between the second process and the first process.

5. The method according to claim 4, characterized in that Before mapping, by the second process, the shared memory corresponding to any one of the first topics into the virtual address space of the second process to create the second shared memory, the method further includes: When any of the second processes successfully opens the shared memory corresponding to any of the first topics in read-only mode, determining whether any of the second processes obtains a file lock of the shared memory corresponding to any of the first topics; Mapping, by the second process, any shared memory corresponding to the first Topic into a virtual address space of the second process to create a second shared memory includes: When any of the second processes can obtain the file lock of the shared memory corresponding to any of the first topics, the shared memory corresponding to any of the first topics is mapped to the virtual address space of the second process through the second process to create a second shared memory.

6. The method according to claim 4, characterized in that The step of reading header data of a shared memory corresponding to any one of the first topics through the second process so as to establish a communication connection between the second process and the first process includes: Determining, according to an initialization flag bit in header data of the shared memory corresponding to the first Topic, that the shared memory corresponding to the first Topic completes the initialization operation; Determining consistency between the second memory and the first memory according to the offset of each data structure in the first Topic; According to the offset of each data structure in the first Topic, a virtual address of each data structure in the first Topic in the second shared memory is calculated.

7. The method according to claim 1, characterized in that The data type of the data of the first Topic is set to a plain old data POD type, and the data of the first Topic is set to a C++ structure.

8. The method according to claim 7, characterized in that The data of the first Topic is stored in a preset custom container.

9. The method according to any one of claims 1 to 3, characterized in that: Writing the data of the first topic into the shared memory corresponding to each configured first topic through the first process includes: Obtain a smart pointer associated with the shared memory corresponding to the first configured Topic; Writing the data of the first Topic into the configured shared memory corresponding to the first Topic through the smart pointer; Correspondingly, notifying multiple second processes through the first process to read data from the shared memory corresponding to the configured first Topic includes: An update signal is sent to the plurality of second processes, wherein the update signal is used to indicate that data in the shared memory corresponding to the first Topic is updated.

10. A data transmission device, characterized in that: include: The opening module is used to start multiple processes and open the shared memory corresponding to each first Topic at the same time; A configuration module, configured to configure the shared memory corresponding to each of the first topics through a first process, wherein the first process is the process that successfully opens the shared memory corresponding to each of the first topics; A writing module, used for writing the data of the first Topic in the shared memory corresponding to each configured first Topic through the first process; A notification module is used to notify multiple second processes through the first process to read data from the shared memory corresponding to the configured first Topic, where the second processes are other processes among the multiple processes except the first process.

11. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 9 is implemented.

12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.