A real-time system three-copy separation redundant memory management method, device and medium

CN122431910BActive Publication Date: 2026-09-08成都菁蓉联创科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610913616.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-06-24
Publication Date
2026-09-08
Estimated Expiration
2046-06-24

AI Technical Summary

Technical Problem

[0004]针对现有技术中的上述不足,本发明提供的一种实时系统三副本分离冗余内存管理方法、装置及介质,解决了现有三副本分离冗余内存管理方法中三份副本可能被同一局部破坏同时影响、进行三份全量精确比较带来较大开销以及缺乏统计与巡检能力导致难以定位与闭环的问题

Benefits of technology

S201、响应于内存分配请求,利用位图管理对空闲块进行寻找,获取空闲块索引并进行置位;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122431910B_ABST
    Figure CN122431910B_ABST
Patent Text Reader

Abstract

The application provides a real-time system three-copy separation redundant memory management method, device and medium, and belongs to the technical field of computer memory management. The method comprises the following steps: obtaining address information of a user, initializing a three-copy separation storage area, arranging data items according to block indexes, obtaining arranged three copies, and setting a preset addressing relationship; in response to a memory allocation request, locating a free block index through a bitmap and setting a bit, establishing handle metadata, clearing the three copies and writing magic words; in response to a write request, calculating three-copy addresses according to the addressing relationship, synchronously copying data and writing double-field magic words to obtain a written three-copy area; in response to a read request, positioning the three-copy area to be read by using the preset addressing relationship, checking and calculating a checksum by matching, and obtaining a consistency result by accurate comparison. The application realizes the reliability improvement, performance improvement and operation and maintenance enhancement of three-copy separation redundant memory management.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer memory management technology, and in particular relates to a method, device and medium for managing redundant memory with three copies separated in a real-time system. Background Technology

[0002] In real-time systems, critical memory data (such as system configuration, running status, communication session status, counters, and critical entries) may lead to incorrect decisions or system failures when affected by bit flips, out-of-bounds writes, or direct memory access from peripherals. To reduce the risk of single-point data corruption, engineering often adopts redundant storage and majority consensus decision-making schemes.

[0003] However, the classic "triple redundancy or majority voting" still has three common difficulties in engineering implementation: First, if the three copies are in the same fault domain, they may be affected by the same local damage at the same time; second, each read requires a full and accurate comparison of the three copies, which will bring a large overhead; and third, the lack of statistical and inspection capabilities will make it difficult to locate and close the loop on the problem. Summary of the Invention

[0004] To address the aforementioned shortcomings in existing technologies, this invention provides a method, apparatus, and medium for managing redundant memory with three copies in a real-time system. This solves the problems in existing methods where all three copies may be simultaneously affected by damage to the same local area, the high overhead of performing a full and accurate comparison of all three copies, and the difficulty in locating and closing the loop due to a lack of statistical and inspection capabilities.

[0005] To achieve the above objectives, the technical solution adopted by this invention is: a method for managing redundant memory with three replicas in a real-time system, comprising the following steps: S1. Based on the real-time system, set up a redundant memory management structure containing three replica separate storage areas, obtain the user address information, initialize the three replica separate storage areas, and arrange the data items of each replica area at equal intervals according to the block index to obtain the arranged three replicas, and set the preset addressing relationship. S2. In response to the memory allocation request, use bitmap management to obtain the free block index and set it, and establish handle metadata. Clear the data area of ​​the three copies arranged and write the magic word to obtain the three copies allocated in memory. S3. In response to the write request, based on the handle metadata and the three copies allocated in memory, select three copies and use the preset addressing relationship to write the source cache data and the double-field magic word to the three selected copies by calculating the starting address of the data area and the magic word address, thus obtaining the written three-copy area. S4. In response to the read request, obtain the block index and block specification type based on the handle metadata, and locate the three replica regions to be read based on the written three replica regions and the preset addressing relationship. Check and calculate the checksum through double-field magic word matching, and accurately compare the replica regions with equal checksums to obtain a consistency result, thus completing the separation of redundant memory management.

[0006] The beneficial effects of this invention are as follows: This invention solves the problems of existing three-replica separated redundant memory management methods, such as the possibility that the three replicas may be simultaneously affected by the same local damage, the large overhead of performing a full and accurate comparison of the three replicas, and the difficulty in locating and closing the loop due to the lack of statistical and inspection capabilities. These problems are addressed by using a three-replica separated storage layout, data item layout and index addressing, boundary magic word access control, hierarchical consistency determination, and statistical and inspection interfaces.

