Data transmission method, device, electronic device and storage medium

By dividing the cyclic cache area in the shared memory of the multi-core processor and using the DMA chain to send data uniformly, the problem of low data transmission efficiency between the multi-core processor and external devices is solved, and the data transmission efficiency and the performance of the power system are improved.

CN113535425BActive Publication Date: 2024-11-26NR ELECTRIC CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110665474.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-16
Publication Date
2024-11-26
Estimated Expiration
2041-06-16

AI Technical Summary

Technical Problem

The data transmission efficiency between multi-core processors and external devices is low, with competitive relationships and performance overhead, which affects the control and protection performance of the power system.

Method used

By dividing the circular cache area in the shared memory of the multi-core processor, each core writes the information of the data to be sent, and when the DMA is detected, the set core starts the DMA chain to send data uniformly, avoiding multiple cores to send data at the same time. competition to reduce data copying and framing operations.

Benefits of technology

It improves the data transmission efficiency between multi-core processors and external devices, shortens data transmission time, reduces the performance overhead of setting cores, and enhances the control and protection performance of the power system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113535425B_ABST
    Figure CN113535425B_ABST
Patent Text Reader

Abstract

The present application discloses a data transmission method, device, electronic device and storage medium. The method includes: when the multi-core processor has data to be sent, writing first information corresponding to the data to be sent to the circular buffer area corresponding to the first core in the shared memory; the first core represents the core where the data to be sent exists; the first information is used to describe the corresponding data to be sent; each core of the multi-core processor is configured with a corresponding circular buffer area in the shared memory; the setting core of the multi-core processor determines that there is data to be sent; when DMA is detected to be idle, the setting core starts the DMA chain to send the data to be sent based on the scanning result of the shared memory.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data transmission, and in particular to a data sending method, device, electronic device and storage medium. Background Art

[0002] With the development and application of multi-core processor technology, multi-core processors are increasingly used in power system control and protection equipment. The core board in power system control and protection equipment generally adopts a multi-core processor plus a field programmable gate array (FPGA) architecture. A large amount of data will be exchanged between the multi-core processor and the FPGA. When each core transmits data to the FPGA at the same time, there will be competition, resulting in low data transmission efficiency between the multi-core processor and the FPGA. Summary of the invention

[0003] In view of this, the main purpose of the embodiments of the present application is to provide a data sending method, device, electronic device and storage medium to solve the problem of low data transmission efficiency between a multi-core processor and an external device in the related art.

[0004] To achieve the above purpose, the technical solution of the embodiment of the present application is implemented as follows:

[0005] The present application provides a data transmission method, the method comprising:

[0006] When the multi-core processor has data to be sent, first information corresponding to the data to be sent is written into a circular buffer area corresponding to a first core in the shared memory; the first core represents a core having data to be sent; the first information is used to describe the corresponding data to be sent; each core of the multi-core processor is configured with a corresponding circular buffer area in the shared memory;

[0007] The setting core of the multi-core processor determines that there is data to be sent;

[0008] When it is detected that the direct memory access (DMA) is idle, the setting core starts the DMA chain to send out the data to be sent based on the scanning result of the shared memory.

[0009] In the above solution, when writing the first information corresponding to the data to be sent into the circular buffer area corresponding to the first core in the shared memory, the method includes:

[0010] The first core calls a set interface function and transmits first information corresponding to the data to be sent to the set interface function; wherein,

[0011] The set interface function is used to write the first information into a corresponding circular buffer area in the shared memory.

[0012] In the above solution, the step of writing first information corresponding to the data to be sent into the circular buffer area corresponding to the first core in the shared memory includes:

[0013] Determine a first priority; the first priority represents a sending priority of the data to be sent;

[0014] Writing first information corresponding to the data to be sent into a first circular buffer area of ​​at least two circular buffer areas corresponding to the first core; wherein,

[0015] The first circular buffer area is used to write first information corresponding to the to-be-sent data of the first priority level.

[0016] In the above solution, the setting core of the multi-core processor determines that there is data to be sent, including:

[0017] When receiving an inter-core interrupt signal, the setting core determines that there is data to be sent; wherein the inter-core interrupt signal is sent by the first core, indicating that the data to be sent is written into the circular buffer area corresponding to the first core; and / or,

[0018] The setting core scans each circular buffer area in the shared memory at a set time interval, and determines that there is data to be sent when it is found that the data to be sent corresponding to the first information in the circular buffer area has not been sent.

[0019] In the above scheme, when the setting core starts the DMA chain to send the data to be sent based on the scanning result of the shared memory, the method includes:

[0020] When the first sequence number and the second sequence number in the scanned circular buffer area are inconsistent, the setting core starts the DMA chain to send out the data to be sent; wherein,

[0021] The first sequence number represents the sequence number corresponding to the first information most recently written in the circular buffer; the second sequence number represents the sequence number corresponding to the first information most recently read by the setting core in the circular buffer.

[0022] In the above solution, the first information includes at least one of the following:

[0023] The starting address of the data to be sent;

[0024] The destination address of the data to be sent;

[0025] The length of the data to be sent.

[0026] In the above scheme, the method further includes:

[0027] When an abnormality occurs in the set core, a new set core is determined from among all the cores of the multi-core processor based on the set order.

[0028] The present application also provides a data sending device, the device comprising:

