Real-time System Synchronous Data Management System Based on Multithreaded Processing

By building implicit dependence graphs and dynamic role switching between threads in a multi-threaded environment, the problem that traditional synchronization mechanisms are difficult to accurately characterize data dependence between threads is solved, which improves system parallelism and response speed, and reduces the risk of conflict.

CN120029790BActive Publication Date: 2025-07-01HUAHENG SEMICON EQUIP (SUZHOU) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510494697.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-21
Publication Date
2025-07-01
Estimated Expiration
2045-04-21

AI Technical Summary

Technical Problem

In a multi-threaded environment, it is difficult for the traditional synchronization mechanism to finely characterize the data dependencies between threads, resulting in unnecessary synchronization waiting, affecting the system parallelism and response speed.

Method used

Through the thread data dependency awareness modeling module, the access sequence and mutual call frequency of multi-threaded shared data blocks are monitored, the implicit dependency graph is constructed, and the dependency node table and access conflict weight matrix are generated. Dynamically divide the thread roles into primary synchronous threads and slave data collaborative threads, and perform role switching in the conflict trigger window. The master synchronous thread initiates data consistency instructions, and the slave thread performs data playback and state merging according to the latest trajectory deviation correction strategy.

Benefits of technology

Dynamically perceive data dependence between threads, improve conflict recognition accuracy and coverage capabilities, reduce unnecessary synchronization waiting, improve system parallelism and response speed, and reduce the risks of thread hunger and resource congestion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120029790B_ABST
    Figure CN120029790B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of data management, and particularly to a real-time system synchronous data management system based on multi-threaded processing, including: a thread data dependency perception modeling module: constructing an implicit dependency graph between threads, generating a dependency node table and an access conflict weight matrix; a dynamic master-slave role switching module: outputting a main thread guidance table and a synchronization window configuration table; a synchronization trajectory reconstruction execution module: the main synchronization thread issues a data consistency instruction according to the synchronization window configuration table, and the subordinate threads execute data playback and status merging operations according to the trajectory deviation correction strategy in the latest main thread guidance table, and output a unified synchronization data status diagram. The present invention can dynamically discover potential conflict paths, improve the accuracy and coverage of conflict recognition in asynchronous access modes, and is particularly suitable for real-time systems with high concurrency, mixed reading and writing, and complex access relationships.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data management, and particularly to a real-time system synchronous data management system based on multi-threaded processing. Background Art

[0002] With the wide application of high-concurrency real-time systems in industrial control, edge computing, and intelligent devices, multi-threaded parallel processing has become a key means to improve the system throughput rate and response ability. However, there are still many technical bottlenecks in the synchronous access management of shared data in a multi-threaded environment. Especially in scenarios with frequent asynchronous access and complex data dependency relationships, traditional synchronization mechanisms face the following problems:

[0003] Existing technologies generally rely on mechanisms such as mutex locks, read-write locks, or semaphores to achieve thread synchronization. However, these mechanisms are difficult to precisely depict the true data dependencies between threads, often resulting in unnecessary synchronization waits, which restricts the system parallelism and response speed.

[0004] Traditional synchronization strategies usually set synchronization boundaries based on the explicit access sequences of threads, ignoring the potential implicit conflicts and indirect dependencies between threads under high-frequency asynchronous access, resulting in data inconsistency or ineffective conflict prediction, which is more prominent especially in systems with multiple nested calls and frequent callback mechanisms.

[0005] Current systems mostly adopt a fixed master thread or polling mechanism for synchronization management. Once a synchronization bottleneck forms, there is a lack of an effective mechanism to complete role switching and instruction guidance reconstruction, which easily causes thread blocking, data drift, and even state anomalies, lacking sufficient scheduling flexibility. Summary of the Invention

[0006] The present invention provides a real-time system synchronous data management system based on multi-threaded processing, which realizes dynamic perception of shared data access behaviors, adaptive evolution of master-slave roles, and hybrid application and trajectory reconstruction of consistency strategies during multi-threaded concurrent execution.

[0007] A real-time system synchronous data management system based on multi-threaded processing includes:

[0008] A thread data dependency perception and modeling module: By monitoring the access sequences of each thread to shared data blocks and their mutual call frequencies during multi-threaded operation, an implicit dependency graph between threads is constructed, and a dependency node table and an access conflict weight matrix are generated;

[0009] A dynamic master-slave role switching module: Based on the dependency node table and the conflict weight matrix, thread roles are dynamically divided into a main synchronization thread and a subordinate data coordination thread, and role switching operations are performed within a conflict trigger window, and a main thread guidance table and a synchronization window configuration table are output;

[0010] Synchronous Trajectory Reconstruction Execution Module: The main synchronization thread initiates a data consistency instruction according to the synchronization window configuration table, and the subordinate threads execute data playback and status merging operations based on the trajectory deviation correction strategy in the latest main thread guidance table, and output a unified synchronized data status diagram.

[0011] Optionally, the thread data dependency awareness modeling module specifically includes:

[0012] Original Access Event Stream Acquisition Unit: Real-time captures the access sequences of each thread to the shared data block, records the thread ID, data block address, operation type, and timestamp, and generates an original access event stream;

[0013] Sliding Window Association Extraction Unit: Processes the original access event stream using a sliding time window to extract the shared access behaviors between adjacent threads. When two threads access the same data block within the time window and there is a read-write overlap in the operations, an implicit dependency edge is established. At the same time, the temporal locality coefficient is calculated based on the time interval: , where represents the time interval between two conflicting accesses, represents the temporal locality coefficient, reflecting the temporal tightness of the two conflicting accesses;

[0014] Dependency Node Table Construction Unit: Constructs a set of nodes in the dependency graph with each thread as a node, and calculates the activity index for each node ;

[0015] Access Conflict Weight Matrix Generation Unit: Constructs an access conflict weight matrix between threads , uses a double-layer hash structure to accelerate retrieval and storage, and the element in the conflict weight matrix represents the conflict weight between thread and thread .

[0016] Optionally, the activity index is calculated as: , where represents the temporal locality coefficient generated by the th access, represents the weight corresponding to the operation type.

[0017] Optionally, the matrix element is represented as: , where represents the number of direct read-write conflicts that occur between thread and thread within the window , Indicates the indirect call frequency obtained by tracing the transfer of dependencies through shared data blocks in the call chain. Is the conflict attenuation factor, which respectively controls the contribution of direct and indirect conflicts to the final weight.

[0018] Optionally, the dynamic master-slave role switching module specifically includes:

[0019] Conflict contribution calculation unit: Based on the activity index of each thread in the dependency node table And the access conflict weight matrix , calculate the conflict contribution of thread : : , where Is the conflict contribution of thread , Is the activity index of thread , Is the average execution cycle of threads in the system, and the sum traverses all threads That have a non-zero conflict relationship with thread ;

[0020] Main thread candidate queue construction unit: Arrange the conflict contributions Of all threads in descending order, and select the first Threads as the main synchronization thread candidates, Is the number of main thread candidates;

[0021] Role switching window trigger unit: When an element in the conflict weight matrix satisfies: , Is the dynamic conflict threshold, then trigger the role switching operation;

[0022] Main thread guidance table generation unit: Record the key data of role switching, generate the main thread guidance table, and the key data includes role switching logs, switching timestamps, old and new main thread IDs, conflict contribution improvement values, and address mapping relationships of conflict data blocks involved. The guidance table supports a version chain structure for tracing the role change process.

[0023] Optionally, the role switching operation includes the following steps:

[0024] a, Freeze the synchronization operation of the current main program and generate a snapshot of its internal state;

[0025] b, Select the thread with the largest conflict contribution improvement value from the candidate queue as the new main thread. The conflict contribution improvement value is calculated as: , where Is the conflict contribution improvement value, Is the current conflict contribution of the candidate thread, is the previous conflict contribution of the replaced main thread, is the historical contribution weight decay factor;

[0026] c, the original main thread to be replaced is demoted to a subordinate thread, and a compensation verification instruction is injected to keep its execution state consistent with the data of the new main thread.

[0027] Optionally, the synchronization window configuration table includes setting the time margin and synchronization trigger threshold of the main thread in the next stage:

[0028] Time margin: ;

[0029] Synchronization trigger threshold: ;

[0030] Among them, is the time margin of the current synchronization operation, is the system reference time window, is the time margin adaptive adjustment coefficient, is the synchronization trigger threshold, is the dynamic scaling coefficient, is the conflict contribution of the new main thread, is the conflict contribution of the original main thread.

[0031] Optionally, the synchronization trajectory reconstruction execution module includes executing step S1: The main synchronization thread initiates a data consistency instruction, specifically including:

[0032] S11. Instruction generation strategy: According to the time margin of the synchronization window configuration table and the synchronization trigger threshold value, select the instruction type:

[0033] Strong consistency instruction: When and , generate a strong consistency instruction, including the latest version number of the target data block and a forced synchronization bitmap, requiring the subordinate thread to immediately stop the current operation and execute synchronization;

[0034] Weak consistency instruction: When and the conflict probability , generate a weak consistency instruction, carrying the time margin allowing delayed synchronization, allowing the subordinate thread to synchronize after completing the current operation;

[0035] Among them, is the critical time threshold, is the maximum conflict intensity set by the system, is the current synchronization trigger threshold, is the current conflict probability, calculated based on the sliding average of conflict frequencies, is the conflict probability upper limit;

[0036] S12. Instruction Distribution Mechanism: The instructions are pushed to associated subordinate threads using a multicast tree structure, and the distribution priority is sorted according to the conflict weight matrix so that threads with high conflict weights receive them first.

[0037] Optionally, the synchronization track reconstruction execution module further includes an execution step S2: The subordinate threads perform track deviation correction, which specifically includes:

[0038] S21. Deviation Detection: Compare the local data version chain with the track baseline in the main thread guidance table to calculate the deviation degree ;

[0039] S22. Correction Mode Decision: Based on the time margin and the deviation degree , select different correction strategies:

[0040] Data Replay Mode: If and , perform data replay, trace back to the most recent consistent state point based on the operation log and re-execute to restore synchronization;

[0041] State Merging Mode: If and there is an intersection of versions (there is an intersection between the local version chain and the main thread version chain), perform state merging: Use the two-way difference method to retain the valid modifications of both sides;

[0042] S23. Unified State Generation: Package the correction results into synchronized data units with time and space stamps, and construct a unified synchronization data state diagram according to the following rules:

[0043] Perform overwrite writing on the instruction coverage area of the strongly consistent region;

[0044] For the weakly consistent region, use the version negotiation mechanism to select the optimal version, and preferentially retain the modifications with the latest time stamp and high historical success rate of the main thread.

[0045] Optionally, the deviation degree is calculated as:

[0046] , where , are the local version and the main thread version of the data block respectively, is the conflict weight of the data block (obtained from ), is the number of data blocks to be synchronized.

[0047] Advantages of the present invention:

[0048] In the present invention, by introducing a "thread data dependence perception modeling module", an implicit dependence graph between threads is constructed in a multi-threaded environment using a sliding time window, a temporal locality coefficient, and an indirect call frequency. This mechanism avoids the drawbacks of traditional synchronization strategies that rely on static locks or predefined synchronization points, can dynamically discover potential conflict paths, improve the accuracy and coverage of conflict recognition in asynchronous access patterns, and is particularly suitable for real-time systems with high concurrency, a mixture of reads and writes, and complex access relationships.

[0049] In the present invention, the "dynamic master-slave role switching module" adaptively selects the main synchronization thread based on the thread conflict contribution degree, and combines the conflict promotion amount and the state snapshot mechanism to support the dynamic evolution of the master-slave role during operation. Compared with the fixed thread binding strategy, this method can reconstruct the synchronization master control chain in time before the concentrated outbreak of conflicts, effectively reduce the risks of thread starvation and resource congestion, and at the same time maintain the real-time performance and flexibility of the system scheduling strategy, especially suitable for handling sudden data storms and dynamic load migrations.