[0007] Further, S1 includes the following steps: S101. Based on the real-time system, a memory pool is established for each block size, and three independent address segments are configured for each memory pool that are physically separate, resulting in a three-copy separate storage area. A redundant memory management structure containing the three-copy separate storage area is also set up. S102. Obtain the user address information. In response to the user address information not having a custom address, the three replica addresses are read by using the linker script symbol. The three replica separate storage areas are initialized to obtain the three replica addresses. In response to the user's address information containing a custom address, the redundant memory is configured by setting the replica address, the three replicas are placed in different physical memory attribute areas, the three replicas are initialized in separate storage areas, and three replica addresses are obtained. S103. Obtain the three initialized replicas based on the three replica addresses; S104. Based on the initialized three replicas, the data items in each replica area are arranged at equal intervals according to the block index to obtain the arranged three replicas. S105. Based on the starting address of the replica area, the block index, and the span of a single data item, a preset addressing relationship is set.

[0008] The beneficial effects of the above-mentioned further solutions are as follows: By adopting a symmetrical layout of three peer copies in three independent address segments and synchronous addressing under the same index, the present invention reduces the risk of the same fault domain, and reduces the allocation and release overhead through pooling and bitmap allocation.

[0009] Furthermore, S2 includes the following steps: S201. In response to a memory allocation request, use bitmap management to search for free blocks, obtain the free block index and set it. S202. By recording the block specification type and block index, handle metadata is established, and the data area of ​​the three copies arranged is cleared and written to the magic word. Combined with the set free blocks, the three copies allocated in memory are obtained.

[0010] The beneficial effects of the above-mentioned further solutions are as follows: This invention ensures that block indexes, block specifications, and three-replica addressing form a closed loop through pooling management, bitmap allocation, and the establishment of handle metadata. This ensures that subsequent writes, reads, access control checks, hierarchical judgments, and error correction write-backs only apply to allocated and valid data blocks, avoiding erroneous operations on unallocated or released blocks. By quickly locating and setting free blocks through bitmaps, the allocation path time is shortened and the predictability of allocation behavior is improved. By clearing the three-replica data area and writing magic words during the allocation phase, blocks that are "allocated but have not yet been written with business data" also have boundary access control conditions, reducing the risk of misjudgment and error correction due to uninitialized boundaries during subsequent reads.

[0011] Furthermore, step S3 includes the following steps: S301. In response to the write request, based on the handle metadata, the handle is validated using the handle magic word and allocation flags to obtain the block index and block specification type. S302. Based on the three copies allocated in memory, locate the copy area to be written according to the block index and block specification type, and select the three copies that have the same block index. S303. Using the preset addressing relationship, calculate the starting address and magic word address of the data area of ​​the three selected copies; S304. Synchronously copy the source cache data to the data area of ​​the three selected copies, and write the two-field magic word containing data identifier and boundary protection to the magic word area of ​​the three selected copies to obtain the written three-copy area.

[0012] The beneficial effects of the above-mentioned further solutions are as follows: By validating the handle and obtaining the block index and block specification type before writing, this invention ensures that the block management information established during the writing operation and allocation phase is consistent, avoiding incorrect addressing caused by illegal handles; by synchronously locating and writing data and double-field magic words to three copies of the same block index, the three copies are kept consistent in terms of data content and boundary protection information, providing a consistent premise for the magic word gate and hierarchical consistency determination of the subsequent read path; by fixing the magic word at the end of the data area and calculating the magic word address with a preset addressing relationship, the boundary integrity check can be completed quickly under a determined address, which helps to reduce read path overhead and improve engineering feasibility.

[0013] Furthermore, S4 includes the following steps: S401. In response to the read request, the block index and block specification type are obtained by parsing the handle. Based on the written three-copy area, the copy area to be read is located to obtain the three-copy area to be read. S402. By sequentially matching and checking the double-field magic words of the three replica regions to be read, in response to any invalid replica magic word, set the separated redundant memory management information containing the return error code and terminating the reading, and proceed to step S406. In response to the simultaneous matching of the double-field magic words of the three copy regions to be read, proceed to step S403; S403. By calculating the checksum of each of the three replica regions to be read, a combination of replica regions with equal checksums is obtained. S404. By comparing the replica region combinations with equal checksums, a majority consensus judgment is performed on the replica region combinations to obtain a consistency result. S405. Based on the consistency results, generate separate redundant memory management information; S406. Complete the separation of redundant memory management based on the separation of redundant memory management information.