[0029] a writing unit, configured to write first information corresponding to the data to be sent into a circular buffer area corresponding to a first core in a shared memory when the multi-core processor has data to be sent; the first core represents a core having data to be sent; the first information is used to describe the corresponding data to be sent; each core of the multi-core processor is configured with a corresponding circular buffer area in the shared memory;

[0030] A determining unit, configured for a setting core of the multi-core processor to determine that there is data to be sent;

[0031] The starting unit is used for starting the DMA chain to send out the data to be sent based on the scanning result of the shared memory when the DMA is detected to be idle.

[0032] The embodiment of the present application further provides an electronic device, comprising: a processor and a memory for storing a computer program that can be run on the processor, wherein:

[0033] The processor is used to execute the steps of any of the above methods when running the computer program.

[0034] An embodiment of the present application further provides a storage medium having a computer program stored thereon, wherein the computer program implements the steps of any of the above methods when executed by a processor.

[0035] In an embodiment of the present application, each core of the multi-core processor is configured with a corresponding circular buffer area in the shared memory. When the multi-core processor has data to be sent, the first information corresponding to the data to be sent is written to the circular buffer area corresponding to the first core in the shared memory, wherein the first core represents the core with data to be sent, and the first information is used to describe the corresponding data to be sent. After the setting core of the multi-core processor determines that there is data to be sent, when the DMA is detected to be idle, the setting core starts the DMA chain to send the data to be sent based on the scanning result of the shared memory. In this way, the setting core starts the DMA chain to send data to the external device uniformly, without copying all the data to be sent and framing them to the setting core, reducing the performance overhead of the setting core and shortening the time required for sending data to the external device. By setting the shared memory and dividing the circular buffer area for each core in the shared memory, when each core has data to be sent, the setting core can scan the circular buffer area and start the DMA chain to send the data to be sent, avoiding the competition relationship between multiple cores sending data to the external device at the same time, and improving the efficiency of data transmission between the multi-core processor and the external device. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 A schematic diagram of the implementation flow of the data transmission method provided in the embodiment of the present application;

[0037] Figure 2 A schematic diagram of a circular buffer area corresponding to each core provided in an embodiment of the present application;

[0038] Figure 3 A schematic diagram of a process of writing first information into a circular buffer area provided in an embodiment of the present application;

[0039] Figure 4 A schematic diagram of the implementation flow of the data transmission method provided in the application embodiment of the present application;

[0040] Figure 5 A schematic diagram of the implementation flow of another data sending method provided in an application embodiment of the present application;

[0041] Figure 6 A schematic diagram of a data sending device provided in an embodiment of the present application;

[0042] Figure 7 Schematic diagram of the hardware structure of the electronic device according to the embodiment of the present application. DETAILED DESCRIPTION

[0043] With the development and application of multi-core processor technology, multi-core processors have been increasingly used in power system control and protection equipment. Multi-core processors have the function of parallel processing, which allows multiple programs to run simultaneously, can effectively reduce the operating cycle, and improve the control and protection performance. In related technologies, the core board of power system control and protection equipment generally adopts the architecture of multi-core processor + FPGA, in which the multi-core processor runs various application algorithms, and the FPGA is used to implement sampling, communication and other functions. The multi-core processor and FPGA generally use high-speed serial computer expansion bus standards (PCIE, Peripheral Component Interconnect Express), Serial Rapid I / O (SRIO) interface, security gateway management interface (SGMI, Security Gateway Management Interface), and serial peripheral interface (SPI, Serial Peripheral Interface) to exchange data. The data transmission efficiency between the multi-core processor and the FPGA will affect the performance of the entire board.

[0044] In some application scenarios, multiple cores of a multi-core processor may send data to external devices such as FPGA at the same time. At this time, there will be competition between multiple cores when sending data. In the end, only one core can send data, and the other cores can only wait. In other application scenarios, in order to solve the competition between multiple cores when sending data, one core in the multi-core processor will be selected as a proxy core, and the data to be sent by other cores will be summarized by the proxy core and sent to external devices such as FPGA. However, in the process of sending the data to be sent by other cores to the proxy core for summary, there are a large number of data copy operations due to the need for framing, which will cause the proxy core to be overloaded. When the proxy core is overloaded, it cannot send data to external devices such as FPGA. Not only is the data transmission process affected, but there may also be security risks.

[0045] In a method for realizing buffer descriptor interaction and a method for manufacturing an electronic device, it is proposed to add a proxy module in a terminal device, use the proxy module to provide each processing core with an entry to a buffer descriptor (BD, BufferDescription) sending queue and a BD receiving queue, and use the proxy module to perform pointer operations on the BD sending queue and the BD receiving queue, so that each core can realize the write operation to the BD sending queue and the read operation to the BD receiving queue through the proxy module, and can also avoid the many-to-one competition of the pointer operation of each processing core. The proxy module of the method is set in the terminal, that is, FPGA, and the FPGA maintains the BD sending queue, and the FPGA actively reads the data according to the queue content. Since the method only maintains one BD sending queue, there is still a competition problem when multiple cores write to the queue at the same time, and the data cannot be prioritized, and the data with higher priority may not be sent out in time. The data transmission and reception process is completely controlled by the FPGA, and the processor cannot timely perceive whether the data is successfully read by the FPGA. At the same time, the method requires the cooperation of the FPGA development program, and when the peripheral is replaced with another device, the method does not work.

