Four-level data automatic identification and adaptation method based on C# architecture
By real-time monitoring of thread access to battle damage data and combining machine learning models to identify competition risks, the read-write lock priority is dynamically adjusted, which solves the shortcomings of the automatic identification and adaptation mechanism of battle damage status in existing technologies and achieves efficient data synchronization and accurate decision support in high-concurrency environments.
Patent Information
- Application Number
- CN202510400792.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-01
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2045-04-01
AI Technical Summary
The existing technology's automatic identification and adaptation mechanism for battle damage status cannot be adaptively adjusted according to access competition conditions, resulting in abnormalities in which battle damage is not effective, affecting the authenticity of combat simulations and decision-making support capabilities.
By monitoring thread access to battle damage data in real time, building a thread access competition data analysis set, and combining machine learning models to identify competition risks, dynamically adjusting read-write lock priorities, and optimizing resource allocation, we ensure improved query efficiency and timely data updates in a high-concurrency environment.
It improves the realism and decision-making support capabilities of combat simulations, reduces the occurrence of "invincible units" or "battle damage accumulation" anomalies, and improves the stability and reliability of the system.
Smart Images

Figure CN120335960B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of wargame combat simulation, and in particular to a four-level data automatic recognition and adaptation method based on a C# architecture. Background Art
[0002] The four-level data automatic identification and adaptation based on the C# architecture refers to the automatic parsing and matching of four levels of data structures in the computer war game system through the framework built by the C# language, so as to realize the real-time detection and response of the status of equipment components on various combat platforms. Specifically, as the smallest unit for performing independent actions, the function of the operator not only depends on the diverse components carried by the platform to which it belongs (such as individual soldiers, tanks, aircraft, ships, etc.), but is also affected by the current status of these components (such as whether they are ready or damaged) and the status of the basic accessories they rely on (such as existence and resource consumption). By automatically identifying the four data levels of platform, component, status and accessories, the system realizes accurate adaptation and dynamic response of data, thereby ensuring the true reflection and efficient operation of the functions of each unit during the deduction process.
[0003] The existing technology has the following deficiencies:
[0004] In combat simulation systems based on a four-level data structure, existing technologies for automatic damage status identification and adaptation are unable to adapt to access contention. When this automatic identification and adaptation mechanism fails due to access contention, it can result in anomalies where damage status is not applied, causing certain combat units (such as tanks, ships, and aircraft) to remain "invincible" even after suffering severe attacks. This can severely distort combat logic, turning simulations into one-sided battles, and cause simulation results to deviate significantly from reality, undermining battlefield analysis and decision support based on simulation data. More seriously, this error can mislead commanders' assessments of tactical effectiveness and equipment performance, leading to serious errors in decision-making and deployment, ultimately resulting in catastrophic consequences for combat operations.
[0005] The above information disclosed in this Background section is only for enhancement of understanding of the background of the present disclosure and therefore it may contain information that does not form the prior art that is already known to a person of ordinary skill in the art. Summary of the Invention
[0006] The purpose of this invention is to provide a four-level data automatic identification and adaptation method based on the C# architecture. By monitoring thread access to battle damage data in real time, building a complete thread access competition data analysis set, and combining it with a machine learning model to intelligently identify competition risks, it can accurately detect competition hotspots in high-concurrency environments and dynamically optimize resource allocation. In particular, based on the competition load prediction results, the read-write lock priority is adaptively adjusted to ensure improved query efficiency in low-competition environments, while prioritizing battle damage data updates in high-competition environments, reducing data lag issues and preventing the occurrence of "invincible units" or "battle damage stacking" anomalies. Ultimately, while ensuring high system throughput, the battle damage status synchronization mechanism is optimized, improving the authenticity and decision-making support capabilities of combat simulations, ensuring that commanders can make reasonable tactics and deployments based on accurate simulation data, and effectively improving the stability, reliability, and scientific decision-making of the combat simulation system, thereby solving the problems mentioned in the above-mentioned background technology.
[0007] In order to achieve the above object, the present invention provides the following technical solution: a four-level data automatic recognition and adaptation method based on C# architecture, comprising the following steps:
[0008] During combat simulations, each thread's access to combat unit damage data is monitored and recorded in real time, and a thread access competition data analysis set is constructed.
[0009] Based on the established analysis set, key indicators related to access contention load are extracted. After in-depth analysis of the extracted key indicators of thread access contention, feature vectors are constructed based on the analyzed features to represent the specific manifestations of thread access contention.
[0010] Input the constructed thread contention feature vector into a trained and operational machine learning model. By analyzing the input feature vector, the thread contention risk in the current environment can be quickly identified.
[0011] After confirming the existence of potential competition risks, the specific operation types performed by the threads when accessing the combat unit damage data are clearly distinguished, that is, it is clearly identified whether the current access is a "read" operation or a "write" operation. According to the real-time thread competition load prediction results, the priority strategy of the read-write lock is dynamically adjusted to adapt to the needs of different access competition loads.
[0012] Preferably, key indicators related to access contention load are extracted, wherein the extracted key indicators include the number of times conflicts occur between multiple threads for the same resource and the ratio of the number of times a shared lock is forced to roll back due to contention. Within a fixed detection period, after an in-depth analysis of the extracted thread access contention key indicators, a thread conflict reference value and a shared lock backoff reference value are generated respectively. A feature vector is constructed through the analyzed thread conflict reference value and shared lock backoff reference value to characterize the specific manifestations of thread access contention.
[0013] Preferably, the constructed thread conflict reference value and shared lock backoff reference value are input into a machine learning model that has been trained and put into practical use. The contention evaluation coefficient is generated by analyzing the current input feature vector, and the thread access contention risk in the current environment is quickly identified based on the contention evaluation coefficient.
[0014] Preferably, the contention assessment coefficient generated when predicting the thread access contention risk in the current environment through the machine learning model within a fixed detection period is compared and analyzed with a preset contention assessment coefficient reference threshold to identify the thread access contention risk in the current environment. The specific identification process is as follows:
[0015] If the contention evaluation coefficient is greater than the contention evaluation coefficient reference threshold, the thread is identified as an access contention risk thread; if the contention evaluation coefficient is less than or equal to the contention evaluation coefficient reference threshold, the thread is identified as a normal thread.
[0016] Preferably, after confirming the existence of potential contention risk, the priority strategy of the read-write lock is dynamically adjusted according to the thread contention load prediction result obtained in real time. The specific steps are as follows:
[0017] After discovering the thread competition risk, we first distinguish the access type of the current thread to the combat unit damage data, that is, determine whether the thread performs a read operation or a write operation. At the same time, combined with the competition evaluation coefficient content evalua and competition evaluation coefficient reference threshold value conten thresh , calculate the dynamic read and write competition factor to characterize the competition intensity ratio of read operations to write operations in the current environment. The calculation expression of the dynamic read and write competition factor is:
[0018]
[0019] , where: d rci is the dynamic read-write competition factor, R cnt is the total number of read operations within a fixed detection cycle, indicating the frequency of the thread querying the combat unit damage data, W cnt is the total number of write operations within a fixed detection period, indicating the frequency of the thread updating the combat unit damage data, α r With αw They are the read priority coefficient and the write priority coefficient, which are used to control the basic weight of the read-write lock. It is an exponential adjustment factor used to amplify the impact of severe competition.
[0020] Preferably, the dynamic read-write competition factor d is calculated rci , adjust the read-write lock priority strategy in real time, so that the system can adaptively schedule read and write operations under different access competition loads. The specific adjustment strategy is as follows:
[0021]
[0022] , where: P r is the read lock priority weight, which determines the scheduling weight of the read operation in a competitive environment. The value range is (0, 1). w is the write lock priority weight, which determines the scheduling weight of the write operation in a competitive environment, and its value range is (0, 1). β is the adjustment factor, which is used to control the sensitivity of the read-write lock priority change in a competitive environment. r and θ w Represents the read lock priority threshold and write lock priority threshold respectively, which are used to control the priority adjustment starting point of read and write locks in different competitive environments.
[0023] Preferably, after an in-depth analysis of the number of conflicts between multiple threads for the same resource within a fixed detection period, the specific steps of generating a thread conflict reference value are as follows:
[0024] During a fixed detection period, whenever a thread conflict occurs, the number of threads competing for the resource at that time is recorded, and the weighted conflict factor is calculated by taking the number of concurrent threads in conflict and calculating the weighted conflict factor. The calculation expression is:
[0025]
[0026] , where C n is the total number of conflicts in this cycle, concurrency k is the number of threads participating in the contention during the k-th conflict, W cf is the weighted conflict factor;
[0027] After obtaining the weighted conflict factor, the logarithmic function is used to improve it and the thread conflict reference value is calculated. The calculation expression is:
[0028] T ci =ln(1+W cf )
[0029] , where: T ci Thread conflict reference value.
[0030] Preferably, within a fixed detection period, the specific steps of generating a shared lock backoff reference value after in-depth analysis of the ratio of times the shared lock is forced to roll back due to contention are as follows:
[0031] In a fixed detection cycle, each thread attempts to acquire a shared lock in total. The number of times it is forced to roll back due to competition failure is recorded, and the lock rollback rate is calculated. The calculation expression is:
[0032]
[0033] , where: L br is the lock rollback rate, where A is the number of successful lock acquisitions, that is, the number of times a thread directly obtains a shared lock without encountering any contention when trying to acquire the shared lock; B is the number of lock rollbacks, that is, the number of times a thread is forced to roll back because the shared lock is occupied by other threads; and C is the number of lock wait timeouts, that is, the number of times a thread fails to acquire the lock after multiple attempts and is terminated by the operating system or scheduling policy due to timeout.
[0034] Using the lock backoff rate, we further introduce a nonlinear adjustment factor to capture the exponential growth trend when competition intensifies and generate a shared lock backoff reference value. The generated expression is:
[0035]
[0036] , where: S lbi is the shared lock backoff reference value, and D is the thread adaptive weight reduction factor, which indicates the degree to which the thread priority is reduced in the current detection cycle.
[0037] In the above technical solution, the technical effects and advantages provided by the present invention are:
[0038] The present invention monitors thread access to battle damage data in real time, constructs a complete thread access competition data analysis set, and combines machine learning models to intelligently identify competition risks. It can accurately detect competition hotspots in a high-concurrency environment and dynamically optimize resource allocation. In particular, the read-write lock priority is adaptively adjusted based on the competition load prediction results to ensure improved query efficiency in a low-competition environment, while giving priority to the update of battle damage data in a high-competition environment, reducing data lag problems and preventing the occurrence of "invincible units" or "battle damage superposition" anomalies. Ultimately, while ensuring high system throughput, the battle damage status synchronization mechanism is optimized, the authenticity and decision-making support capabilities of combat simulations are improved, and commanders are ensured to make reasonable tactics and deployments based on accurate simulation data, effectively improving the stability, reliability and scientific nature of decision-making of the combat simulation system. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction to the drawings required for use in the embodiments will be given below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0040] Figure 1 This is a flow chart of the method for automatic identification and adaptation of four-level data based on C# architecture of the present invention. DETAILED DESCRIPTION
[0041] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these example embodiments are provided so that the description of this disclosure will be thorough and complete and will fully convey the concepts of the example embodiments to those skilled in the art.
[0042] The present invention provides Figure 1 The four-level data automatic identification and adaptation method based on the C# architecture shown includes the following steps:
[0043] During combat simulations, each thread's access to combat unit damage data is monitored and recorded in real time, building a complete and accurate thread access competition data analysis set.
[0044] Access to combat damage data includes explicit recording of thread ID, combat unit ID, access timestamp, operation type (read or write), and access duration and frequency. By capturing this detailed, real-time access log data, the system constructs a complete and accurate analysis set of thread access contention data. This step provides the foundational data for subsequent identification and analysis of thread contention characteristics.
[0045] Based on the established analysis set, key indicators related to access contention load are extracted. After in-depth analysis of the extracted key indicators of thread access contention, feature vectors are constructed based on the analyzed features to represent the specific manifestations of thread access contention.
[0046] Key indicators related to access contention load are extracted, including the number of times conflicts occur between multiple threads for the same resource and the ratio of the number of times shared locks are forced to roll back due to contention. Within a fixed detection period, after in-depth analysis of the extracted thread access contention key indicators, thread conflict reference values and shared lock backoff reference values are generated respectively. Feature vectors are constructed based on the analyzed thread conflict reference values and shared lock backoff reference values to represent the specific manifestations of thread access contention.
[0047] During combat simulations, if multiple threads simultaneously attempt to access and modify the damage data of the same combat unit, and monitoring records show a significant increase in inter-thread access conflicts, this indicates that threads are frequently unable to obtain valid data access rights in a timely manner due to resource competition, resulting in significant contention. A higher number of contentions indicates a higher level of resource contention. This often leads to data update delays, inconsistent status, and even serious data overwrite or omission issues, ultimately severely impacting the data consistency and combat simulation accuracy of the combat simulation system.
[0048] After an in-depth analysis of the number of conflicts between multiple threads for the same resource within a fixed detection period, the specific steps for generating a thread conflict reference value are as follows:
[0049] During a fixed detection period, whenever a thread conflict occurs, the number of threads competing for the resource at that time is recorded, and the weighted conflict factor is calculated by taking the number of concurrent threads in conflict and calculating the weighted conflict factor. The calculation expression is:
[0050]
[0051] , where C n is the total number of conflicts in this cycle, concurrency k is the number of threads participating in the contention during the k-th conflict, W cf is the weighted conflict factor;
[0052] By quadratically accumulating the number of concurrent threads, we can highlight the severity of conflicts in high-concurrency scenarios: the larger the number of concurrent threads, the more significant the performance impact of the corresponding conflict. This step serves to "amplify" the concurrency scale of each conflict, providing a more sensitive baseline metric for subsequent calculations.
[0053] After obtaining the weighted conflict factor, the logarithmic function is used to improve it and the thread conflict reference value is calculated. The calculation expression is:
[0054] T ci =ln(1+W cf )
[0055] , where: T ci is the thread conflict reference value, which is calculated by adding the weighted conflict factor T ci Adding 1 to the value and taking the logarithm can maintain sufficient resolution when the value is low and avoid infinite expansion when the value is high, ensuring that the result can effectively distinguish the size of the conflict without being "blown away" by extreme conflict situations;
[0056] The purpose of this step is to further squeeze and stretch the conflict degree through logarithmic transformation, so that moderate conflicts and extreme conflicts can be effectively distinguished, thereby achieving clear quantification of thread access contention.
[0057] The thread conflict reference value, generated by analyzing the number of conflicts between multiple threads for the same resource within a fixed detection period, shows that a higher performance value indicates a greater number of thread conflicts for the same resource within the fixed detection period and a higher degree of concurrency among the competing threads, indicating more severe resource contention for the thread. The thread conflict reference value is calculated based on a weighted conflict factor. It not only considers the frequency of conflicts but also amplifies the number of concurrent threads, making the impact of conflicts more significant at higher concurrency levels. After a logarithmic transformation, the thread conflict reference value effectively distinguishes different levels of contention, maintaining a stable quantitative result even with drastic changes in contention levels. Therefore, a higher thread conflict reference value indicates severe resource contention for the thread, potentially leading to performance degradation or prolonged thread blocking. A lower thread conflict reference value indicates smoother resource access, less contention, and higher execution efficiency.
[0058] During combat simulations, a high rate of forced rollbacks due to contention for shared locks typically indicates that threads are experiencing severe contention when accessing critical resources (such as battlefield status data and combat unit status). Shared locks are designed to allow multiple threads to read data simultaneously, while maintaining mutual exclusion when writing data to ensure data consistency. However, when multiple threads attempt to acquire the same shared lock simultaneously, if the lock is already held by another thread, the system may trigger a lock rollback mechanism, causing the current thread to postpone its retry attempt or enter a waiting state. A continuously increasing rate of rollbacks indicates that multiple threads in the system are frequently competing for the same resource, and the resource release rate cannot keep up with the increase in requests, resulting in threads repeatedly entering rollback and retry states. This not only reduces overall computing efficiency but can also delay the execution of critical tasks in the simulation (such as combat decision calculations and unit status updates), affecting the accuracy and real-time nature of simulation results. In extreme cases, a high rate of lock rollbacks can lead to reduced system throughput, prolonged thread blockage, and even deadlock, ultimately impacting the smooth operation of the entire combat simulation.
[0059] The specific steps for generating a shared lock backoff reference value after in-depth analysis of the proportion of times a shared lock is forced back off due to contention within a fixed detection period are as follows:
[0060] In a fixed detection cycle, each thread attempts to acquire a shared lock in total. The number of times it is forced to roll back due to competition failure is recorded, and the lock rollback rate is calculated. The calculation expression is:
[0061]
[0062] , where: L br is the lock rollback rate, where A is the number of successful lock acquisitions, that is, the number of times a thread directly obtains a shared lock without encountering any contention when trying to acquire the shared lock; B is the number of lock rollbacks, that is, the number of times a thread is forced to roll back because the shared lock is occupied by other threads; and C is the number of lock wait timeouts, that is, the number of times a thread fails to acquire the lock after multiple attempts and is terminated by the operating system or scheduling policy due to timeout.
[0063] This formula measures the level of contention a thread faces when accessing a resource by considering successful lock acquisitions (A), lock rollbacks (B), and lock timeouts (C). Unlike traditional methods, this calculation not only focuses on lock rollbacks (B) but also incorporates successful lock acquisitions and timeouts, providing a more comprehensive reflection of lock contention pressure.
[0064] Using the lock backoff rate, we further introduce a nonlinear adjustment factor to capture the exponential growth trend when competition intensifies and generate a shared lock backoff reference value. The generated expression is:
[0065]
[0066] , where: S lbi is the shared lock backoff reference value, and D is the thread adaptive demotion factor, which indicates the degree to which the thread's priority is reduced during the current detection cycle. The calculation method for the thread adaptive demotion factor can be determined by combining the operating system's thread management strategy and the custom logic of the application layer. Typically, existing methods include: dynamically lowering the thread priority based on the thread's CPU usage or waiting time in the previous cycle; measuring the impact on the system load and adjusting accordingly based on the length of time the thread is stuck in operations such as lock contention and I / O blocking; or combining a "penalty mechanism" to count the frequency of lock conflicts caused by the thread and demotion threads with more contention to balance the execution efficiency of other tasks. By integrating the above indicators and calculating or integrating them under certain weights, a factor that reflects the extent to which the thread priority should be reduced is ultimately obtained, thus achieving adaptive priority management.
[0067] The thread conflict reference value, generated by analyzing the proportion of times a shared lock is forced back off due to contention within a fixed detection period, indicates that a higher value indicates more severe resource contention encountered by the thread, while a lower value indicates less or almost no contention. The shared lock back off reference value accurately captures the difficulty a thread faces in acquiring a shared lock by combining the lock back off rate and an adaptive demotion factor. A high shared lock back off reference value indicates that a thread has repeatedly experienced forced back off due to lock contention within the detection period. This indicates that multiple threads are frequently competing for the same resource, hindering computational tasks and impacting system throughput and inference efficiency. Conversely, a low shared lock back off reference value indicates that a thread successfully acquires the lock most of the time, with fewer lock back offs, indicating less resource contention and smoother system operation. Therefore, the shared lock back off reference value can serve as an important indicator of the intensity of resource contention among threads.
[0068] Input the constructed thread contention feature vector into a trained and operational machine learning model (such as a random forest, XGBoost, or neural network model). By analyzing the input feature vector, the risk of thread contention in the current environment can be quickly identified.
[0069] The constructed thread conflict reference value and shared lock backoff reference value are input into a trained and practical machine learning model (such as random forest, XGBoost, neural network model). By analyzing the current input feature vector, a contention evaluation coefficient is generated. Based on the contention evaluation coefficient, the thread access contention risk in the current environment is quickly identified.
[0070] The term "trained and operational machine learning model" here refers to a stable and effective model that has gone through the entire process of data collection, feature extraction, data annotation, model selection, model training, validation, and optimization, and has passed comprehensive performance evaluation before being deployed in a production environment. This model is typically trained and validated using extensive historical data. It draws on a large amount of clearly labeled, accurate, and reliable historical feature data, including but not limited to key features such as thread conflict reference values and shared lock backoff reference values. It uses the corresponding actual access contention risk as a learning label, enabling it to accurately map input features to risk assessment results. For example, random forests, XGBoost, or neural networks, these models undergo repeated iterative optimization during the training phase, adjusting model parameters and improving fit, ultimately achieving accurate classification or regression prediction of thread access contention risk. Once the model achieves specified performance metrics such as precision, recall, or F1 score, the training phase is complete and the model enters the production deployment phase.
[0071] The model's operational deployment means it has completed offline training and testing in a laboratory environment or on a simulated dataset and has been formally applied to a real-world wargame or real-world system environment. It receives real-time data input and makes real-time contention assessment predictions to guide subsequent system scheduling decisions and performance optimization. Specifically, feature metrics such as thread conflict reference value and shared lock backoff reference value are calculated and generated in real time in the actual operational environment. These are then input into the deployed machine learning model as feature vectors. The model then rapidly infers the underlying patterns and decision rules learned during training and outputs the corresponding contention assessment coefficient. The contention assessment coefficient clearly reflects the level of contention faced by threads in the current system when accessing resources. A high contention assessment coefficient indicates severe contention between threads, which may have already or will soon lead to significant performance degradation, reduced throughput, or even the risk of downtime. A low contention assessment coefficient indicates relatively healthy resource contention among threads and stable and smooth system operation. Therefore, this machine learning model, which has been trained and put into practical use, can help the system achieve real-time monitoring and dynamic early warning during operation, and early detection, location and resolution of performance bottlenecks or abnormal conditions related to thread access contention, ensuring the stability and reliability of the war game simulation system and even related actual systems.
[0072] The machine learning model is not specifically limited here, and can achieve the thread conflict reference value T ci and the shared lock backoff reference value S lbi Conduct comprehensive analysis to generate competitive assessment coefficients evalua In order to realize the technical solution of the present invention, the present invention provides a specific implementation method; the competition evaluation coefficient conten evalua The generated expression is: evalua =o p *T ci +o q *S lbi , where o p 、o q They are thread conflict reference values T ci and the shared lock backoff reference value S lbi The preset proportional coefficient, and o p 、o q All are greater than 0. Preset proportional coefficient (o p and o q ) refers to the weighted different competition indicators (thread conflict reference value T ci and the shared lock backoff reference value S lbiThe purpose of these preset proportional coefficients is to adjust the contribution of each indicator to the competition evaluation coefficient, ensuring that the calculated competition evaluation coefficient is consistent with the actual value of the competition evaluation coefficient. evalua It can accurately reflect the severity of access contention in different environments. ci and S lbi The importance of the thread content may vary in different systems, different thread architectures, or different application scenarios. The preset scaling factor allows the system to adjust according to actual needs. For example, in some high-concurrency environments, thread conflicts may be the main performance bottleneck, so a higher o p To increase T ci In other environments where frequent access to shared resources is required, the shared lock contention may be more serious, so the o q Make S lbi The impact on competition evaluation is greater. Therefore, the existence of the preset scaling factor makes the competition evaluation system more flexible and adjustable, and can adapt to different types of computing tasks and system architectures.
[0073] It can be seen from the contention assessment coefficient that, within a fixed detection period, the greater the performance value of the thread conflict reference value generated after in-depth analysis of the number of conflicts occurring between multiple threads for the same resource, the greater the performance value of the shared lock backoff reference value generated after in-depth analysis of the proportion of times the shared lock is forced to roll back due to contention. That is, the greater the performance value of the contention assessment coefficient generated when the machine learning model that has been trained and put into practical use within a fixed detection period predicts the thread access contention risk in the current environment, the more severe the access contention encountered by the thread when accessing the resource, and vice versa.
[0074] The contention assessment coefficient generated by predicting the thread access contention risk in the current environment through the machine learning model within a fixed detection period is compared with the pre-set contention assessment coefficient reference threshold to identify the thread access contention risk in the current environment. The specific identification process is as follows:
[0075] If the contention evaluation coefficient is greater than the contention evaluation coefficient reference threshold, the thread is identified as an access contention risk thread; if the contention evaluation coefficient is less than or equal to the contention evaluation coefficient reference threshold, the thread is identified as a normal thread.
[0076] After confirming the existence of potential contention risks, the specific operation type performed by the thread when accessing combat unit damage data is clearly distinguished. That is, it is clearly identified whether the current access is a "read" operation (query status) or a "write" operation (update status). Based on the real-time thread contention load prediction results, the read-write lock priority strategy is dynamically adjusted to adapt to the needs of different access contention loads;
[0077] After confirming the existence of potential contention risks, the read-write lock priority strategy is dynamically adjusted based on the real-time thread contention load prediction results. The specific steps are as follows:
[0078] After discovering the thread contention risk, we first distinguish the access type of the current thread to the combat unit damage data, that is, determine whether the thread performs a read operation (query status) or a write operation (update status). evalua and competition evaluation coefficient reference threshold value conten thresh , calculate the dynamic read and write competition factor to characterize the competition intensity ratio of read operations to write operations in the current environment. The calculation expression of the dynamic read and write competition factor is:
[0079]
[0080] , where: d rci is the dynamic read-write competition factor, R cnt is the total number of read operations within a fixed detection cycle, indicating the frequency of the thread querying the combat unit damage data, W cnt is the total number of write operations within a fixed detection period, indicating the frequency of the thread updating the combat unit damage data, α r With α w They are the read priority coefficient and the write priority coefficient, which are used to control the basic weight of the read-write lock and can be dynamically adjusted according to system requirements. is an index adjustment factor used to amplify the impact of severe competition. evalua >conten thresh When the item increases rapidly, the dynamic read and write competition factor d rci In a highly competitive environment, it is more inclined to make weighted adjustments to high-frequency access types;
[0081] After discovering thread contention risk, the type of thread operation can be detected to distinguish the type of access the current thread is making to the combat unit's damage data. This can be achieved through thread operation identifiers. When each thread executes a task, the type of operation can be identified through a program-embedded marking mechanism or context management. When a thread begins accessing damage data, the operation can be marked in its execution path as a read operation (querying status) or a write operation (updating status). For example, in C#, the type of operation the current thread is performing can be recorded through method parameters or thread-local storage. For read operations, the system checks whether it is a data query request; for write operations, the system checks whether the thread is updating the damage status. In this way, the system can dynamically distinguish and capture the operation type of each thread during execution, allowing for more precise contention risk management and lock scheduling strategy adjustments.
[0082] This step calculates the dynamic read / write contention factor, which not only distinguishes the access type of the current thread but also dynamically measures the current read / write contention pressure, providing data support for subsequent adjustments to the lock priority strategy. The introduction of the exponential adjustment factor significantly impacts high-frequency access operations in highly contentious environments, enabling adaptive adjustment of the lock strategy under varying load conditions.
[0083] According to the calculated dynamic read and write competition factor d rci , adjust the read-write lock priority strategy in real time, so that the system can adaptively schedule read and write operations under different access competition loads. The specific adjustment strategy is as follows:
[0084]
[0085] , where: P r is the read lock priority weight, which determines the scheduling weight of the read operation in a competitive environment. The value range is (0, 1). w is the write lock priority weight, which determines the scheduling weight of the write operation in a competitive environment, and its value range is (0, 1). β is the adjustment factor, which is used to control the sensitivity of the read-write lock priority change in a competitive environment. r and θ w Represents the read lock priority threshold and write lock priority threshold respectively, which are used to control the priority adjustment starting point of read and write locks in different competitive environments;
[0086] When the dynamic read-write competition factor is higher than the write priority threshold and the write lock priority threshold, the write operation priority weight P w Rapidly rise, give priority to scheduling write threads to reduce the risk of data inconsistency, dynamic balance of read and write: when the dynamic read and write competition factor is in a moderate range, the priority of the read and write locks automatically tends to balance to prevent a certain type of operation from being unscheduled for a long time, high competition environment optimization: if the competition evaluation coefficient far exceeds the competition evaluation coefficient reference threshold, then P w Further improvement to ensure that key battle damage data is updated as quickly as possible and improve the consistency and responsiveness of the system; this strategy dynamically adjusts the priority of read-write locks by introducing exponential transformation to ensure that under different access competition load conditions, the system can adaptively optimize thread scheduling strategies, improve concurrent execution efficiency, and reduce performance bottlenecks caused by competition.
[0087] This mechanism aims to improve resource access efficiency in concurrent environments and optimize the stability and data consistency of the wargame system. By clearly distinguishing the specific operation type (read or write) of threads accessing combat unit damage data, the system can adaptively adjust the priority strategy for read and write locks based on real-time contention load predictions, thereby dynamically optimizing lock scheduling under different contention environments. When the system detects low contention risk, it prioritizes read operations to ensure high throughput of query tasks. When the contention load is high, especially when write operation conflicts intensify, the system prioritizes write operations to ensure timely updates of damage data and avoid distortions in wargames caused by data delays or lock contention. This mechanism effectively reduces thread starvation, improves resource utilization, and optimizes the real-time update capability of damage data, ensuring that the wargame system can operate efficiently and stably in high-concurrency, high-contention environments, avoiding performance bottlenecks or misleading decisions caused by improper lock management.
[0088] The four-level data automatic identification and adaptation method described above, based on a C# architecture, effectively resolves damage status anomalies caused by access contention in combat simulation systems, improving the real-time and accuracy of combat data. By monitoring thread access to damage data in real time, building a comprehensive thread access contention data analysis set, and integrating machine learning models to intelligently identify contention risks, the system accurately detects contention hotspots and dynamically optimizes resource allocation in high-concurrency environments. Specifically, it adaptively adjusts read-write lock priorities based on contention load predictions, ensuring improved query efficiency in low-contention environments while prioritizing damage data updates in high-contention environments, reducing data lag and preventing "invincible unit" or "damage accumulation" anomalies. Ultimately, this solution optimizes damage status synchronization while maintaining high system throughput, enhancing the realism and decision-making support capabilities of combat simulations. This ensures commanders can make informed tactical and deployment decisions based on accurate simulation data, effectively improving the stability, reliability, and scientific nature of combat simulation systems.
[0089] The above formulas are all dimensionless and numerical calculations. The formulas are obtained by collecting a large amount of data and performing software simulation to obtain the most recent real situation. The preset parameters in the formulas are set by technicians in this field according to actual conditions.
[0090] The above description is merely illustrative of certain exemplary embodiments of the present invention. It goes without saying that those skilled in the art will be able to modify the described embodiments in various ways without departing from the spirit and scope of the present invention. Therefore, the above drawings and description are illustrative in nature and should not be construed as limiting the scope of protection of the claims.
[0091] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0092] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0093] In the several embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection of some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0094] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0095] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0096] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0097] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A four-level data automatic identification and adaptation method based on C# architecture, characterized by: The following steps are involved: During combat simulations, each thread's access to combat unit damage data is monitored and recorded in real time, and a thread access competition data analysis set is constructed. Based on the established analysis set, key indicators related to access contention load are extracted, and the extracted key indicators of thread access contention are deeply analyzed. The analyzed features are used to construct feature vectors to represent the specific manifestations of thread access contention. Input the constructed thread contention feature vector into a trained and operational machine learning model. By analyzing the input feature vector, the thread contention risk in the current environment can be quickly identified. After confirming the existence of potential contention risks, the specific operation type performed by the thread when accessing combat unit damage data is clearly distinguished. In other words, it is clearly identified whether the current access is a "read" operation or a "write" operation. Based on the real-time thread contention load prediction results, the read-write lock priority strategy is dynamically adjusted to adapt to the needs of different access contention loads. After confirming the existence of potential contention risks, the read-write lock priority strategy is dynamically adjusted based on the real-time thread contention load prediction results. The specific steps are as follows: After discovering the thread competition risk, first distinguish the access type of the current thread to the combat unit damage data, that is, determine whether the thread performs a read operation or a write operation. At the same time, combined with the competition evaluation coefficient and competition assessment coefficient reference threshold , calculate the dynamic read and write competition factor to characterize the competition intensity ratio of read operations to write operations in the current environment. The calculation expression of the dynamic read and write competition factor is: ,in: is the dynamic read and write competition factor, is the total number of read operations within a fixed detection cycle, indicating the frequency of the thread querying the combat unit damage data. is the total number of write operations within a fixed detection period, indicating the frequency with which the thread updates the combat unit damage data. and They are the read priority coefficient and the write priority coefficient, which are used to control the basic weight of the read-write lock. It is an index adjustment factor used to amplify the impact of severe competition; According to the calculated dynamic read and write competition factor , adjust the read-write lock priority strategy in real time, so that the system can adaptively schedule read and write operations under different access competition loads. The specific adjustment strategy is as follows: ,in: The read lock priority weight determines the scheduling weight of the read operation in a competitive environment. The value range is , The write lock priority weight determines the scheduling weight of the write operation in a competitive environment. The value range is , is a regulation factor used to control the sensitivity of read-write lock priority changes in a competitive environment. and Represents the read lock priority threshold and write lock priority threshold respectively, which are used to control the priority adjustment starting point of read and write locks in different competitive environments.
2. The method for automatic identification and adaptation of level 4 data based on C# architecture according to claim 1 is characterized in that: Key indicators related to access contention load are extracted, including the number of times conflicts occur between multiple threads for the same resource and the ratio of the number of times shared locks are forced to roll back due to contention. Within a fixed detection period, after in-depth analysis of the extracted thread access contention key indicators, thread conflict reference values and shared lock backoff reference values are generated respectively. Feature vectors are constructed based on the analyzed thread conflict reference values and shared lock backoff reference values to represent the specific manifestations of thread access contention.
3. The method for automatic identification and adaptation of level 4 data based on C# architecture according to claim 2 is characterized in that: The constructed thread conflict reference value and shared lock backoff reference value are input into a trained and practically used machine learning model. The contention assessment coefficient is generated by analyzing the current input feature vector, and the thread access contention risk in the current environment is identified based on the contention assessment coefficient.
4. The method for automatic identification and adaptation of level 4 data based on C# architecture according to claim 3 is characterized in that: The contention assessment coefficient generated by predicting the thread access contention risk in the current environment through the machine learning model within a fixed detection period is compared with the pre-set contention assessment coefficient reference threshold to identify the thread access contention risk in the current environment. The specific identification process is as follows: If the contention evaluation coefficient is greater than the contention evaluation coefficient reference threshold, the thread is identified as an access contention risk thread; if the contention evaluation coefficient is less than or equal to the contention evaluation coefficient reference threshold, the thread is identified as a normal thread.
5. The method for automatic identification and adaptation of level 4 data based on C# architecture according to claim 2 is characterized in that: After an in-depth analysis of the number of conflicts between multiple threads for the same resource within a fixed detection period, the specific steps for generating a thread conflict reference value are as follows: During a fixed detection period, whenever a thread conflict occurs, the number of threads competing for the resource at that time is recorded, and the weighted conflict factor is calculated by taking the number of concurrent threads in conflict and calculating the weighted conflict factor. The calculation expression is: ,in, is the total number of conflicts in this cycle, It is k The number of threads participating in the contention during the conflict. is the weighted conflict factor; After obtaining the weighted conflict factor, the logarithmic function is used to improve it and the thread conflict reference value is calculated. The calculation expression is: ,in: Thread conflict reference value.
6. The method for automatic identification and adaptation of level 4 data based on C# architecture according to claim 2 is characterized in that: The specific steps for generating a shared lock backoff reference value after in-depth analysis of the proportion of times a shared lock is forced back off due to contention within a fixed detection period are as follows: In a fixed detection cycle, each thread attempts to acquire a shared lock in total. The number of times it is forced to roll back due to competition failure is recorded, and the lock rollback rate is calculated. The calculation expression is: ,in: is the lock rollback rate, A The number of times the lock was successfully acquired, that is, the number of times the thread directly acquired the lock without encountering any competition when trying to acquire the shared lock. B The number of lock rollbacks, that is, the number of times a thread is forced to roll back because the shared lock is occupied by other threads. C The number of lock waiting timeouts, that is, the number of times a thread fails to acquire a lock after multiple attempts and is terminated by the operating system or scheduling policy due to timeout; Using the lock backoff rate, we further introduce a nonlinear adjustment factor to capture the exponential growth trend when competition intensifies and generate a shared lock backoff reference value. The generated expression is: ,in: The shared lock backoff reference value. D It is the thread adaptive weight reduction factor, which indicates the degree to which the thread priority is reduced in the current detection cycle.
Citation Information
Patent Citations
Data read-write priority balancing method, system and device and storage medium
CN112416556A
Lock scheduling optimization method and terminal
CN118519792A