[0014] Furthermore, S403 includes the following steps: S4031. By treating the data in the data area of ​​each of the three replica regions to be read as a 32-bit unsigned integer array, the data in the data area of ​​each of the three replica regions to be read is accumulated word by word to obtain the initial accumulated data. S4032. The last few bytes of the initially accumulated data that are less than 4 bytes are accumulated byte by byte using an 8-bit unsigned integer array to obtain three checksums; S4033. By comparing three checksums, select the combination of replica regions with equal checksums.

[0015] The beneficial effects of the above-mentioned further solutions are as follows: By adopting a fast checksum calculation method that accumulates 32-bit words and remainder bytes, the present invention can perform initial screening of three copies of data with low computational overhead, quickly eliminating a large number of impossible combinations; and by comparing the three checksums to screen candidate consistent combinations, the subsequent precise comparison only applies to candidate combinations, thereby reducing the trigger ratio of full precise comparison of the three copies of data and the CPU overhead of the reading path, which is conducive to meeting the performance budget of real-time systems.

[0016] Furthermore, S404 specifically refers to: By performing a byte-by-byte comparison on the replica regions with equal checksums, and then performing a majority consistency check on the replica regions with equal checksums, a consistency result containing both the correct replica index and the incorrect replica index is obtained.

[0017] Furthermore, S405 includes the following steps: S4051. Based on the consistency result, in response to the consistency result being consistent across three replicas, set up separate redundant memory management information that includes copying any replica data to the target cache and returning success. S4052. In response to the consistency result being consistent between the two replicas, the settings include copying the consistent replica data to the target cache, repairing the inconsistency by writing back the consistent replica data to overwrite the inconsistent replica, and updating the separated redundant memory management information of the error correction statistics. S4053. In response to a consistency result where all three replicas are inconsistent, set up separate redundant memory management information that includes returning uncorrectable errors and updating error statistics.

[0018] The beneficial effects of the above-mentioned further solutions are as follows: This invention generates different separated redundant memory management information based on the consistency results, thereby achieving closed-loop processing of the read path: when all three replicas are consistent, data is returned directly without additional write-back, reducing write amplification; when two replicas are consistent, consistent data is returned and inconsistent replicas are written back to repair, achieving self-healing and reducing long-term accumulation of inconsistencies; when all three replicas are inconsistent, uncorrectable errors are returned and error statistics are updated, facilitating the upper layer to adopt security strategies, enter a safe state, trigger inspections or alarms, and complete the operation and maintenance closed loop; at the same time, through the updating of error correction statistics and error statistics, reliability behavior becomes quantifiable and traceable.

[0019] To achieve the above objectives, the present invention also provides a real-time system three-copy separation redundant memory management device, including a memory, a processor, and a program stored in the memory, wherein the processor executes the program to implement the method described above.

[0020] To achieve the above objectives, the present invention also provides a storage medium having a program stored thereon, which, when executed, implements the method described thereon.

[0021] The beneficial effects of the above-mentioned further solutions are as follows: This invention achieves improved reliability, performance, and enhanced maintainability of three-replica separated redundant memory management through three-replica separated storage layout, data item layout and index addressing, boundary magic word gate, hierarchical consistency determination, two-consistency self-healing write-back, and statistics and inspection interfaces. Attached Figure Description

[0022] Figure 1 This is a flowchart of the method of the present invention.

[0023] Figure 2 This is a schematic diagram of the overall structure of the redundant memory management structure in this embodiment.

[0024] Figure 3 This is a schematic diagram of the data item layout within a single copy area in this embodiment.

[0025] Figure 4 This is a timing diagram for the layered verification and decision-making in this embodiment.

[0026] Figure 5 This is a schematic diagram of self-healing write-back when the consistency result of the two copies is consistent in this embodiment. Detailed Implementation

[0027] The specific embodiments of the present invention are described below to enable those skilled in the art to understand the present invention. However, it should be understood that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, various changes are obvious as long as they are within the spirit and scope of the present invention as defined and determined by the appended claims. All inventions utilizing the concept of the present invention are protected.