[0046] That is to say, in the related technology, the data transmission efficiency between the multi-core processor and the FPGA is relatively low. For the control and protection equipment of the power system, due to the high real-time requirements, the programs of each core of the multi-core processor are relatively independent. When each core reads and writes data to the external device frequently, the data exchange capability between the multi-core processor and the FPGA becomes the bottleneck of the performance of the entire power system. Therefore, it is necessary to study a method for exchanging data between a multi-core processor and an external device to improve the data interaction capability and efficiency between the multi-core processor and the FPGA.

[0047] Based on this, the embodiment of the present application provides a data sending method, device, electronic device and storage medium. When there is data to be sent in a multi-core processor, first information corresponding to the data to be sent is written to the circular buffer area corresponding to the first core in the shared memory, wherein the first core represents the core with data to be sent, and the first information is used to describe the corresponding data to be sent. Each core of the multi-core processor is configured with a corresponding circular buffer area in the shared memory. After the setting core of the multi-core processor determines that there is data to be sent, when the DMA is detected to be idle, the setting core starts the DMA chain based on the scanning result of the shared memory to send the data to be sent. In this way, the setting core starts the DMA chain to send data to the external device uniformly, without copying all the data to be sent and framing them to the setting core, reducing the performance overhead of the setting core and shortening the time required for sending data to the external device. By setting the shared memory and dividing the circular buffer area for each core in the shared memory, when each core has data to be sent, the setting core can scan the circular buffer area and start the DMA chain to send the data to be sent, avoiding the competition relationship between multiple cores sending data to the external device at the same time, and improving the efficiency of data transmission between the multi-core processor and the external device.

[0048] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments.

[0049] Figure 1 The following is a schematic diagram of the implementation flow of the data transmission method provided in the embodiment of the present application, wherein the method is applied to a first device, and the first device is configured with a multi-core processor. Figure 1 As shown, the method includes:

[0050] Step 101: When there is data to be sent in the multi-core processor, first information corresponding to the data to be sent is written into the circular buffer area corresponding to the first core in the shared memory; the first core represents the core where the data to be sent exists; the first information is used to describe the corresponding data to be sent; each core of the multi-core processor is configured with a corresponding circular buffer area in the shared memory.

[0051] Here, when any core in the multi-core processor has data to be sent, the core having the data to be sent, namely the first core, writes first information corresponding to the data to be sent into the circular buffer area corresponding to the first core, wherein the circular buffer area corresponding to the first core is located in the shared memory. In the shared memory, each core of the multi-core processor is configured with a corresponding circular buffer area. By writing the first information corresponding to the data to be sent into the corresponding circular buffer area in the shared memory, it is convenient to read the data to be sent.

[0052] The first information is used to describe the corresponding data to be sent. Specifically, in one embodiment, the first information includes at least one of the following:

[0053] The starting address of the data to be sent;

[0054] The destination address of the data to be sent;

[0055] The length of the data to be sent.

[0056] Here, the first information includes at least one of the starting address, destination address and length of the data to be sent. Writing the first information of the data to be sent into the corresponding circular buffer instead of directly writing the data to be sent into the corresponding circular buffer can save the memory space of the shared memory and reduce the load and performance overhead of the multi-core processor.

[0057] Step 102: The setting core of the multi-core processor determines that there is data to be sent.

[0058] Here, after the first core writes the first information in the corresponding circular buffer area in the shared memory, it indicates that there is data to be sent to the external device in the multi-core processor, and the setting core of the multi-core processor determines that there is data to be sent. Any core in the multi-core processor is designated as the setting core, and the setting core performs the proxy function, and the proxy first core sends the data to be sent uniformly.

[0059] Step 103: When the DMA is detected to be idle, the setting core starts the DMA chain to send out the data to be sent based on the scanning result of the shared memory.

[0060] Here, when the proxy core detects that the DMA is idle, the core is set to scan each circular buffer area in the shared memory, and based on the scanning result, the DMA chain is started to send the data to be sent. The DMA chain represents a DMA chain list, and when the scanning result indicates that there is data to be sent, the first information corresponding to the data to be sent is written into the DMA chain, and the data to be sent is sent to the external device through the DMA chain.

[0061] DMA is an external device independent of the multi-core processor. DMA is used to copy data from one address space to another address space to achieve data transmission. In the embodiment of the present application, DMA is used to copy the data to be sent from the shared memory to an external device such as an FPGA.

[0062] In one embodiment, when writing first information corresponding to the data to be sent into the circular buffer area corresponding to the first core in the shared memory, the method includes:

[0063] The first core calls a set interface function and transmits first information corresponding to the data to be sent to the set interface function; wherein,

[0064] The set interface function is used to write the first information into a corresponding circular buffer area in the shared memory.

[0065] Here, when writing the first information corresponding to the data to be sent into the circular buffer area corresponding to the first core in the shared memory, the first core calls the set interface function, passes the first information corresponding to the data to be sent to the set interface function, and writes the first information into the corresponding circular buffer area through the set interface function. The set interface function is used to write the first information into the corresponding circular buffer area in the shared memory.

[0066] When there is data to be sent, the first core writes the first information into the corresponding circular buffer area by calling a set interface function, which can improve the efficiency of writing the first information into the circular buffer area.

[0067] In one embodiment, writing first information corresponding to the data to be sent into the circular buffer area corresponding to the first core in the shared memory includes:

[0068] Determine a first priority; the first priority represents a sending priority of the data to be sent;

[0069] Writing first information corresponding to the data to be sent into a first circular buffer area of ​​at least two circular buffer areas corresponding to the first core; wherein,

[0070] The first circular buffer area is used to write first information corresponding to the to-be-sent data of the first priority level.

[0071] Here, when writing the first information corresponding to the data to be sent to the circular buffer area corresponding to the first core in the shared memory, the sending priority of the data to be sent, that is, the first priority, must be determined first. The first core corresponds to at least two circular buffer areas in the shared memory. After the first core calls the set interface function, the set interface function obtains the first priority of the data to be sent by the first core, and then writes the first information to the first circular buffer area of ​​the at least two circular buffer areas corresponding to the first core based on the first priority. Among them, the first circular buffer area is used to write the first information corresponding to the data to be sent of the first priority. In other words, the set interface function will write the first information corresponding to the data to be sent to the circular buffer area that matches the sending priority according to the sending priority of the data to be sent.

[0072] Exemplarily, when the first priority is a high priority, the first core calls a set interface function to write the first information to the first circular buffer area of ​​at least two circular buffer areas corresponding to the first core, and at this time, the first circular buffer area is used to store the first information corresponding to the high priority data to be sent. When the first priority is a low priority, the first core calls a set interface function to write the first information to the first circular buffer area of ​​at least two circular buffer areas corresponding to the first core, and at this time, the first circular buffer area is used to store the first information corresponding to the low priority data to be sent.

[0073] Figure 2 A schematic diagram of the loop buffer area corresponding to each core provided in the embodiment of the present application, such as Figure 2 As shown:

[0074] Each core corresponds to at least two circular buffers, including a high-priority circular buffer and a low-priority circular buffer, wherein the high-priority circular buffer is used to store the first information corresponding to the high-priority data to be sent, and the low-priority circular buffer is used to store the first information corresponding to the low-priority data to be sent. The set interface function writes the corresponding first information into the circular buffer matching the sending priority of the at least two circular buffers corresponding to each core based on the sending priority of the data to be sent.

[0075] Exemplarily, there is data 0 to be sent in the first core, and the sending priority of data 0 to be sent is high priority. Then, when the first core calls the set interface function, after determining that the sending priority of data 0 to be sent is high priority, a circular buffer area that matches the sending priority of data 0 to be sent is found in the circular buffer area corresponding to the first core, that is, the high priority circular buffer area. Afterwards, the set interface function writes the first information corresponding to data 0 to be sent into the high priority circular buffer area.

[0076] By determining the sending priority of the data to be sent and writing the first information corresponding to the data to be sent into a circular buffer area matching the priority, the data sending order can be adjusted based on the different sending priorities of the data to be sent, thereby improving the flexibility of data transmission.

[0077] In one embodiment, the setting core of the multi-core processor determines that there is data to be sent, including:

[0078] When receiving an inter-core interrupt signal, the setting core determines that there is data to be sent; wherein the inter-core interrupt signal is sent by the first core, indicating that the data to be sent is written into the circular buffer area corresponding to the first core; and / or,

[0079] The setting core scans each circular buffer area in the shared memory at a set time interval, and determines that there is data to be sent when it is found that the data to be sent corresponding to the first information in the circular buffer area has not been sent.

[0080] Here, when an inter-core interrupt signal is received, the setting core determines that there is data to be sent. The inter-core interrupt signal is sent by the first core, indicating that the data to be sent is written into the circular buffer area corresponding to the first core. Specifically, when the data to be sent is written into the second circular buffer area corresponding to the first core, the first core sends the inter-core interrupt signal. The second circular buffer area is used to write the first information corresponding to the high-priority data to be sent.

[0081] It should be noted that when the first core writes the data to be sent in the corresponding second circular buffer area, it means that there is data to be sent with a high sending priority in the first core, and usually the data to be sent with a high sending priority is the data that needs to be sent first. Therefore, in order to ensure that the high priority data to be sent can be sent in time, the first core will send an inter-core interrupt signal to the setting core to notify the setting core that there is high priority data to be sent in the circular buffer area corresponding to the first core, so that the setting core can process it in time, thereby improving the timeliness of data transmission.

[0082] After the setting core receives the inter-core interrupt signal, the setting core will first scan the second loop buffer area corresponding to each first core, and after scanning all the second loop buffer areas corresponding to the first cores, the setting core will scan the third loop buffer area corresponding to each first core to determine whether there is the first information corresponding to the data to be sent in the third loop buffer area corresponding to each core. Among them, the third loop buffer area is used to write the first information corresponding to the low-priority data to be sent. Because when the first core writes the first information corresponding to the data to be sent in the corresponding third loop buffer area, it means that there is data to be sent with a low priority in the first core, and the sending time of the data to be sent with a low priority is usually not urgent, so the setting core will scan the third loop buffer area later. It should be noted that, after receiving the inter-core interrupt signal, the setting core first scans the corresponding second loop buffer area, and after scanning all the second loop buffer areas, it scans the corresponding third loop buffer area, so that the first information corresponding to the data to be sent in the first scanned second loop buffer area will be sent out first through the DMA chain, and the first information corresponding to the data to be sent in the third loop buffer area scanned later will be sent out later through the DMA chain. In this way, it is ensured that the data to be sent with a high priority is sent first, and the data to be sent with a low priority is sent later, thereby improving the timeliness of data transmission.