[0050] The present invention proposes a hybrid synchronization strategy that combines strong consistency and weak consistency instructions, and is equipped with a "synchronization trace reconstruction execution module". Through deviation detection and version merging, a structured unified synchronization data state graph is finally output, realizing data consistency control between multiple threads without introducing strong global blocking, taking into account both execution efficiency and consistency reliability, and having significant advantages in edge real-time computing, industrial automation, and heterogeneous thread cooperation systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings in the following description are only those of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0052] Figure 1 It is a schematic diagram of the system module of an embodiment of the present invention;

[0053] Figure 2 It is a schematic diagram of the synchronization trace reconstruction execution module of an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0054] The following will describe the present invention in detail with reference to the drawings and specific embodiments. At the same time, it should be noted here that in order to make the embodiments more detailed, the following embodiments are the best and preferred embodiments. For some well-known technologies, those skilled in the art can also adopt other alternative methods for implementation; moreover, the drawing part is only for more specifically describing the embodiments, and is not intended to specifically limit the present invention.

[0055] It should be noted that in the specification, the mention of "an embodiment", "embodiment", "exemplary embodiment", "some embodiments", etc. indicates that the described embodiments may include specific features, structures or characteristics, but not necessarily every embodiment includes such specific features, structures or characteristics. Additionally, when combining embodiments to describe specific features, structures or characteristics, implementing such features, structures or characteristics in combination with other embodiments (whether explicitly described or not) should be within the knowledge of those skilled in the relevant art.

[0056] Generally, terms can be understood at least in part from their use in context. For example, at least in part depending on the context, the term "one or more" as used herein can be used to describe any feature, structure or characteristic in a singular sense, or can be used to describe a combination of features, structures or characteristics in a plural sense. Additionally, the term "based on" can be understood as not necessarily intended to convey a set of exclusive factors, but rather, at least in part depending on the context, can allow for the existence of other factors that are not necessarily explicitly described.

[0057] As Figure 1 - Figure 2 shown, a real-time system synchronization data management system based on multi-threaded processing includes:

[0058] Thread data dependency perception modeling module: By monitoring the access sequences of each thread to the shared data block and the mutual call frequencies during the multi-threaded operation, construct an implicit dependency graph between threads, and generate a dependency node table and an access conflict weight matrix;

[0059] Dynamic master-slave role switching module: Based on the dependency node table and the conflict weight matrix, dynamically divide the thread roles into a main synchronization thread and a subordinate data collaboration thread, and perform role switching operations within the conflict trigger window, outputting a main thread guidance table and a synchronization window configuration table;

[0060] Synchronization track reconstruction execution module: The main synchronization thread initiates a data consistency instruction according to the synchronization window configuration table, and the subordinate threads execute data playback and status merging operations according to the track deviation correction strategy in the latest main thread guidance table, and output a unified synchronization data status graph.

[0061] The thread data dependency perception modeling module specifically includes:

[0062] Original access event stream acquisition unit: Real-time capture the access sequences of each thread to the shared data block, record the thread ID, data block address, operation type and timestamp, and generate an original access event stream;

[0063] Sliding window correlation extraction unit: Adopt a sliding time window to process the original access event stream, extract the shared access behaviors between adjacent threads, when two threads are within the time window When accessing the same data block internally and there is read-write overlap in the operations, an implicit dependency edge is established. At the same time, the temporal locality coefficient is calculated based on the time interval: , where represents the time interval between two conflicting accesses, represents the temporal locality coefficient, reflecting the temporal tightness of two conflicting accesses. Adding 1 to the denominator is to avoid the problem of the denominator being zero at the time, and at the same time forming a dynamic attenuation mechanism;

[0064] Dependency node table construction unit: Construct a set of nodes in the dependency graph with each thread as a node, and calculate the activity index for each node ;

[0065] Access conflict weight matrix generation unit: Construct an access conflict weight matrix between threads , using a double-layer hash structure to accelerate retrieval and storage. The element in the conflict weight matrix represents thread and thread the conflict weight between them.

[0066] Activity index is calculated as: , where represents the th time the temporal locality coefficient generated by the access, represents the weight of the corresponding operation type, where the write operation weight is set to 2 and the read operation weight is set to 1, is the number of times the current thread participates in conflicting accesses within the window. Optional features such as the cumulative conflict count of the thread and the average dependency strength can also be included in the node attributes.