[0028] Before describing this embodiment, the following terms will be explained: API: Application Programming Interface.

[0029] Example 1 like Figure 1 As shown, this invention provides a method for managing redundant memory with three replicas in a real-time system, the implementation of which is as follows: S1. Based on the real-time system, a redundant memory management structure with three separate storage regions for each replica is set up. The address information of the user is obtained, the three separate storage regions for each replica are initialized, and the data items of each replica region are arranged at equal intervals according to the block index to obtain the arranged three replicas. The preset addressing relationship is then set. The specific steps are as follows: S101. Based on the real-time system, a memory pool is established for each block size, and three independent address segments that are physically separate are configured for each memory pool to obtain a three-copy separate storage area. A redundant memory management structure containing the three-copy separate storage area is set up.

[0030] In this embodiment, as Figure 2 As shown, the redundant memory management scheme generally consists of an application layer, a redundant memory API layer, a redundant memory management control structure, and a three-replica separated storage area, and their logical relationship is as follows: At the application layer, critical data (such as configuration, status, counters, etc.) in real-time systems are initialized, allocated, written, read, and released through redundant memory APIs. The redundant memory API layer provides interfaces such as Init, Alloc, Write, Read, and Free to shield the details of the three-copy mechanism and provide a unified redundant data block handle to the upper layer. The Redundant Memory Management Control Structure (CTRL) is used to maintain redundant memory control structures on the kernel side, and is used to centrally manage the following structures: Multi-specification memory pools (e.g., 64B / 128B / 4KB block sizes); Allocation bitmap (used for allocation / release of block index blockIdx); Handle metadata (records sizeType, blockIdx, read / write / error correction statistics, etc.); Global statistics (number of reads, number of writes, number of corrected errors, number of uncorrectable errors, and number of magic word errors, etc.); Concurrency protection lock (spin locks can be used in multi-core scenarios, and interrupt shielding can be used in single-core scenarios); The multi-specification memory pools POOL64 / POOL128 / POOL4K are established separately for different block sizes to reduce fragmentation and provide deterministic allocation / release behavior; each memory pool is configured with three peer replicas, which are mapped to... Figure 2 The first replica region Replica0, the second replica region Replica1, and the third replica region Replica2; The three replicas are stored in separate storage areas Replica0 / Replica1 / Replica2. The three replicas are stored in different address ranges (the default address can be given by the symbol exported by the linker script, or set by the user before initialization) to reduce the probability that the same local damage will affect all three replicas at the same time. For the same logical block index blockIdx, there is a one-to-one corresponding data item in each of the three areas Replica0 / Replica1 / Replica2.

[0031] S102. Obtain the user address information. In response to the user address information not having a custom address, the three replica addresses are read by using the linker script symbol. The three replica separate storage areas are initialized to obtain the three replica addresses. In response to the user's address information containing a custom address, the redundant memory is configured by setting the replica address, the three replicas are placed in different physical memory attribute areas, the three replicas are initialized in separate storage areas, and three replica addresses are obtained. S103. Obtain the three initialized replicas based on the three replica addresses; S104. Based on the initialized three replicas, the data items in each replica area are arranged at equal intervals according to the block index to obtain the arranged three replicas.

[0032] In this embodiment, each memory pool of each block size is used to configure three independent address segments as replica regions (replica 0 / 1 / 2). The three address segments are separated in terms of physical address to reduce the probability that the same local damage will affect all three replicas at the same time. Obtain the user's address information. In response to the fact that the user's address information does not have a custom address set, use the linker script symbols in the redundant memory initialization to read the three copy addresses. In response to the user's address information, three copies are placed in different physical memory attribute areas. By calling the redundant memory to set the copy address, the copy address is configured to obtain three copy addresses. Based on the three replica addresses, the data items in each replica area are arranged at equal intervals according to the block index, resulting in the arranged three replicas; like Figure 3 As shown, the data items include at least: The data area, with a length of blockSize (e.g., 64B / 128B / 4KB), is used to store user data; The magic word area, which follows the end of the data area, has a fixed size of REDUND_MAGIC_SIZE=8 bytes and corresponds to the structure struct RedundMagicGuard{U32 magic1;U32 magic2;}, which is used for boundary protection and access control judgment. The separator area, which follows the magic word area, has a fixed size of REDUND_SEPARATOR_SIZE=64 bytes and is used for isolation / reservation.

