Inter-core communication method and system for multi-core heterogeneous relay protection device based on shared memory
By employing shared memory and a ring data queue in the relay protection device, the problems of limited external bus bandwidth and high latency are solved, achieving efficient and reliable inter-core data transmission and clock synchronization, and reducing hardware costs.
Patent Information
- Application Number
- CN202611431290.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-15
- Publication Date
- 2026-11-27
AI Technical Summary
In existing relay protection devices, the external bus bandwidth is limited, the transmission delay is high, and it is susceptible to electromagnetic interference, which increases hardware costs. Furthermore, it cannot directly share the memory address space, affecting data real-time performance and reliability.
By using shared memory instead of an external bus, and by dividing the processor into shared memory regions and configuring them to disable caching, direct data interaction between the protection core and the management core is achieved. A circular data queue and timestamp mechanism are used, with the protection core serving as the sole clock source for inter-core synchronization.
It achieves high-speed, low-latency, and interference-resistant data transmission, reduces hardware costs, improves the security and reliability of data transmission, and fully covers the data interaction needs throughout the entire life cycle of the device.
Smart Images

Figure CN123178123A_ABST
Abstract
Description
Technical Field
[0001] This invention mainly relates to the field of relay protection technology, specifically to a method and system for inter-core communication in a multi-core heterogeneous relay protection device based on shared memory. Background Technology
[0002] Existing relay protection devices typically employ multi-core heterogeneous processors supporting asymmetric multiprocessing (AMP). One core is configured as the protection core, running the protection algorithm program in bare-core mode, responsible for analog signal sampling, protection logic discrimination, and relay trip output execution. The remaining cores are configured as management cores, running non-real-time operating systems such as Linux, responsible for non-real-time tasks such as action report generation, waveform recording, display, communication, and serial port printing. During the device's power-on initialization phase, the two cores need to exchange configuration information. During the protection operation phase, the sampling data, input data, and protection action flags generated by the protection core in each fixed interrupt cycle need to be reported to the management core in real time. At the same time, the management core needs to issue commands such as accuracy correction coefficients, setting modifications, and remote control to the protection core. In terms of clock synchronization, the management core also needs to synchronize external time information such as IEC103, IEC61850, and NTP to the protection core.
[0003] Existing solutions mostly use external buses such as SPI, PCIe, and parallel ports to achieve data communication between dual cores, which has the following shortcomings: First, the bandwidth of the external bus is limited, making it difficult to meet the real-time transmission of high-density sampling data generated by the protection core in each interrupt cycle; Second, the external bus has high transmission latency and is susceptible to electromagnetic interference, affecting the determinism and reliability of protection actions; Third, the external bus requires dedicated hardware interfaces and increases PCB routing, raising the hardware cost of the device; Fourth, the external bus method cannot directly share the same physical memory address space, requiring additional protocol layers for framing and deframing, further increasing protocol overhead and processor load. Summary of the Invention
[0004] To address the technical problems existing in the prior art, this invention provides a method and system for inter-core communication of multi-core heterogeneous relay protection devices based on shared memory, which eliminates the overhead of external bus and frame assembly / disassembly while ensuring data real-time performance and determinism.
[0005] To solve the above-mentioned technical problems, the technical solution proposed by this invention is as follows: A method for inter-core communication in a multi-core heterogeneous relay protection device based on shared memory is disclosed. The relay protection device employs a processor supporting asymmetric multiprocessing (AMP) multi-core heterogeneity, where one core is configured as a protection core running the protection algorithm program in bare-core mode, and the remaining cores are configured as management cores running a non-real-time operating system. The communication method includes: Dual-core synchronization phase: A shared memory region is partitioned in the processor's physical memory, and the shared memory region is configured to disable caching. After the protection core starts, it blocks reading the dual-core synchronization flag data area in the shared memory region. After the management core process starts, it writes a first preset value to the dual-core synchronization flag data area and waits for the protection core to write a second preset value. After the protection core reads the first preset value, it writes the second preset value, triggering the management core and the protection core to synchronize and enter the dual-core initialization phase. Dual-core initialization phase: The management core receives variable attribute information reported by the protection core through the low-frequency instruction data area in the shared memory region; the management core constructs a bidirectional memory data mapping table based on the variable attribute information and the pre-stored configuration file, and sends the bidirectional memory data mapping table to the protection core through the low-frequency instruction data area; the bidirectional memory data mapping table is used to determine the data content represented by each byte of each queue member in the high-frequency interrupt queue data area; During the protection operation phase: In each interrupt cycle, the protection core constructs sampling data according to the bidirectional memory data mapping table, adds a sampling timestamp, writes it into the high-frequency interrupt queue data area in the shared memory region, and reads the operation parameters issued by the management core through the high-frequency interrupt queue data area; the management core reads all the sampling data from the high-frequency interrupt queue data area at a fixed period and generates event reports and / or waveform data according to the sampling timestamp. Clock synchronization phase: Using the protection core as the sole clock source, the protection core writes the latest clock data to the clock synchronization data area in the shared memory region during each interrupt cycle and accumulates the cumulative interrupt count of the protection core; the management core determines the operating status of the protection core based on the cumulative interrupt count and reads the latest clock data from the clock synchronization data area as the time reference for the management core itself.
[0006] Preferably, the shared memory region is contiguous in physical address and is further divided into four functional sub-regions: a dual-core synchronization flag data region for dual-core startup synchronization handshake; a low-frequency instruction data region for transmitting initialization information, remote control instructions, setting modification and debugging data; a high-frequency interrupt queue data region for transmitting sampling data and operating parameters with high real-time requirements; and a clock synchronization data region for inter-core clock synchronization.
[0007] Preferably, the low-frequency instruction data area includes two independent ring data buffers: a ring data buffer for protecting the core write and managing the core read, and a ring data buffer for managing the core write and protecting the core read. Each ring data buffer is configured with an independent read pointer and a write pointer. Each frame of instruction data is composed of source address, main type, subtype, payload length, and payload data concatenated sequentially.
[0008] Preferably, the high-frequency interrupt queue data area includes two circular data queues: a protection core write-to-management core read-to-circular data queue and a management core write-to-protection core read-to-circular data queue, with a total of four read / write pointers. Each queue member has its variable number, type, and arrangement order fixed according to the bidirectional memory data mapping table, and sequentially contains a sampling microsecond timestamp and several memory mapping table data items. The protection core and the management core can directly read addresses without framing or splitting frames through the bidirectional memory data mapping table.
[0009] Preferably, the clock synchronization data area includes four fields: management verification time flag, management verification time clock, protection core interruption count, and protection verification time clock; the source of the management verification time flag includes at least one of IEC103 communication time synchronization, IEC61850 communication time synchronization, NTP time synchronization, and LCD panel time modification; the time precision of both the management verification time clock and the protection verification time clock includes year, month, day, hour, minute, second, millisecond, and microsecond.
[0010] Preferably, during the clock synchronization phase, when the management core receives an external time synchronization signal, it writes the external time synchronization clock and a valid time synchronization flag into the clock synchronization data area; after the protection core detects the valid time synchronization flag during the interrupt cycle, it synchronizes the protection core's time clock with the external time synchronization clock and clears the valid time synchronization flag.
[0011] Preferably, the first preset value is 0x55AA, and the second preset value is 0xAA55; the dual-core synchronization flag data area is a 4-byte independently readable and writable area, and the protection core is in a blocked waiting state when it does not read the first preset value.
[0012] Preferably, during the protection operation phase, after reading all the sampled data, the management core generates an action report, an event sequence record (SOE), and a fault waveform file in sequence according to the sampling timestamp of each sampled data; the protection core receives the accuracy correction coefficient issued by the management core through the protection core write-protection-read ring data queue.
[0013] Preferably, the shared memory region is marked as non-cacheable in the processor's MMU to avoid cache coherency issues between the protection core and the management core; the management core accesses the shared memory region by mapping it to the virtual memory space of the management core process through memory mapping, and the protection core directly accesses the shared memory region through a preset physical address and pointer.
[0014] The present invention also discloses an inter-core communication system for a multi-core heterogeneous relay protection device based on shared memory, comprising an interconnected memory and a processor, wherein the memory stores a computer program, and the computer program executes the steps of the method described above when run by the processor.
[0015] Compared with the prior art, the advantages of the present invention are as follows: This invention uses shared memory instead of external bus communication to achieve faster transmission speeds, lower communication latency, reduced communication interference, and improved data transmission security. It does not involve external hardware wiring, saving costs. Through a high-speed data queue, a non-real-time Linux system can fully acquire each protected sampled data and build reports and SOE data.
[0016] This invention uses shared memory to simulate a physical bus for data transmission, enabling high-speed, low-latency transmission of large amounts of data; it employs a circular data queue and timestamps for reliable and stable data transmission; and it uses a protected core as a clock source, with time setting and clock synchronization via shared memory, achieving low-latency inter-core clock synchronization.
[0017] This invention achieves high-speed, low-latency, and interference-resistant data communication between the protection core and the management core by dividing the physical memory into shared memory regions and disabling cacheable functions, adopting a four-functional sub-region structure, a ring data area + read / write pointer pairs, a bidirectional memory data mapping table, and a single clock source for the protection core. It can fully cover the bidirectional data interaction needs of the relay protection device throughout its entire life cycle of startup synchronization, initialization, operation, and clock synchronization. Attached Figure Description
[0018] Figure 1 This is a schematic diagram of the structure of the low-frequency instruction data area in an embodiment of the present invention.
[0019] Figure 2 This is a schematic diagram of the structure of the high-frequency interrupt queue data area in an embodiment of the present invention.
[0020] Figure 3 This is a schematic diagram of the clock synchronization data area in an embodiment of the present invention.
[0021] Figure 4 This is a timing flowchart of dual-core communication in an embodiment of the present invention. Detailed Implementation
[0022] The present invention will be further described below with reference to the accompanying drawings and specific embodiments.
[0023] like Figure 4As shown in the embodiment of the present invention, the inter-core communication method for multi-core heterogeneous relay protection devices based on shared memory is applicable to relay protection devices employing multi-core heterogeneous processors supporting asymmetric multiprocessing (AMP). One core in the processor is configured as a bare core, running the protection algorithm program as the protection core, while the remaining cores are configured as management cores, running the Linux operating system. The protection core is mainly responsible for sampling analog and digital input data, determining protection logic, and executing relay trip outputs; the management core generates action reports and fault waveforms by analyzing the data from the protection core, and also needs to perform display, communication, and serial port printing functions.
[0024] To achieve reliable data interaction between the two cores, this embodiment uses shared memory as the data interaction channel and divides the method into four sequentially connected execution phases: dual-core synchronization phase, dual-core initialization phase, protection operation phase, and clock synchronization phase. Each phase is connected via bidirectional data flow through the shared memory region, forming a complete data communication loop. The specific details of each phase are as follows: Dual-core synchronization phase. For example... Figure 4 As shown, after the device powers on, the processor allocates a contiguous shared memory region from its physical memory as a dual-core data interaction area. This region is configured as non-cacheable in the MMU to avoid cache coherency issues between the protection core and the management core. The management core program accesses this shared memory region by mapping it to the virtual address space of the management core process through the kernel's memory mapping mechanism. The protection core, running in bare-core mode, accesses the shared memory region directly through pre-agreed physical addresses and pointers without going through MMU address translation. The shared memory region is further divided into four functional sub-regions: dual-core synchronization flag data area, low-frequency instruction data area, high-frequency interrupt queue data area, and clock synchronization data area.
[0025] Within the four functional sub-areas, the dual-core synchronization flag data area is a 4-byte independently readable and writable region specifically used for dual-core startup synchronization handshake. The specific synchronization handshake process is as follows: after the protection core starts, it blocks and reads the dual-core synchronization flag data area; after the management core process starts, it writes a first preset value (0x55AA) to this data area and waits in a loop for the protection core to write a second preset value; after the protection core reads the first preset value (0x55AA), it writes the second preset value (0xAA55) to this data area, triggering the management core and protection core to synchronize and enter the dual-core initialization phase. If the first preset value is not read, the protection core remains in a blocked waiting state.
[0026] Dual-core initialization phase: After the dual-core synchronous handshake is completed, the protection core registers protection information (i.e., attribute information of each variable on the protection core side, including variable name, type, length, access attributes, etc.) with the management core through the low-frequency instruction data area. After receiving the variable attribute information, the management core constructs a bidirectional memory data mapping table in conjunction with the pre-stored device configuration file, and sends the bidirectional memory data mapping table to the protection core through the low-frequency instruction data area. This bidirectional memory data mapping table is used to determine the data content represented by each byte of each queue member in the high-frequency interrupt queue data area.
[0027] like Figure 1 As shown, the low-frequency instruction data area includes two independent ring-shaped data buffers: a ring-shaped data buffer for writing from the protection core to the management core and a ring-shaped data buffer for writing from the management core to the protection core. Each ring-shaped data buffer is configured with independent read and write pointers, maintained by the corresponding core. Each frame of instruction data is constructed by sequentially concatenating the source address, main type, subtype, payload length, and payload data, and is stored in the corresponding buffer frame by frame during transmission. The low-frequency instruction data area is mainly used to transmit low-frequency instruction data such as initialization information, remote control commands, setting modification commands, and debugging output commands issued by the management core to the protection core, as well as initialization board information and instruction execution result data returned by the protection core to the management core. The design of two independent buffers with corresponding read and write pointers effectively avoids dual-core access conflicts.
[0028] Protection operation phase. For example... Figure 2 As shown, during the protection operation phase, the high-frequency interrupt queue data area includes two circular data queues: a circular data queue for protection core to write to management core and a circular data queue for management core to write to protection core. A total of four read / write pointers are configured, each independently maintained by its corresponding core. Each queue member has its variable number, type, and arrangement order fixed according to the bidirectional memory data mapping table issued during the initialization phase, and sequentially contains a sampling microsecond timestamp and several memory mapping table data items. Data in each queue member does not require framing or deframing; the management core and protection core directly read the buffer by address through the bidirectional memory data mapping table, significantly improving data transmission efficiency.
[0029] Within each interrupt cycle, the protection core constructs high-speed sampling data for the current cycle based on a bidirectional memory data mapping table. This includes analog sampling data, input data, protection action flags, etc. The sampling data is then appended with a microsecond timestamp and written to the protection core's write-to-management-core read-to-circular data queue. Simultaneously, the protection core reads operating parameters such as accuracy correction coefficients issued by the management core from the management core's write-to-protection-core read-to-circular data queue. Since the Linux operating system on the management core is not a real-time operating system, its scheduling cycle cannot precisely follow the interrupt cycle of the protection core. Using a circular data queue in conjunction with sampling timestamps ensures no data loss. The management core only needs to read all sampling data from the protection core's write-to-management-core read-to-circular data queue at its own fixed cycle. Then, based on the sampling timestamp of each sampled data, it sequentially generates action reports, Sequence of Events (SOE) records, and fault waveform files.
[0030] Clock synchronization phase. In this embodiment, the protection core is used as the sole clock source, and the clock reference for the entire device is provided by the protection core. For example... Figure 3 As shown, the clock synchronization data area includes four fields: management check time flag, management check time clock, protection core interruption count, and protection core check time clock. The management check time flag can be sourced from at least one of IEC103 communication time synchronization, IEC61850 communication time synchronization, NTP time synchronization, and LCD panel time modification. The time precision of both the management check time clock and the protection core check time clock includes year, month, day, hour, minute, second, millisecond, and microsecond.
[0031] In the clock synchronization process, the protection core writes the latest clock data to the clock synchronization data area during each interrupt cycle and increments the interrupt count field. The management core determines whether the protection core is operating normally based on the change in the interrupt count. After confirming that the protection core is operating normally, it reads the latest clock data from the clock synchronization data area as the time reference for its own end. When the management core receives communication IEC103, IEC61850, or NTP time synchronization signals, or manual time modification operations on the LCD panel, it writes the external time synchronization clock and valid time synchronization flag into the clock synchronization data area. After detecting the valid time synchronization flag during the interrupt cycle, the protection core synchronizes its own protection core clock to the external time synchronization clock and clears the valid time synchronization flag, thus completing the closed loop of inter-core clock synchronization.
[0032] This invention uses shared memory instead of external bus communication to achieve faster transmission speeds, lower communication latency, reduced communication interference, and improved data transmission security. It does not involve external hardware wiring, saving costs. Through a high-speed data queue, a non-real-time Linux system can fully acquire each protected sampled data and build reports and SOE data.
[0033] This invention uses shared memory to simulate a physical bus for data transmission, enabling high-speed, low-latency transmission of large amounts of data; it employs a circular data queue and timestamps for reliable and stable data transmission; and it uses a protected core as a clock source, with time setting and clock synchronization via shared memory, achieving low-latency inter-core clock synchronization.
[0034] This invention achieves high-speed, low-latency, and interference-resistant data communication between the protection core and the management core by dividing the physical memory into shared memory regions and disabling cacheable functions, adopting a four-functional sub-region structure, a ring data area + read / write pointer pairs, a bidirectional memory data mapping table, and a single clock source for the protection core. It can fully cover the bidirectional data interaction needs of the relay protection device throughout its entire life cycle of startup synchronization, initialization, operation, and clock synchronization.
[0035] The present invention also discloses an inter-core communication system for a multi-core heterogeneous relay protection device based on shared memory, comprising an interconnected memory and a processor, wherein the memory stores a computer program, and the computer program executes the steps of the method described above when run by the processor.
[0036] The communication system of the present invention corresponds to the above-described communication method and also has the advantages of the above-described communication method.
[0037] The present invention can implement all or part of the processes in the methods of the above embodiments, or it can be implemented by hardware related to computer program instructions. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, it can implement the steps of the above method embodiments. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer-readable storage medium includes: any entity or device capable of carrying computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. The memory is used to store computer programs and / or modules. The processor implements various functions by running or executing the computer programs and / or modules stored in the memory, and by calling data stored in the memory. The memory may include high-speed random access memory, as well as non-volatile memory, such as hard disks, RAM, plug-in hard disks, smart media cards (SMC), secure digital (SD) cards, flash cards, at least one disk storage device, flash memory device, or other volatile solid-state storage devices.
[0038] The above are merely preferred embodiments of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be noted that for those skilled in the art, any improvements and modifications made without departing from the principles of the present invention should be considered within the scope of protection of the present invention.
Claims
1. A method for inter-core communication in a multi-core heterogeneous relay protection device based on shared memory, wherein the relay protection device employs a processor supporting asymmetric multiprocessing (AMP) multi-core heterogeneity, wherein one core is configured as a protection core running the protection algorithm program in bare-core mode, and the remaining cores are configured as management cores running a non-real-time operating system; characterized in that, Communication methods include: Dual-core synchronization phase: A shared memory region is partitioned in the processor's physical memory, and the shared memory region is configured to disable caching. After the protection core starts, it blocks reading the dual-core synchronization flag data area in the shared memory region. After the management core process starts, it writes a first preset value to the dual-core synchronization flag data area and waits for the protection core to write a second preset value. After the protection core reads the first preset value, it writes the second preset value, triggering the management core and the protection core to synchronize and enter the dual-core initialization phase. Dual-core initialization phase: The management core receives variable attribute information reported by the protection core through the low-frequency instruction data area in the shared memory region; the management core constructs a bidirectional memory data mapping table based on the variable attribute information and the pre-stored configuration file, and sends the bidirectional memory data mapping table to the protection core through the low-frequency instruction data area; the bidirectional memory data mapping table is used to determine the data content represented by each byte of each queue member in the high-frequency interrupt queue data area; During the protection operation phase: In each interrupt cycle, the protection core constructs sampling data according to the bidirectional memory data mapping table, adds a sampling timestamp, writes it into the high-frequency interrupt queue data area in the shared memory region, and reads the operation parameters issued by the management core through the high-frequency interrupt queue data area; the management core reads all the sampling data from the high-frequency interrupt queue data area at a fixed period and generates event reports and / or waveform data according to the sampling timestamp. Clock synchronization phase: Using the protection core as the sole clock source, the protection core writes the latest clock data to the clock synchronization data area in the shared memory region during each interrupt cycle and accumulates the cumulative interrupt count of the protection core; the management core determines the operating status of the protection core based on the cumulative interrupt count and reads the latest clock data from the clock synchronization data area as the time reference for the management core itself.
2. The inter-core communication method for a multi-core heterogeneous relay protection device based on shared memory according to claim 1, characterized in that, The shared memory region is contiguous in physical address and is further divided into four functional sub-regions: a dual-core synchronization flag data region for dual-core startup synchronization handshake; a low-frequency instruction data region for transmitting initialization information, remote control instructions, setting modification and debugging data; a high-frequency interrupt queue data region for transmitting sampling data and operating parameters with high real-time requirements; and a clock synchronization data region for inter-core clock synchronization.
3. The inter-core communication method for a multi-core heterogeneous relay protection device based on shared memory according to claim 2, characterized in that, The low-frequency instruction data area includes two independent ring data buffers: a ring data buffer for protecting the core write and managing the core read, and a ring data buffer for managing the core write and protecting the core read. Each ring data buffer is configured with independent read and write pointers. Each frame of instruction data is composed of source address, main type, subtype, payload length, and payload data concatenated in sequence.
4. The inter-core communication method for a multi-core heterogeneous relay protection device based on shared memory according to claim 2, characterized in that, The high-frequency interrupt queue data area includes two circular data queues: a circular data queue for writing to the protection core and reading from the management core, and a circular data queue for writing to the management core and reading from the protection core. A total of four read / write pointers are configured. Each queue member has its variable number, type, and arrangement order fixed according to the bidirectional memory data mapping table, and sequentially contains a sampling microsecond timestamp and several memory mapping table data items. The protection core and the management core can directly read addresses without framing or splitting frames through the bidirectional memory data mapping table.
5. The inter-core communication method for a multi-core heterogeneous relay protection device based on shared memory according to claim 2, characterized in that, The clock synchronization data area includes four fields: management verification time flag, management verification time clock, protection core interruption count, and protection verification time clock. The source of the management verification time flag includes at least one of IEC103 communication time synchronization, IEC61850 communication time synchronization, NTP time synchronization, and LCD panel time modification. The time precision of both the management verification time clock and the protection verification time clock includes year, month, day, hour, minute, second, millisecond, and microsecond.
6. The inter-core communication method for a multi-core heterogeneous relay protection device based on shared memory according to any one of claims 1-5, characterized in that, During the clock synchronization phase, when the management core receives an external time synchronization signal, it writes the external time synchronization clock and the valid time synchronization flag into the clock synchronization data area; after the protection core detects the valid time synchronization flag during the interrupt cycle, it synchronizes the protection core's time clock with the external time synchronization clock and clears the valid time synchronization flag.
7. The inter-core communication method for a multi-core heterogeneous relay protection device based on shared memory according to any one of claims 1-5, characterized in that, The first preset value is 0x55AA, and the second preset value is 0xAA55; the dual-core synchronization flag data area is a 4-byte independently readable and writable area, and the protection core is in a blocked waiting state when it does not read the first preset value.
8. The inter-core communication method for a multi-core heterogeneous relay protection device based on shared memory according to any one of claims 1-5, characterized in that, During the protection operation phase, after reading all the sampled data, the management core generates an action report, an event sequence record (SOE), and a fault waveform file in sequence according to the sampling timestamp of each sampled data. The protection core receives the accuracy correction coefficient issued by the management core through the protection core's write-protection-read ring data queue.
9. The inter-core communication method for a multi-core heterogeneous relay protection device based on shared memory according to any one of claims 1-5, characterized in that, The shared memory region is marked as non-cacheable in the processor's MMU to avoid cache coherency issues between the protection core and the management core. The management core accesses the shared memory region by mapping it to the virtual memory space of the management core process through memory mapping, while the protection core accesses the shared memory region directly through a preset physical address and pointer.
10. A multi-core heterogeneous relay protection device inter-core communication system based on shared memory, comprising interconnected memory and processor, wherein the memory stores a computer program, characterized in that, The computer program, when run by a processor, performs the steps of the method as described in any one of claims 1-9.