[0067] Matrix element is expressed as: , where represents thread and thread the number of direct read-write conflicts that occurred between them within the window , represents the indirect call frequency obtained by tracing the dependency relationship through the shared data block in the call chain, is the conflict attenuation factor, respectively controlling the contribution of direct and indirect conflicts to the final weight. Initial values: α = 0.6 (direct conflict weight), β = 0.4 (indirect call weight). Attenuation rule: Adjust dynamically every 5 minutes according to α' = α × 0.95, β' = β + 0.01. The first layer of the double-layer hash structure indexes the thread pair , and the second layer indexes the shared data block identifier to achieve fast conflict location.

[0068] The direct conflict relationship within the time window calculated by the sliding window correlation extraction unit (i.e., ), which is obtained by detecting the read-write overlap behavior within the sliding window. Meanwhile, the dependency node table constructed by the dependency node table construction unit provides the activity information and access structure of the threads to support the derivation path and depth judgment of the indirect call frequency .

[0069] The calculation is as follows: within the time window , count the number of times that thread and thread have read-write overlaps on the same data block, that is:

[0070] ;

[0071] Among them, are respectively the access event sets of threads , . represents two access events within the sliding window W, coming from thread and thread respectively. is an indicator function, and it is recorded as 1 when the condition is satisfied. is the timestamp. is the operation type (read / write). indicates that within the time window, if thread and access the same address and have different operation types (i.e., read-write overlap), then a conflict is recorded once. respectively represent the data block addresses accessed by events and ;

[0072] The calculation is as follows: based on the generated dependency node table, trace back the thread call chain. If there is an indirect access path (crossing ≥ 3 layers) passed through the shared data block between thread and , count the effective dependency frequency on this path: , among which, represents the set of shared data block transfer paths from thread to . is the number of intermediate thread nodes in path .

[0073] The dynamic master-slave role switching module specifically includes:

[0074] Conflict contribution degree calculation unit: Based on the activity index of each thread in the dependency node table and the access conflict weight matrix , the computing thread 's conflict contribution degree : , where is the conflict contribution degree of thread , is the activity index of thread , is the average execution cycle of threads in the system. The summation traverses all threads that have a non-zero conflict relationship with thread ;

[0075] Main thread candidate queue construction unit: Sort the conflict contribution degrees of all threads in descending order, and select the top threads as the main synchronization thread candidates, calculate it as , where is the number of main thread candidates, is the total number of active concurrent threads in the current system, represents the ceiling function;

[0076] Role switching window trigger unit: When an element in the conflict weight matrix satisfies: , is the dynamic conflict threshold (0.7 when CPU utilization > 70%, otherwise 0.5), then trigger the role switching operation;

[0077] Main thread guidance table generation unit: Record the key data of role switching, generate the main thread guidance table. The key data includes role switching logs, switching timestamps, old and new main thread IDs, conflict contribution improvement values, and address mapping relationships of conflict data blocks involved. The guidance table supports a version chain structure for backtracking the role change process.

[0078] The role switching operation includes the following steps:

[0079] a, Freeze the synchronization operation of the current main program and generate a snapshot of its internal state;

[0080] b, Select the thread with the largest conflict contribution improvement value from the candidate queue as the new main thread. The conflict contribution improvement value is calculated as: , where is the conflict contribution improvement value, is the current conflict contribution degree of the candidate thread, is the previous conflict contribution degree of the replaced main thread, is the historical contribution weight decay factor, initially takes the value of 0.5, and is multiplied by 0.8 after a switching failure;

[0081] c, the original main thread being replaced is demoted to a subordinate thread, and compensation verification instructions are injected to keep its execution status consistent with the data of the new main thread.

[0082] The synchronization window configuration table includes setting the time margin and synchronization trigger threshold for the main thread in the next stage:

[0083] Time margin: ;

[0084] Synchronization trigger threshold: ;