[0033] S105. Based on the starting address of the replica area, the block index, and the span of a single data item, a preset addressing relationship is set.

[0034] In this embodiment, the span of a single data item (i.e., the size of a single item within a single copy) itemSize is implemented in the code as: singleItemSize = blockSize + REDUND_MAGIC_SIZE + REDUND_SEPARATOR_SIZE; The base address of a data item corresponding to a certain index blockIdx can be obtained by the following addressing relationship: itemBase = replicaBase + blockIdx itemSize, where replicaBase is the starting address of the replica area, and itemSize is the span of a single item (including the data area, magic text area, and separator area). Based on the starting address, block index, and span of a single data item, a preset addressing relationship is set; this addressing relationship is reused uniformly in writing, reading, magic word checking, and two consistency error correction write-back, thereby ensuring that the three replica operations correspond one-to-one on the same blockIdx; Where replicaBase is the starting address of a replica region in a certain specification pool, i.e., pool->replicaAddr[replicaIdx]; blockIdx is the block index, and the same logical block shares the same blockIdx in the three replicas; itemSize or singleItemSize: The byte span of a single data item, specifically the data area + magic text area + separator area; replicaIdx is the replica index, which is either the first replica Replica0, the second replica Replica1, or the third replica Replica2.

[0035] S2. In response to the memory allocation request, using bitmap management, obtain the free block index and set it, and establish handle metadata. The data areas of the three replicas are cleared and written to a magic word to obtain the three memory-allocated replicas. The specific steps are as follows: S201. In response to a memory allocation request, use bitmap management to search for free blocks, obtain the free block index and set it. S202. By recording the block specification type and block index, handle metadata is established, and the data area of ​​the three copies arranged is cleared and written to the magic word. Combined with the set free blocks, the three copies allocated in memory are obtained.

[0036] In this embodiment, pooling management, bitmap allocation, and handle metadata creation are performed. Independent memory pools are maintained for different block sizes, and a bitmap (allocBitmap) is used to manage free / occupied blocks: the redundant data block allocation function (PRT_RedundMemAlloc()) finds and sets the free blockIdx using the bitmap-allocated free block function (OsRedundAllocBlock()); the redundant data block release function (PRT_RedundMemFree()) clears the bits using the bitmap-released block function (OsRedundFreeBlock()); the external redundant data block handle (PrtRedundHandle) actually points to the redundant data block metadata structure (struct RedundBlockMeta) of that block, which stores the block size type (sizeType) and blockIdx. When allocating blocks, the redundant data block allocation function (PRT_RedundMemAlloc()) also zeros the data area of ​​the three copies and writes a magic word to ensure that blocks that have been allocated but have not yet been written with business data also have boundary access control. Before each read / write operation, the handle validity verification function (OsRedundValidateHandle()) checks the handle magic word (metadata magic word constant REDUND_MAGIC_META) and the allocation flag to ensure that the block index, block size, and three-replica addressing form a closed loop, thereby limiting addressing, access control, judgment, and error correction to allocated and valid data blocks.

[0037] S3. In response to the write request, based on the handle metadata and the three copies allocated in memory, select three copies and, using a preset addressing relationship, calculate the starting address of the data area and the magic word address, write the source cache data and the double-field magic word into the three selected copies to obtain the written three-copy area. The specific steps are as follows: S301. In response to the write request, based on the handle metadata, the handle is validated using the handle magic word and allocation flags to obtain the block index and block specification type. S302. Based on the three copies allocated in memory, locate the copy area to be written according to the block index and block specification type, and select the three copies that have the same block index. S303. Using the preset addressing relationship, calculate the starting address and magic word address of the data area of ​​the three selected copies; S304. Synchronously copy the source cache data to the data area of ​​the three selected copies, and write the two-field magic word containing data identifier and boundary protection to the magic word area of ​​the three selected copies to obtain the written three-copy area.

[0038] In this embodiment, in response to a write request (redundant data write function PRT_RedundMemWrite(handle,srcBuf,len)), three copies of the same blockIdx are synchronously written. Specifically: Using the preset addressing relationship, calculate the starting address of the data area of ​​the three copies of the same blockIdx, and copy the source buffer srcBuf in the write request to the data area of ​​the three copies of the same blockIdx; Using a preset addressing relationship, the magic word address of the three copies of the same blockIdx is calculated. Based on the magic word address of the three copies of the same blockIdx, a double-field magic word is written to the magic word area of ​​the three copies of the same blockIdx to obtain the written three-copy area. The magic word structure uses two fields, namely data identifier and boundary protection, which are fixed at the end of the data area. This makes it easy to read the path and determine whether the boundary has been violated at a cost of O(1), thereby avoiding error correction with defects.