[0083] In one embodiment, the first core sends an inter-core interrupt signal to the setting core by calling a set startup function, and the set startup function is used to transmit the inter-core interrupt signal to the setting core.

[0084] And / or, the core is set to scan each circular buffer area in the shared memory at a set time interval, and when it is found that the data to be sent corresponding to the first information in the circular buffer area has not been sent, it is determined that there is data to be sent.

[0085] Here, after the DMA chain sends the data to be sent, the DMA will send a completion interrupt signal to the setting core, triggering the setting core to generate a completion interrupt. After the setting core generates a completion interrupt, in order to avoid the omission of the data to be sent, the setting core will periodically scan the circular buffer area in the shared memory. If the first information is found in the circular buffer area, it is determined that there is data to be sent, and then the data to be sent is sent by starting the DMA chain. It should be noted that here the setting core periodically scans all the circular buffer areas corresponding to each core in the shared memory.

[0086] By receiving an inter-core interrupt signal and / or periodically scanning a circular buffer area, the setting core can accurately determine that there is data to be sent, so as to facilitate timely processing of the data to be sent.

[0087] In one embodiment, when the setting core starts the DMA chain to send out the data to be sent based on the scanning result of the shared memory, the method includes:

[0088] When the first sequence number and the second sequence number in the scanned circular buffer area are inconsistent, the setting core starts the DMA chain to send out the data to be sent; wherein,

[0089] The first sequence number represents the sequence number corresponding to the first information most recently written in the circular buffer; the second sequence number represents the sequence number corresponding to the first information most recently read by the setting core in the circular buffer.

[0090] Here, the starting position of each circular buffer area will allocate memory space for recording the first sequence number and the second sequence number, the first sequence number represents the sequence number corresponding to the first information most recently written in the circular buffer area, and the second sequence number represents the sequence number corresponding to the first information most recently read by the setting core in the circular buffer area. Among them, the reading of the setting core represents that the setting core reads the first information from the circular buffer area and puts the first information into the DMA chain. Based on the first sequence number and the second sequence number, the memory location of the first information most recently written and most recently read by the setting core can be known. When the first information is written in the circular buffer area, the first sequence number will be updated. When the setting core reads the first information in the circular buffer area, the second sequence number will be updated. If the first sequence number and the second sequence number in the circular buffer area are scanned to be inconsistent, it means that there is still first information in the circular buffer area that has not been read by the setting core, that is, it means that there is still first information corresponding to the data to be sent in the circular buffer area. In this case, the setting core starts the DMA chain to send the data to be sent.

[0091] like Figure 2 As shown, the starting position of each circular buffer is allocated with memory space for recording the first sequence number and the second sequence number, wherein the first sequence number represents the sequence number of the first information currently written to the circular buffer, and the first sequence number represents the sequence number corresponding to the first information last read by the setting core of the circular buffer. When the first sequence number is consistent with the second sequence number, it means that the sequence number currently written in the circular buffer is the same as the sequence number read by the setting core, and therefore, the first information corresponding to the data to be sent does not exist in the circular buffer. If the first sequence number is inconsistent with the second sequence number, it means that the sequence number currently written in the circular buffer is different from the sequence number read by the setting core. In this case, it means that the first information corresponding to the data to be sent exists in the circular buffer. Exemplarily, when the first sequence number is 4 and the second sequence number is 0, it means that there is the first information in the circular buffer that has not been read by the setting core. At this time, the setting core determines that there is data to be sent, and starts the DMA chain to send the data to be sent.

[0092] By setting the core to start the DMA chain to send the data to be sent when the first sequence number and the second sequence number in the scanned circular buffer area are inconsistent, it can be ensured that when there is data to be sent in the shared memory, the core can be set to process it in time and start the DMA chain to send the data in time, thereby improving the efficiency of data transmission.

[0093] In one embodiment, the method further comprises:

[0094] When an abnormality occurs in the set core, a new set core is determined from among all the cores of the multi-core processor based on the set order.

[0095] Here, the set core is determined by specifying any core in the multi-core processor. If the set core is abnormal, then based on the set order, a new set core is re-determined from all the cores of the multi-core processor. Exemplarily, the set order may be core 0, core 1, core 2, core 3. When the set core is core 0 and core 0 is abnormal, core 1 is determined as the new set core according to the set order.

[0096] By setting a rotation mechanism for the set core, it can be ensured that when an abnormality occurs in the set core, the data transmission of other cores is not affected, thereby improving the reliability of data transmission.

[0097] In one embodiment, when it is detected that the DMA is not idle, after the DMA chain sends out the data to be sent, the method further includes:

[0098] Receive the completion interrupt signal sent by the DMA; after setting the core to trigger the completion interrupt, start the DMA chain to send out the data to be sent.

[0099] Here, if it is detected that the DMA is not idle, the setting core will not start the DMA chain to send the data to be sent. Instead, after the DMA chain sends the data to be sent, the DMA chain will send a completion interrupt signal to the setting core. After the setting core receives the completion interrupt signal, it generates a completion interrupt. After receiving the completion interrupt signal sent by the DMA, the setting core will know that the DMA chain has sent the previous data to be sent and the DMA is currently in an idle state. At this time, if there is still data to be sent in the circular buffer area, the setting core will restart the DMA chain to send the data to be sent. In this way, it is ensured that the data to be sent can be sent in time when the DMA is not idle.