[0085] Among them, is the time margin for the current synchronization operation, is the system reference time window, is the time margin adaptive adjustment coefficient, with an initial value of 1.2 (dropping to 0.8 under high load and rising to 1.5 under low load), is the synchronization trigger threshold, is the dynamic scaling coefficient, with a value range of 1.2 - 2.0, and the default value is 1.5, is the conflict contribution degree of the new main thread, is the conflict contribution degree of the original main thread.

[0086] The settings of the two parameters, time margin and synchronization trigger threshold, in the synchronization window configuration table are to define in advance "when to trigger synchronization" (relying on the trigger threshold) and "how fast to complete synchronization" (relying on the time margin), so that the main thread in the next stage can execute efficiently according to the strategy.

[0087] The synchronization trajectory reconstruction execution module includes executing step S1: The main synchronization thread initiates a data consistency instruction, specifically including:

[0088] S11. Instruction generation strategy: According to the time margin and synchronization trigger threshold values in the synchronization window configuration table, select the instruction type:

[0089] Strong consistency instruction: When and , generate a strong consistency instruction, including the latest version number of the target data block and a forced synchronization bitmap, requiring the subordinate thread to immediately stop the current operation and perform synchronization;

[0090] Weak consistency instruction: When and the conflict probability , generate a weak consistency instruction, carrying the time margin allowing delayed synchronization, allowing the subordinate thread to perform synchronization after completing the current operation;

[0091] Among them, is the critical time threshold, The maximum conflict intensity set for the system The current synchronization trigger threshold The current conflict probability, calculated based on the moving average of the conflict frequency The upper limit of the conflict probability, the critical time threshold According to And Calculate: , where Is the instruction type weight factor, taking 0.8 for strong consistency and 0.3 for weak consistency; the current conflict probability Can be calculated based on the conflict frequency within the sliding window, specifically: , where Is the number of inter-thread conflict events at time point , Is the width of the sliding time window Is the current time, this formula represents the average number of conflicts within the last cycles, as the conflict probability index at the current time, used for synchronous instruction type judgment;

[0092] S12. Instruction distribution mechanism: Use the multicast tree structure to push instructions to associated subordinate threads, and the distribution priority is sorted according to the conflict weight matrix , and the thread with the higher conflict weight receives first.

[0093] The synchronous trajectory reconstruction execution module also includes execution step S2: The subordinate thread performs trajectory deviation correction, specifically including:

[0094] S21. Deviation detection: Compare the local data version chain with the trajectory baseline in the main thread guide table, and calculate the deviation degree :

[0095] , where 、 Are the local version and the main thread version of the data block respectively, Is the conflict weight of the data block (obtained from ), Is the number of data blocks that need to be synchronized;

[0096] S22. Correction mode decision: According to the time margin And the deviation degree , select different correction strategies:

[0097] Data replay mode: If And , execute data replay, trace back to the most recent consistent state point based on the operation log and re-execute to restore synchronization;

[0098] Status merging mode: If and there is a version intersection (there is an intersection between the local version chain and the main thread version chain), perform status merging: Use the two-way difference method to retain the valid modifications of both parties;

[0099] S23. Unified status generation: Package the correction result into a synchronized data unit with time and space stamps, and construct a unified synchronized data status graph according to the following rules:

[0100] Perform overwrite writing on the instruction coverage area of the strongly consistent area;

[0101] For the weakly consistent area, use the version negotiation mechanism to select the optimal version, and preferentially retain the modifications with the latest time stamp and the high historical success rate of the main thread.

[0102] The local data version chain represents the historical version record maintained by the subordinate thread, recording the modification sequence of each data block by this thread (e.g., the version change of data block A: v1 → v3 → v5)

[0103] The trajectory baseline in the main thread guidance table represents the standard operation trajectory recorded in the generated main thread guidance table, including two key pieces of information:

[0104] 1. Version baseline: The latest correct version number of the data block recognized by the main thread (e.g., the current version of data block A should be v6);

[0105] 2. Operation sequence: The ideal execution steps required by the main thread for the subordinate thread to follow (e.g., data block B must be written first and then data block A must be read)

[0106] The following fields in the main thread guidance table are the trajectory baseline:

[0107] Role switching log → Version baseline;

[0108] Conflict data block address mapping relationship → Operation sequence dependency rule;