[0039] S4. In response to the read request, obtain the block index and block specification type based on the handle metadata, and locate the three replica regions to be read based on the written three replica regions and the preset addressing relationship. Through matching checks and calculating checksums, accurately compare the replica regions with equal checksums to obtain a consistency result, and complete the separation of redundant memory management. The specific steps are as follows: S401. In response to the read request, the block index and block specification type are obtained by parsing the handle. Based on the written three-copy area, the copy area to be read is located to obtain the three-copy area to be read. S402. By sequentially matching and checking the double-field magic words of the three replica regions to be read, in response to any invalid replica magic word, set the separated redundant memory management information containing the return error code and terminating the reading, and proceed to step S406. In response to the simultaneous matching of the double-field magic words of the three copy regions to be read, proceed to step S403; S403. By calculating the checksum of each of the three replica regions to be read, a combination of replica regions with equal checksums is obtained. Specifically: S4031. By treating the data in the data area of ​​each of the three replica regions to be read as a 32-bit unsigned integer array, the data in the data area of ​​each of the three replica regions to be read is accumulated word by word to obtain the initial accumulated data. S4032. The last few bytes of the initially accumulated data that are less than 4 bytes are accumulated byte by byte using an 8-bit unsigned integer array to obtain three checksums; S4033. By comparing three checksums, select the combination of replica regions with equal checksums; S404. By comparing replica region combinations with equal checksums, a majority consensus judgment is performed on the replica region combinations to obtain a consistency result. Specifically: By performing a byte-by-byte comparison on the replica regions with equal checksums, and then performing a majority consistency check on the replica regions with equal checksums, a consistency result containing both the correct replica index and the incorrect replica index is obtained.

[0040] In this embodiment, in response to the call to the Read(handle,len) interface, the read block index and block specification type are obtained by parsing the handle, and the data area and magic word area of ​​the written three-copy area are located according to the read block index and block specification type to obtain the three copies to be read; By sequentially checking whether the magic words of the three copies to be read match simultaneously, it is determined whether the magic words of the three copies located are valid. If not, that is, any copy magic word is invalid, it is determined that there is a risk of out-of-bounds write, stepping on the edge, or data item boundary destruction. "Magic word error" is returned directly, and the current reading process is terminated. Corresponding separation of redundant memory management information is generated, and the separation of redundant memory management is carried out through the redundant memory management control structure to avoid error correction with defects. If so, Figure 4 As shown, based on the data area addresses of the three replicas that have been located, checksums are calculated for the three data sets respectively to obtain replica area combinations with equal checksums. Then, a precise byte-by-byte comparison is performed on the candidate combinations with equal checksums to obtain the correct replica index correctIdx and the wrong replica index wrongIdx. Based on the correct replica index and the incorrect replica index, we determine majority consistency and obtain a consistency result.

[0041] S405. Based on the consistency results, generate separate redundant memory management information, specifically including the following steps: S4051. Based on the consistency result, in response to the consistency result being consistent across three replicas, set up separate redundant memory management information that includes copying any replica data to the target cache and returning success. S4052. In response to the consistency result being consistent between the two replicas, the settings include copying the consistent replica data to the target cache, repairing the inconsistency by writing back the consistent replica data to overwrite the inconsistent replica, and updating the separated redundant memory management information of the error correction statistics. S4053. In response to a consistency result where all three replicas are inconsistent, set up separate redundant memory management information that includes returning uncorrectable errors and updating error statistics. S406. Complete the separation of redundant memory management based on the separation of redundant memory management information.

[0042] In this embodiment, in response to the consistency result that the three replicas are consistent, any replica data is directly copied to the target cache dst and a success is returned, generating the corresponding separated redundant memory management information; The response is that the two replicas are consistent, such as... Figure 5 As shown, the data is copied from the copy corresponding to the correct replica index correctIdx to the target buffer dstBuf, and the consistent replica data is written back to overwrite the copy corresponding to the wrong replica index wrongIdx to complete the repair. At the same time, the error correction statistics are updated and the error correction is notified to the upper layer through the corrected output parameter, and the corresponding separated redundant memory management information is generated. If the consistency result is that the three replicas are inconsistent, it is determined to be an uncorrectable error. The error statistics are updated and the uncorrectable error is returned. Corresponding separate redundant memory management information is generated.