[0100] In actual applications, when the setting core determines that there is data to be sent, if the DMA is detected to be idle, the setting core starts the DMA chain to send the data to be sent based on the scan result of the shared memory. If the setting core detects that the DMA is not idle, it is known that the current flag of the DMA is the flag to be sent. After the DMA chain sends the data to be sent, the DMA will enter the sending completion service function, and detect the DMA flag in the service function. If the DMA flag is detected to be the flag to be sent, it indicates that the DMA chain needs to continue to send the data to be sent. Therefore, when the DMA flag is the flag to be sent, repeat the above steps until the DMA is in an idle state.

[0101] Figure 3 A schematic diagram of a process of writing first information into a circular buffer area provided in an embodiment of the present application, such as Figure 3 As shown:

[0102] When there is data to be sent in the first core, the first core calls the set interface function and writes the first information corresponding to the data to be sent into the corresponding circular buffer area. The set interface function determines whether the sending priority of the data to be sent is a high priority based on the information representing the priority in the first information corresponding to the data to be sent. If it is determined that the sending priority of the data to be sent is a high priority, the first information is written into the high-priority circular buffer area corresponding to the first core. Then the first core notifies the set core that there is high-priority data to be sent by sending an inter-core interrupt signal. If it is determined that the sending priority of the data to be sent is a low priority, the first information is written into the low-priority circular buffer area corresponding to the first core.

[0103] Figure 4 A schematic diagram of the implementation flow of the data transmission method provided in the application embodiment of the present application is as follows: Figure 4 As shown:

[0104] After the setting core receives the notification of triggering the inter-core interrupt, it first checks whether the DMA is idle. If the DMA is idle, it first scans the high-priority circular buffer area corresponding to each core in the shared memory, and organizes the DMA chain to send data based on the scan result. After the setting core determines that the DMA has completed sending the data to be sent scanned this time, it determines whether the DMA flag is the to-be-sent flag in the sending completion service function. When the DMA flag is the to-be-sent flag, it indicates that the DMA chain needs to continue to send the data to be sent. Therefore, the setting core continues to scan the shared memory and organizes the DMA chain to send data. When the DMA flag is not the to-be-sent flag, it indicates that the DMA chain does not need to continue to send the data to be sent, so the data sending process ends. When the setting core detects that the DMA is not idle, it is known that the current DMA flag is the to-be-sent flag.

[0105] Figure 5 A schematic diagram of the implementation flow of another data sending method provided by the application embodiment of the present application is as follows: Figure 5 As shown:

[0106] The setting core periodically scans the circular buffer area corresponding to each core in the shared memory. If the scanning result indicates that there is data to be sent and the DMA is idle, the DMA is started and the DMA chain is organized to send data. After the setting core determines that the DMA has completed sending the data to be sent scanned this time, the data sending process ends. If the scanning result indicates that there is no data to be sent or the DMA is not idle, the setting core continues to periodically scan the circular buffer area corresponding to each core in the shared memory.

[0107] In an embodiment of the present application, when there is data to be sent in a multi-core processor, first information corresponding to the data to be sent is written to the circular buffer area corresponding to the first core in the shared memory, wherein the first core represents the core with data to be sent, and the first information is used to describe the corresponding data to be sent. Each core of the multi-core processor is configured with a corresponding circular buffer area in the shared memory. After the setting core of the multi-core processor determines that there is data to be sent, when the DMA is detected to be idle, the setting core starts the DMA chain to send the data to be sent based on the scanning result of the shared memory. In this way, the setting core starts the DMA chain to send data to the external device uniformly, without the need to copy all the data to be sent and frame it into the setting core, reducing the performance overhead of the setting core and shortening the time required for sending data to the external device. By setting the shared memory and dividing the circular buffer area for each core in the shared memory, when each core has data to be sent, the setting core can scan the circular buffer area and start the DMA chain to send the data to be sent, avoiding the competition relationship between multiple cores sending data to the external device at the same time, and improving the efficiency of data transmission between the multi-core processor and the external device.

[0108] In order to implement the method of the embodiment of the present application, the embodiment of the present application also provides a data sending device, Figure 6 For a schematic diagram of a data transmission device provided in an embodiment of the present application, see Figure 6 , the device comprises:

[0109] The writing unit 601 is used for writing first information corresponding to the data to be sent to the circular buffer area corresponding to the first core in the shared memory when there is data to be sent in the multi-core processor; the first core represents the core where the data to be sent exists; the first information is used to describe the corresponding data to be sent; each core of the multi-core processor is configured with a corresponding circular buffer area in the shared memory;

[0110] A determining unit 602, configured for a setting core of the multi-core processor to determine that there is data to be sent;

[0111] The starting unit 603 is used for starting the DMA chain to send out the data to be sent based on the scanning result of the shared memory when the DMA is detected to be idle.

[0112] In one embodiment, the writing unit 601 is further used for the first core to call a set interface function and pass the first information corresponding to the data to be sent to the set interface function; wherein,

[0113] The set interface function is used to write the first information into a corresponding circular buffer area in the shared memory.

[0114] In one embodiment, the writing unit 601 is further used to determine a first priority; the first priority represents a sending priority of the data to be sent;