[0109] By comparing the local actual version (version chain) with the standard (trajectory baseline) specified by the main thread, synchronize deviations are discovered and corrected.

[0110] The present invention covers any substitutions, modifications, equivalent methods, and solutions made within the spirit and scope of the present invention. For the public to have a thorough understanding of the present invention, specific details are described in detail in the following preferred embodiments of the present invention, and those skilled in the art can fully understand the present invention without these detailed descriptions. Additionally, well-known methods, processes, flows, components, and circuits, etc. are not described in detail to avoid unnecessary confusion to the essence of the present invention.

[0111] The above are only the preferred embodiments of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.

Claims

1. A real-time system synchronization data management system based on multi-threaded processing, characterized in that: include: Thread data dependency awareness modeling module: by monitoring the access sequence and mutual call frequency of each thread to the shared data block during the multi-threaded operation, the implicit dependency graph between threads is constructed, and a dependency node table and an access conflict weight matrix are generated. The construction of the dependency node table includes constructing a node set in the dependency graph with each thread as a node, and calculating the activity index for each node; The access conflict weight matrix adopts a double-layer hash structure to accelerate retrieval and storage, and the elements in the access conflict weight matrix represent the conflict weights between threads; Dynamic master-slave role switching module: Based on the dependency node table and conflict weight matrix, the thread roles are dynamically divided into the master synchronization thread and the slave data coordination thread, and the role switching operation is performed within the conflict triggering window, and the master thread guide table and the synchronization window configuration table are output. The master thread guide table records the key data of the role switching, which includes the role switching log, the switching timestamp, the new and old main thread IDs, the conflict contribution improvement value, and the address mapping relationship involving the conflicting data blocks. The master thread guide table supports the version chain structure for backtracking the role change process; The synchronization window configuration table includes setting the time margin and synchronization trigger threshold of the main thread; The time margin is set as: ; The synchronization trigger threshold is set as: ; in, is the time margin of the current synchronization operation, is the system benchmark time window, is the time margin adaptive adjustment coefficient, is the synchronous trigger threshold, is the dynamic scaling factor, The conflict contribution of the new main thread. is the conflict contribution of the original main thread, is the matrix element in the conflict weight matrix; Synchronous trajectory reconstruction execution module: The main synchronization thread initiates a data consistency instruction according to the synchronization window configuration table, and the slave thread performs data playback and state merging operations according to the trajectory deviation correction strategy in the latest main thread guide table, and outputs a unified synchronization data state diagram. The trajectory deviation correction strategy specifically includes: a. Deviation detection: Compare the local data version chain with the track baseline in the main thread boot table and calculate the deviation degree ; b. Modify mode decision: according to time margin Deviation , choose different correction strategies: Data playback mode: If and , perform data replay, trace back to the most recent consistent state point based on the operation log and re-execute to restore synchronization, is the critical time threshold; State merging mode: If If there is a version intersection, the execution status is merged: a two-way difference method is used to retain the valid modifications of both parties; c. Unified state generation: Encapsulate the correction results into synchronized data units with time and space stamps, and construct a unified synchronized data state diagram according to the following rules: Perform overwrite write on the strongly consistent area instruction overlay area; For weakly consistent areas, a version negotiation mechanism is used to select the optimal version, giving priority to retaining modifications with the latest timestamp and a high main thread historical success rate.

2. The real-time system synchronization data management system based on multi-threaded processing according to claim 1 is characterized in that: The thread data dependency awareness modeling module specifically includes: Original access event stream collection unit: captures the access sequence of each thread to the shared data block in real time, records the thread ID, data block address, operation type and timestamp, and generates the original access event stream; Sliding window correlation extraction unit: using sliding time window Process the original access event stream and extract the shared access behavior between adjacent threads. When the same data block is accessed within a certain period of time and there is read-write overlap in the operation, an implicit dependency edge is established and the temporal locality coefficient is calculated based on the time interval: ,in, represents the time interval between two conflicting accesses, It represents the temporal locality coefficient, reflecting the timing closeness of two conflicting accesses; Dependency node table construction unit: construct a node set in the dependency graph with each thread as a node, and calculate the activity index for each node ; Access conflict weight matrix generation unit: constructs the access conflict weight matrix between threads ,Using a double-layer hash structure to accelerate retrieval and storage, the elements in the conflict weight matrix Represents a thread With Thread The weight of the conflict between them.