[0043] In this embodiment, interfaces for reading / writing / error correction / statistics information are provided, such as the redundant memory statistics information acquisition function (PRT_RedundMemGetStatistics()) or the redundant memory statistics information clearing function (PRT_RedundMemClearStatistics()); single block integrity check function (PRT_RedundMemCheckIntegrity()) and full integrity check function (PRT_RedundMemCheckAll()); handle enumeration allocation function (PRT_RedundMemEnumHandles()); and the replica address and size can be configured before initialization (the replica region address configuration function (PRT_RedundMemSetReplicaAddr()) requires address alignment and prohibits modification after initialization).

[0044] The overall scheme's termination criteria (method termination conditions) are as follows: For a single operation, this redundant memory management method ends with a single API call—writing ends when the redundant data write function (PRT_RedundMemWrite()) completes the copying of three copies of data, magic word updates, update statistics, and returns OS_OK; reading ends when the redundant data read function (PRT_RedundMemRead()) completes access control checks, hierarchical determination, (if necessary) error correction and write-back, copies the results to the target buffer (dstBuf), and returns OS_OK; if a magic word error occurs or all three copies are inconsistent, the management process ends with the return of an error code (OS_ERRNO_REDUND_MAGIC_ERROR (boundary magic word error code) or OS_ERRNO_REDUND_ALL_MISMATCH (all three copies are inconsistent and cannot be corrected)); for the data block's lifecycle, it ends when the redundant data block release function (PRT_RedundMemFree()) marks the block as unallocated and releases the bitmap.

[0045] Example 2 The present invention provides a real-time system three-copy separation redundant memory management device, including a memory, a processor, and a program stored in the memory, characterized in that the processor executes the program to implement the method described in Embodiment 1.

[0046] The present invention also provides a storage medium having a program stored thereon, characterized in that the program, when executed, implements the method described in any of the embodiments in 1.

[0047] In this embodiment, a real-time system triple-copy redundant memory management device and storage medium, in order to achieve the principle and beneficial effects of the system embodiment 1 described above, includes hardware structures and / or software modules corresponding to the execution of various functions. Those skilled in the art should readily recognize that, in conjunction with the illustrative units and algorithm steps described in the embodiments disclosed in this invention, the present invention can be implemented in hardware and / or a combination of hardware and computer software. Whether a function is executed by hardware or computer software depends on the specific application and design constraints of the technical solution. Different methods can be used to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

Claims

1. A method for managing redundant memory with three replicas in a real-time system, characterized in that, Includes the following steps: S1. Based on the real-time system, set up a redundant memory management structure containing three replica separate storage areas, obtain the user address information, initialize the three replica separate storage areas, and arrange the data items of each replica area at equal intervals according to the block index to obtain the arranged three replicas, and set the preset addressing relationship. S2. In response to the memory allocation request, use bitmap management to obtain the free block index and set it, and establish handle metadata. Clear the data area of ​​the three copies arranged and write the magic word to obtain the three copies allocated in memory. S3. In response to the write request, based on the handle metadata and the three copies allocated in memory, select three copies and use the preset addressing relationship to write the source cache data and the double-field magic word to the three selected copies by calculating the starting address of the data area and the magic word address, thus obtaining the written three-copy area. S4. In response to the read request, obtain the block index and block specification type based on the handle metadata, and locate the three replica regions to be read based on the written three replica regions and the preset addressing relationship. Check and calculate the checksum through double-field magic word matching, and accurately compare the replica regions with equal checksums to obtain a consistency result, thus completing the separation of redundant memory management.

2. The real-time system three-copy separation redundant memory management method according to claim 1, characterized in that, S1 includes the following steps: S101. Based on the real-time system, a memory pool is established for each block size, and three independent address segments are configured for each memory pool that are physically separate, resulting in a three-copy separate storage area. A redundant memory management structure containing the three-copy separate storage area is also set up. S102. Obtain the user address information. In response to the user address information not having a custom address, the three replica addresses are read by using the linker script symbol. The three replica separate storage areas are initialized to obtain the three replica addresses. In response to the user's address information containing a custom address, the redundant memory is configured by setting the replica address, the three replicas are placed in different physical memory attribute areas, the three replicas are initialized in separate storage areas, and three replica addresses are obtained. S103. Obtain the three initialized replicas based on the three replica addresses; S104. Based on the initialized three replicas, the data items in each replica area are arranged at equal intervals according to the block index to obtain the arranged three replicas. S105. Based on the starting address of the replica area, the block index, and the span of a single data item, a preset addressing relationship is set.