[0115] Writing first information corresponding to the data to be sent into a first circular buffer area of ​​at least two circular buffer areas corresponding to the first core; wherein,

[0116] The first circular buffer area is used to write first information corresponding to the to-be-sent data of the first priority level.

[0117] In one embodiment, the determining unit 602 is further configured to, when receiving an inter-core interrupt signal, determine that the setting core has data to be sent; wherein the inter-core interrupt signal is sent by the first core, indicating that the data to be sent is written into the circular buffer area corresponding to the first core; and / or,

[0118] The setting core scans each circular buffer area in the shared memory at a set time interval, and determines that there is data to be sent when it is found that the data to be sent corresponding to the first information in the circular buffer area has not been sent.

[0119] In one embodiment, the startup unit 603 is further used for, when the first sequence number and the second sequence number in the scanned circular buffer area are inconsistent, the setting core starts the DMA chain to send out the data to be sent; wherein,

[0120] The first sequence number represents the sequence number corresponding to the first information most recently written in the circular buffer; the second sequence number represents the sequence number corresponding to the first information most recently read by the setting core in the circular buffer.

[0121] In one embodiment, the first information includes at least one of the following:

[0122] The starting address of the data to be sent;

[0123] The destination address of the data to be sent;

[0124] The length of the data to be sent.

[0125] In one embodiment, the device further includes: a second determining unit, configured to determine a new set core from among all the cores of the multi-core processor based on a set order when an abnormality occurs in the set core.

[0126] In actual application, the writing unit 601, the determining unit 602, the starting unit 603, and the second determining unit can be implemented by a processor in the terminal, such as a central processing unit (CPU), a digital signal processor (DSP), a microcontroller unit (MCU) or a programmable gate array (FPGA).

[0127] It should be noted that: when the data sending device provided in the above embodiment displays information, only the division of the above program modules is used as an example. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device is divided into different program modules to complete all or part of the above-described processing. In addition, the data sending device provided in the above embodiment and the data sending method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0128] Based on the hardware implementation of the above program modules and in order to implement the method of the embodiment of the present application, the embodiment of the present application also provides an electronic device. Figure 7 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 7 As shown, the electronic equipment includes:

[0129] Communication interface 701, capable of exchanging information with other devices such as network devices;

[0130] The processor 702 is connected to the communication interface 701 to implement information exchange with other devices and is used to execute the method provided by one or more technical solutions on the terminal side when running a computer program. The computer program is stored in the memory 703.

[0131] Specifically, the processor 702 is used to write first information corresponding to the data to be sent to the circular buffer area corresponding to the first core in the shared memory when there is data to be sent in the multi-core processor; the first core represents the core where the data to be sent exists; the first information is used to describe the corresponding data to be sent; each core of the multi-core processor is configured with a corresponding circular buffer area in the shared memory;

[0132] The setting core of the multi-core processor determines that there is data to be sent;

[0133] When the DMA is detected to be idle, the setting core starts the DMA chain to send out the data to be sent based on the scanning result of the shared memory.

[0134] In one embodiment, when writing the first information corresponding to the data to be sent into the circular buffer area corresponding to the first core in the shared memory, the processor 702 is further used for the first core to call a set interface function and pass the first information corresponding to the data to be sent to the set interface function; wherein,

[0135] The set interface function is used to write the first information into a corresponding circular buffer area in the shared memory.

[0136] In one embodiment, the processor 702 is further configured to determine a first priority; the first priority represents a sending priority of the data to be sent;

[0137] Writing first information corresponding to the data to be sent into a first circular buffer area of ​​at least two circular buffer areas corresponding to the first core; wherein,

[0138] The first circular buffer area is used to write first information corresponding to the to-be-sent data of the first priority level.

[0139] In one embodiment, the processor 702 is further configured to, when receiving an inter-core interrupt signal, determine that the setting core has data to be sent; wherein the inter-core interrupt signal is sent by the first core, indicating that the data to be sent is written into the circular buffer area corresponding to the first core; and / or,

[0140] The setting core scans each circular buffer area in the shared memory at a set time interval, and determines that there is data to be sent when it is found that the data to be sent corresponding to the first information in the circular buffer area has not been sent.

[0141] In one embodiment, when the setting core starts the DMA to send the data to be sent based on the scanning result of the shared memory, the processor 702 is further used for starting the DMA chain to send the data to be sent when the first sequence number and the second sequence number in the scanned circular buffer area are inconsistent; wherein,

[0142] The first sequence number represents the sequence number corresponding to the first information most recently written in the circular buffer; the second sequence number represents the sequence number corresponding to the first information most recently read by the setting core in the circular buffer.

[0143] In one embodiment, the first information includes at least one of the following:

[0144] The starting address of the data to be sent;

[0145] The destination address of the data to be sent;

[0146] The length of the data to be sent.

[0147] In one embodiment, the processor 702 is further configured to determine a new set core from among all the cores of the multi-core processor based on a set order when an exception occurs to the set core.

[0148] Of course, in actual application, the various components in the electronic device are coupled together through the bus system 704. It can be understood that the bus system 704 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 704 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 7 Various buses are labeled as bus system 704 .

[0149] The memory 703 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.

[0150] It can be understood that the memory 703 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAM bus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory 703 described in the embodiments of the present application is intended to include but is not limited to these and any other suitable types of memories.