3. The real-time system synchronization data management system based on multi-threaded processing according to claim 2 is characterized in that: The activity index Calculated as: ,in, Indicates The temporal locality coefficient generated by the visit, Indicates the weight of the corresponding operation type.

4. The real-time system synchronization data management system based on multi-thread processing according to claim 3 is characterized in that: The matrix elements It is expressed as: ,in, Represents a thread With Thread Between the windows The number of direct read-write conflicts that occurred within Represents the indirect call frequency obtained by tracing the shared data block delivery dependencies in the call chain. is the conflict attenuation factor, which controls the contribution of direct and indirect conflicts to the final weight respectively.

5. The real-time system synchronization data management system based on multi-thread processing according to claim 2 is characterized in that: The dynamic master-slave role switching module specifically includes: Conflict contribution calculation unit: based on the activity index of each thread in the dependency node table And the access conflict weight matrix ,Compute Thread Contribution to conflict : ,in, For Thread The conflict contribution of For Thread The activity index, is the average execution cycle of threads in the system, and the sum is traversed over all threads Threads with non-zero conflict relations ; Main thread candidate queue construction unit: the conflict contribution of all threads Sort in descending order, select the first Threads are candidates for main synchronization threads. The number of main thread candidates; Role switching window trigger unit: When an element in the conflict weight matrix satisfies: , If it is a dynamic conflict threshold, the role switching operation is triggered; Main thread boot table generation unit: records key data of role switching and generates main thread boot table. Key data includes role switching log, switching timestamp, new and old main thread IDs, conflict contribution improvement value and address mapping relationship involving conflicting data blocks. The boot table supports version chain structure for backtracking the role change process.

6. The real-time system synchronization data management system based on multi-thread processing according to claim 5 is characterized in that: The role switching operation includes performing the following steps: a. Freeze the synchronization operation of the current mainline program and generate a snapshot of its internal state; b. Select the thread with the largest conflict contribution improvement value from the candidate queue as the new main thread. The conflict contribution improvement value is calculated as: ,in, Contribute to conflict improvement, is the current conflict contribution of the candidate thread, is the previous conflict contribution of the replaced main thread, Weight decay factor for historical contributions; c. The replaced original main thread is downgraded to a slave thread, and a compensation check instruction is injected to keep its execution state consistent with the data of the new main thread.

7. The real-time system synchronization data management system based on multi-thread processing according to claim 1 is characterized in that: The synchronization trajectory reconstruction execution module includes executing step S1: the main synchronization thread initiates a data consistency instruction, specifically including: S11. Instruction generation strategy: according to the time margin of the synchronization window configuration table Synchronous trigger threshold Value selection instruction type: Strong consistency instructions: When and When a strong consistency instruction is generated, including the latest version number of the target data block and the forced synchronization bitmap, the slave thread is required to immediately stop the current operation and perform synchronization; Weak consistency instructions: When And the probability of conflict When , a weak consistency instruction is generated, which carries a time margin to allow delayed synchronization, allowing the slave thread to synchronize after completing the current operation; in, is the critical time threshold, is the maximum conflict intensity set for the system, is the current synchronization trigger threshold, is the current conflict probability, calculated based on the sliding average of the conflict frequency, is the upper limit of the conflict probability; S12. Instruction distribution mechanism: Use a multicast tree structure to push instructions to associated slave threads, and distribute priorities according to the conflict weight matrix Sorting, threads with high conflict weight receive first.

8. The real-time system synchronization data management system based on multi-thread processing according to claim 1 is characterized in that: The degree of deviation Calculated as: ,in, , Data blocks The local version and the main thread version, is the conflict weight of the data block, The number of data blocks that need to be synchronized.

Citation Information

Patent Citations

  • Implementation method of multithread distributed SLAM system based on ROS environment

    CN110455294A

  • Efficient thread group scheduling

    EP3385842A1