3. The real-time system three-copy separation redundant memory management method according to claim 1, characterized in that, S2 includes the following steps: S201. In response to a memory allocation request, use bitmap management to search for free blocks, obtain the free block index and set it. S202. By recording the block specification type and block index, handle metadata is established, and the data area of ​​the three copies arranged is cleared and written to the magic word. Combined with the set free blocks, the three copies allocated in memory are obtained.

4. The real-time system three-copy separation redundant memory management method according to claim 1, characterized in that, S3 includes the following steps: S301. In response to the write request, based on the handle metadata, the handle is validated using the handle magic word and allocation flags to obtain the block index and block specification type. S302. Based on the three copies allocated in memory, locate the copy area to be written according to the block index and block specification type, and select the three copies that have the same block index. S303. Using the preset addressing relationship, calculate the starting address and magic word address of the data area of ​​the three selected copies; S304. Synchronously copy the source cache data to the data area of ​​the three selected copies, and write the two-field magic word containing data identifier and boundary protection to the magic word area of ​​the three selected copies to obtain the written three-copy area.

5. The real-time system three-copy separation redundant memory management method according to claim 1, characterized in that, S4 includes the following steps: S401. In response to the read request, the block index and block specification type are obtained by parsing the handle. Based on the written three-copy area, the copy area to be read is located to obtain the three-copy area to be read. S402. By sequentially matching and checking the double-field magic words of the three replica regions to be read, in response to any invalid replica magic word, set the separated redundant memory management information containing the return error code and terminating the reading, and proceed to step S406. In response to the simultaneous matching of the double-field magic words of the three copy regions to be read, proceed to step S403; S403. By calculating the checksum of each of the three replica regions to be read, a combination of replica regions with equal checksums is obtained. S404. By comparing the replica region combinations with equal checksums, a majority consensus judgment is performed on the replica region combinations to obtain a consistency result. S405. Based on the consistency results, generate separate redundant memory management information; S406. Complete the separation of redundant memory management based on the separation of redundant memory management information.

6. The real-time system three-copy separation redundant memory management method according to claim 5, characterized in that, S403 includes the following steps: S4031. By treating the data in the data area of ​​each of the three replica regions to be read as a 32-bit unsigned integer array, the data in the data area of ​​each of the three replica regions to be read is accumulated word by word to obtain the initial accumulated data. S4032. The last few bytes of the initially accumulated data that are less than 4 bytes are accumulated byte by byte using an 8-bit unsigned integer array to obtain three checksums; S4033. By comparing three checksums, select the combination of replica regions with equal checksums.

7. The real-time system three-copy separation redundant memory management method according to claim 5, characterized in that, Specifically, S404 is: By performing a byte-by-byte comparison on the replica regions with equal checksums, and then performing a majority consistency check on the replica regions with equal checksums, a consistency result containing both the correct replica index and the incorrect replica index is obtained.

8. The real-time system three-copy separation redundant memory management method according to claim 5, characterized in that, S405 includes the following steps: S4051. Based on the consistency result, in response to the consistency result being consistent across three replicas, set up separate redundant memory management information that includes copying any replica data to the target cache and returning success. S4052. In response to the consistency result being consistent between the two replicas, the settings include copying the consistent replica data to the target cache, repairing the inconsistency by writing back the consistent replica data to overwrite the inconsistent replica, and updating the separated redundant memory management information of the error correction statistics. S4053. In response to a consistency result where all three replicas are inconsistent, set up separate redundant memory management information that includes returning uncorrectable errors and updating error statistics.

9. A real-time system triple-copy redundant memory management device, comprising a memory, a processor, and a program stored in the memory, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1-8.

10. A storage medium having a program stored thereon, characterized in that, When the program is executed, it implements the method as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Memory management method and device, electronic equipment and computer program product

    CN119829278A

  • MCU anti-radiation optical module control system based on multistage redundancy and safe starting mechanism

    CN122219287A