[0151] The method disclosed in the above embodiment of the present application can be applied to the processor 702, or implemented by the processor 702. The processor 702 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of the hardware in the processor 702 or an instruction in the form of software. The above processor 702 may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 702 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module may be located in a storage medium, which is located in the memory 703, and the processor 702 reads the program in the memory 703 and completes the steps of the above method in combination with its hardware.

[0152] When the processor 702 executes the program, the corresponding processes in the various methods of the embodiments of the present application are implemented.

[0153] In an exemplary embodiment, the present application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, for example, a memory 703 storing a computer program, and the computer program can be executed by a processor 702 to complete the steps of the aforementioned method. The computer-readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface storage, optical disk, or CD-ROM.

[0154] In the several embodiments provided in the present application, it should be understood that the disclosed devices, terminals and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the 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 can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0155] The units described above as separate components may or may not be physically separated, and the components displayed 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 present embodiment.

[0156] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0157] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium, which, when executed, executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, disks or optical disks.

[0158] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable an electronic device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.

[0159] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A data transmission method, characterized in that: applied to a first device; The first device is configured with a multi-core processor; the method comprises: When there is data to be sent in the multi-core processor, first information corresponding to the data to be sent is written into the circular buffer area corresponding to the first core in the shared memory; the first core represents the core where the data to be sent exists; the first information is used to describe the corresponding data to be sent; each core of the multi-core processor is configured with at least two corresponding circular buffer areas in the shared memory; the at least two circular buffer areas include a high-priority circular buffer area and a low-priority circular buffer area, wherein the high-priority circular buffer area is used to store the first information corresponding to the high-priority data to be sent, and the low-priority circular buffer area is used to store the first information corresponding to the low-priority data to be sent; The setting core of the multi-core processor determines that the data to be sent exists; the setting core is any core of the multi-core processor, which is used to execute the proxy function; When it is detected that the direct memory access DMA is idle, the setting core starts the DMA chain to send the to-be-sent data to an external device based on a scan result of the shared memory; the external device is a field programmable gate array FPGA.

2. The data transmission method according to claim 1, characterized in that: When writing first information corresponding to the data to be sent into the circular buffer area corresponding to the first core in the shared memory, the method includes: The first core calls a set interface function and transmits the first information corresponding to the data to be sent to the set interface function; wherein, The set interface function is used to write the first information into the corresponding circular buffer area in the shared memory.

3. The method according to claim 1 or 2, characterized in that: The step of writing first information corresponding to the data to be sent into the circular buffer area corresponding to the first core in the shared memory includes: Determine a first priority; the first priority represents a sending priority of the data to be sent; Writing first information corresponding to the data to be sent into a first circular buffer area of ​​at least two circular buffer areas corresponding to the first core; wherein, The first circular buffer area is used to write first information corresponding to the to-be-sent data of the first priority level.

4. The method according to claim 1 or 2, characterized in that: The setting core of the multi-core processor determines that there is data to be sent, including: When receiving an inter-core interrupt signal, the setting core determines that there is data to be sent; wherein the inter-core interrupt signal is sent by the first core, indicating that the data to be sent is written into the circular buffer area corresponding to the first core; and / or, The setting core scans each circular buffer area in the shared memory at a set time interval, and determines that there is data to be sent when it is found that the data to be sent corresponding to the first information in the circular buffer area has not been sent.

5. The data transmission method according to claim 1, characterized in that: When the setting core starts the DMA chain to send data to be sent based on the scanning result of the shared memory, the method includes: When the first sequence number and the second sequence number in the scanned circular buffer area are inconsistent, the setting core starts the DMA chain to send the data to be sent; wherein, The first sequence number represents a sequence number corresponding to the first information most recently written into the circular buffer; the second sequence number represents a sequence number corresponding to the first information most recently read by the setting core in the circular buffer.

6. The data transmission method according to claim 1, characterized in that: The first information includes at least one of the following: The starting address of the data to be sent; The destination address of the data to be sent; The length of the data to be sent.

7. The data transmission method according to claim 1, characterized in that: The method further comprises: When an abnormality occurs in the set core, a new set core is determined from among all the cores of the multi-core processor based on the set order.

8. A data sending device, characterized in that: The device comprises: A writing unit, used for writing first information corresponding to the data to be sent to the circular buffer area corresponding to the first core in the shared memory when there is data to be sent in the multi-core processor; the first core represents the core where the data to be sent exists; the first information is used to describe the corresponding data to be sent; each core of the multi-core processor is configured with at least two corresponding circular buffer areas in the shared memory; the at least two circular buffer areas include a high-priority circular buffer area and a low-priority circular buffer area, wherein the high-priority circular buffer area is used to store the first information corresponding to the data to be sent with a high priority, and the low-priority circular buffer area is used to store the first information corresponding to the data to be sent with a low priority; A determination unit, configured for a setting core of the multi-core processor to determine that the data to be sent exists; the setting core is any core of the multi-core processor, configured to execute a proxy function; The startup unit is used for, when the DMA is detected to be idle, the setting core starts the DMA chain to send the data to be sent to the external device based on the scanning result of the shared memory; the external device is a field programmable gate array FPGA.

9. An electronic device, characterized in that: include: A processor and a memory for storing a computer program that can be executed on the processor, wherein: When the processor is used to run the computer program, the steps of the method according to any one of claims 1 to 7 are performed.

10. A 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 7 are implemented.