Lock strategy adjustment method based on lock scheduling condition and terminal
By predicting the contention degree of locks in real time and adjusting the lock strategy dynamically, the lock competition problem of lock scheduling and concurrent control in the Linux kernel is solved, and the balance between high performance and fairness is achieved, and the system stability and responsiveness are improved.
Patent Information
- Application Number
- CN202411509586.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2025-03-18
AI Technical Summary
Lock scheduling and concurrent control in the existing Linux kernel have problems such as CPU idle caused by lock competition, long resource waiting time, and the difficulty of traditional static strategies to adapt to dynamically changing workloads.
By acquiring historical system running data, the machine learning model is trained to predict the contention degree of locks in real time, and dynamically adjust the lock's scheduling strategy based on the prediction results, including adjusting the spin number of spins of the spin lock, the priority strategy of the read and write lock, and the spin number of the mutex lock or converting it into a blocking lock.
The lock scheduling strategy is optimized, unnecessary spin and context switching is reduced, CPU usage efficiency is improved, and the overall stability and response ability of the system are improved.
Smart Images

Figure CN119645674A_ABST
Abstract
Description
[0001] This case is a divisional application based on the invention patent with application date of July 24, 2024, application number 202410997817.4, and name “A method and terminal for lock scheduling optimization” as the parent case. Technical Field
[0002] The present invention relates to the technical field of lock scheduling prediction, and in particular to a lock strategy adjustment method and a terminal based on lock scheduling conditions. Background Art
[0003] There are some challenges in lock scheduling and concurrency control in the current Linux kernel, such as CPU idling caused by lock contention, long resource waiting time, and traditional static strategies that are difficult to adapt to dynamically changing workloads.
[0004] Existing locking mechanisms have some limitations. In highly concurrent environments, these mechanisms are difficult to efficiently balance performance and fairness.
[0005] (1) Spin locks occupy the CPU all the time. If the lock is not acquired, it will be in a running state (spinning), which occupies a large amount of CPU. If the lock cannot be acquired in a very short time, it will undoubtedly reduce the CPU efficiency. In a highly concurrent environment, a large number of threads may be spinning at the same time, which is not suitable for long-term locking operations and reduces the overall performance of the system.
[0006] (2) A mutex lock allows only one thread to access a shared resource at a time, resulting in reduced performance in scenarios with high read concurrency. If a mutex lock cannot be acquired, the thread will fall into a blocked state (sleep) until it is awakened when the lock is acquired. In a high-concurrency environment, context switching will incur certain overhead.
[0007] (3) The implementation of read-write locks is more complicated, and usually requires maintaining reader counters and writer lock states, resulting in a higher risk of implementation errors and maintenance costs. At the same time, in order to improve concurrency, the granularity of the lock needs to be carefully designed. Too coarse-grained read-write locks may limit unnecessary concurrency, while too fine-grained read-write locks may increase the overhead of managing locks. Summary of the invention
[0008] The technical problem to be solved by the present invention is to provide a lock strategy adjustment method and a terminal based on lock scheduling conditions to achieve optimization of the lock scheduling strategy.
[0009] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0010] A method for lock scheduling optimization comprises the steps of:
[0011] S1. Acquire historically collected system operation data, wherein the system operation data includes lock scheduling data, system load data, and system scheduling overhead data;
[0012] S2. training a machine learning model based on the system operation data collected historically;
[0013] S3. Predict the lock contention level in real time based on the trained machine learning model to obtain the prediction result.
[0014] S4. Adjust the lock scheduling strategy according to the prediction result.
[0015] A lock strategy adjustment method based on lock scheduling conditions comprises the following steps:
[0016] S1. Predict the lock contention level in real time based on the trained machine learning model to obtain the prediction result.
[0017] The prediction result is in the form of a probability value of the lock contention degree;
[0018] S2. Adjusting the lock scheduling strategy according to the prediction result;
[0019] If the predicted probability value is lower than the preset first threshold, it is considered as low lock contention; if the predicted probability value is higher than the preset second threshold, it is considered as high lock contention;
[0020] Step S2 is specifically as follows:
[0021] When the prediction result is low lock contention:
[0022] For spin locks, increase the number of spin times of the spin lock;
[0023] For read-write locks, a reader priority strategy is adopted to allow multiple readers to access resources at the same time;
[0024] For the mutex lock, increase the number of spins of the mutex lock;
[0025] When the prediction result is high lock contention:
[0026] For spin locks, reduce the number of spin times of the spin lock, or switch the spin lock to a blocking lock;
[0027] For read-write locks, a writer-first strategy is adopted;
[0028] For the mutex lock, reduce the number of spin times of the mutex lock, or switch the mutex lock to a blocking lock.
[0029] In order to solve the above technical problems, another technical solution adopted by the present invention is:
[0030] A terminal for lock scheduling optimization includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented:
[0031] S1. Acquire historically collected system operation data, wherein the system operation data includes lock scheduling data, system load data, and system scheduling overhead data;
[0032] S2. training a machine learning model based on the system operation data collected historically;
[0033] S3. Predict the lock contention level in real time based on the trained machine learning model to obtain the prediction result.
[0034] S4. Adjust the lock scheduling strategy according to the prediction result.
[0035] A lock strategy adjustment terminal based on lock scheduling conditions includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented:
[0036] S1. Predict the lock contention level in real time based on the trained machine learning model to obtain the prediction result.
[0037] The prediction result is in the form of a probability value of the lock contention degree;
[0038] S2. Adjusting the lock scheduling strategy according to the prediction result;
[0039] If the predicted probability value is lower than the preset first threshold, it is considered as low lock contention; if the predicted probability value is higher than the preset second threshold, it is considered as high lock contention;
[0040] Step S2 is specifically as follows:
[0041] When the prediction result is low lock contention:
[0042] For spin locks, increase the number of spin times of the spin lock;
[0043] For read-write locks, a reader priority strategy is adopted to allow multiple readers to access resources at the same time;
[0044] For the mutex lock, increase the number of spins of the mutex lock;
[0045] When the prediction result is high lock contention:
[0046] For spin locks, reduce the number of spin times of the spin lock, or switch the spin lock to a blocking lock;
[0047] For read-write locks, a writer-first strategy is adopted;
[0048] For the mutex lock, reduce the number of spin times of the mutex lock, or switch the mutex lock to a blocking lock.
[0049] The beneficial effects of the present invention are: a lock strategy adjustment method and terminal based on lock scheduling conditions of the present invention can intelligently predict the degree of lock contention, and then dynamically adjust the lock strategy to achieve a balance between high performance and fairness, and optimize the lock scheduling strategy, which can reduce unnecessary spinning and context switching, improve CPU utilization efficiency, and thus enhance the overall stability and responsiveness of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 A flowchart of a lock scheduling optimization method according to an embodiment of the present invention;
[0051] Figure 2 An architectural flow chart of a lock scheduling optimization method according to an embodiment of the present invention;
[0052] Figure 3 A data processing flow chart of a lock scheduling optimization method according to an embodiment of the present invention;
[0053] Figure 4 A policy scheduling flow chart of a lock scheduling optimization method according to an embodiment of the present invention;
[0054] Figure 5 A structural diagram of a terminal for lock scheduling optimization according to an embodiment of the present invention;
[0055] Description of labels:
[0056] 1. A terminal for lock scheduling optimization; 2. A processor; 3. A memory. DETAILED DESCRIPTION
[0057] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.
[0058] Please refer to Figure 1 , a method for lock scheduling optimization, comprising the steps of:
[0059] S1. Acquire historically collected system operation data, wherein the system operation data includes lock scheduling data, system load data, and system scheduling overhead data;
[0060] S2. training a machine learning model based on the system operation data collected historically;
[0061] S3. Predict the lock contention level in real time based on the trained machine learning model to obtain the prediction result.
[0062] S4. Adjust the lock scheduling strategy according to the prediction result.
[0063] From the above description, it can be seen that the beneficial effects of the present invention are: a lock scheduling optimization method of the present invention can intelligently predict the degree of lock contention, and then dynamically adjust the lock strategy to achieve a balance between high performance and fairness, and optimize the lock scheduling strategy. It can reduce unnecessary spinning and context switching, improve CPU utilization efficiency, and thus improve the overall stability and responsiveness of the system.
[0064] Furthermore, the machine learning model uses a random forest algorithm to predict the degree of lock contention, and the formula is as follows:
[0065]
[0066] Where P(y=k|x1,x2,...,x n ) means that given the feature vector (x1, x2, ..., x n ), the probability that the target variable y is predicted as category k, B represents the number of decision trees in the random forest, Tb represents the bth decision tree in the random forest, and I Tb (y=k|x1,x2,...,x n ) represents an indicator function, which is used to determine whether the decision tree Tb is suitable for a given feature vector (x1, x2, ..., x n ), whether to predict that y belongs to category k. If the decision tree Tb predicts that y belongs to category k, then I Tb (y=k|x1,x2,...,x n )=1, otherwise I Tb (y=k|x1,x2,...,x n )=0.
[0067] From the above description, we can see that the random forest algorithm can handle nonlinear relationships and complex interactions, which enables it to better capture the complex relationship between the lock contention level and other features. In addition, since the random forest algorithm introduces randomness during the training process, it has a strong resistance to overfitting, which is very helpful for dealing with possible noise and complexity in lock contention level prediction.
[0068] Furthermore, step S4 is specifically as follows:
[0069] When the prediction result is low lock contention:
[0070] For spin locks, increase the number of spin times of the spin lock;
[0071] For read-write locks, a reader priority strategy is adopted to allow multiple readers to access resources at the same time;
[0072] For the mutex lock, increase the number of spins of the mutex lock;
[0073] When the prediction result is high lock contention:
[0074] For spin locks, reduce the number of spin times of the spin lock, or switch the spin lock to a blocking lock;
[0075] For read-write locks, a writer-first strategy is adopted;
[0076] For the mutex lock, reduce the number of spin times of the mutex lock, or switch the mutex lock to a blocking lock.
[0077] As can be seen from the above description, through the above method, for different types of locks and different lock contention levels (low lock contention and high lock contention), the strategy can be dynamically adjusted to achieve a balance between high performance and fairness.
[0078] Furthermore, in step S2, before training the machine learning model, the system operation data needs to be preprocessed by normalization and denoising.
[0079] From the above description, it can be seen that before training the machine learning model, the system operation data is preprocessed to ensure the validity of the data.
[0080] Furthermore, the method further comprises the steps of:
[0081] S5. Collect system operation data in real time and perform feedback optimization on the machine learning model.
[0082] From the above description, it can be seen that the machine learning model is feedback optimized based on the prediction results and real-time system operation data to improve the accuracy of model prediction.
[0083] Please refer to Figure 2 , a terminal for lock scheduling optimization, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0084] S1. Acquire historically collected system operation data, wherein the system operation data includes lock scheduling data, system load data, and system scheduling overhead data;
[0085] S2. training a machine learning model based on the system operation data collected historically;
[0086] S3. Predict the lock contention level in real time based on the trained machine learning model to obtain the prediction result.
[0087] S4. Adjust the lock scheduling strategy according to the prediction result.
[0088] From the above description, it can be seen that the beneficial effects of the present invention are: a lock scheduling optimization terminal of the present invention can intelligently predict the degree of lock contention, and then dynamically adjust the lock strategy to achieve a balance between high performance and fairness, and optimize the lock scheduling strategy. It can reduce unnecessary spinning and context switching, improve CPU utilization efficiency, and thus improve the overall stability and responsiveness of the system.
[0089] Furthermore, the machine learning model uses a random forest algorithm to predict the degree of lock contention, and the formula is as follows:
[0090]
[0091] Where P(y=k|x1,x2,...,x n ) means that given the feature vector (x1, x2, ..., x n ), the probability that the target variable y is predicted as category k, B represents the number of decision trees in the random forest, Tb represents the bth decision tree in the random forest, and I Tb (y=k|x1,x2,...,x n ) represents an indicator function, which is used to determine whether the decision tree Tb is suitable for a given feature vector (x1, x2, ..., x n ), whether to predict that y belongs to category k. If the decision tree Tb predicts that y belongs to category k, then I Tb (y=k|x1,x2,...,x n )=1, otherwise I Tb (y=k|x1,x2,...,x n )=0.
[0092] From the above description, we can see that the random forest algorithm can handle nonlinear relationships and complex interactions, which enables it to better capture the complex relationship between the lock contention level and other features. In addition, since the random forest algorithm introduces randomness during the training process, it has a strong resistance to overfitting, which is very helpful for dealing with possible noise and complexity in lock contention level prediction.
[0093] Furthermore, step S4 is specifically as follows:
[0094] When the prediction result is low lock contention:
[0095] For spin locks, increase the number of spin times of the spin lock;
[0096] For read-write locks, a reader priority strategy is adopted to allow multiple readers to access resources at the same time;
[0097] For the mutex lock, increase the number of spins of the mutex lock;
[0098] When the prediction result is high lock contention:
[0099] For spin locks, reduce the number of spin times of the spin lock, or switch the spin lock to a blocking lock;
[0100] For read-write locks, a writer-first strategy is adopted;
[0101] For the mutex lock, reduce the number of spin times of the mutex lock, or switch the mutex lock to a blocking lock.
[0102] As can be seen from the above description, through the above method, for different types of locks and different lock contention levels (low lock contention and high lock contention), the strategy can be dynamically adjusted to achieve a balance between high performance and fairness.
[0103] Furthermore, in step S2, before training the machine learning model, the system operation data needs to be preprocessed by normalization and denoising.
[0104] From the above description, it can be seen that before training the machine learning model, the system operation data is preprocessed to ensure the validity of the data.
[0105] Furthermore, the method further comprises the steps of:
[0106] S5. Collect system operation data in real time and perform feedback optimization on the machine learning model.
[0107] From the above description, it can be seen that the machine learning model is feedback optimized based on the prediction results and real-time system operation data to improve the accuracy of model prediction.
[0108] The invention discloses a lock scheduling optimization method and terminal, which are suitable for optimizing lock scheduling when the system is running, and are particularly suitable for optimizing lock scheduling and concurrency of Linux systems.
[0109] Please refer to Figures 1 to 4 , Embodiment 1 of the present invention is:
[0110] A method for lock scheduling optimization comprises the steps of:
[0111] S1. Acquire historically collected system operation data, where the system operation data includes lock scheduling data, system load data, and system scheduling overhead data.
[0112] In this embodiment, reference can be made to Figure 2, a monitoring module is designed: this module is responsible for collecting system operation data in real time, including but not limited to the number of lock contention, average waiting time, CPU occupancy, context switching frequency, etc. The tag data is the degree of lock contention. It can be obtained in the following ways. These data can be recorded by kernel tracking tools such as perf and ftrace, and the number of lock contention and average waiting time data.
[0113] S2. training a machine learning model based on the system operation data collected historically;
[0114] In step S2, before training the machine learning model, the system operation data needs to be normalized and denoised.
[0115] In this embodiment, reference can be made to Figure 3 , extract features that are helpful for prediction from the data collected by the monitoring module lock. The features that are helpful for prediction include: the number of lock contention, which reflects the frequency of lock competition; the average waiting time, which reflects the length of time the thread waits for the lock; the CPU occupancy rate, which reflects the system load; the context switching frequency, which reflects the system scheduling overhead. The judgment method uses the feature selection algorithm: using Lasso regression and decision tree algorithm, automatically select important features.
[0116] Preprocessing operations are performed, normalization is applied, and Z-score standardization is used to scale all features to a uniform range to avoid certain features having a disproportionate impact on the model prediction results due to differences in dimensions. De-noising is also performed to smooth time series data through moving average or median filtering to eliminate the interference of short-term fluctuations on model training.
[0117] The machine learning model uses a random forest algorithm to predict the degree of lock contention, and the formula is as follows:
[0118]
[0119] Where P(y=k|x1,x2,...,x n ) means that given the feature vector (x1, x2, ..., x n ), the probability that the target variable y is predicted as category k, B represents the number of decision trees in the random forest, Tb represents the bth decision tree in the random forest, and I Tb (y=k|x1,x2,...,x n ) represents an indicator function, which is used to determine whether the decision tree Tb is suitable for a given feature vector (x1, x2, ..., x n ), whether to predict that y belongs to category k. If the decision tree Tb predicts that y belongs to category k, then I Tb (y=k|x1,x2,...,x n)=1, otherwise I Tb (y=k|x1,x2,...,x n )=0.
[0120] Sampling: A subset is randomly selected from the original data set using the bootstrap method.
[0121] Feature selection: Before each node splits, a subset of features is randomly selected from all features, usually using a preset number of features (e.g. sqrt(n), where n is the total number of features).
[0122] Tree construction: On the selected feature subset, a decision tree is constructed according to the decision tree algorithm until the preset stopping condition is met (such as the number of samples in the node is less than the threshold or the maximum depth is reached).
[0123] S3. According to the trained machine learning model, the lock contention level is predicted in real time to obtain the prediction result.
[0124] In this embodiment, the prediction result is in the form of a probability value of the degree of lock contention, and a dynamic scheduling strategy is generated. The degree of lock contention is judged as low lock contention and high lock contention, and is judged by a probability value used to reflect the degree of lock contention. Low lock contention: The predicted probability value is lower than a certain threshold, which is set to 0.3 in the embodiment. High lock contention: The predicted probability value is higher than a certain threshold, which is set to 0.7 in the embodiment. If it is between 0.3-0.7, we do not make special treatment, and the scheduling lock does not make policy adjustments.
[0125] S4. Adjusting the lock scheduling strategy according to the prediction result;
[0126] Step S4 is specifically as follows:
[0127] When the prediction result is low lock contention:
[0128] For spin locks, increase the number of spin times of the spin lock;
[0129] For read-write locks, a reader priority strategy is adopted to allow multiple readers to access resources at the same time;
[0130] For the mutex lock, increase the number of spins of the mutex lock;
[0131] When the prediction result is high lock contention:
[0132] For spin locks, reduce the number of spin times of the spin lock, or switch the spin lock to a blocking lock;
[0133] For read-write locks, a writer-first strategy is adopted;
[0134] For the mutex lock, reduce the number of spin times of the mutex lock, or switch the mutex lock to a blocking lock.
[0135] In this embodiment, reference can be made to Figure 2 and Figure 4 ,Design a scheduling strategy generator: Based on the results predicted by the model, the prediction results are in the form of probability values of the degree of lock contention, a dynamic scheduling strategy is generated.
[0136] For spin locks, when the lock contention level is predicted to be low, the rule engine may choose to increase the spin count of the spin lock (adaptive spin lock) to reduce context switching. When the prediction results show that the lock contention level is high, the policy generator will dynamically reduce the spin count or switch the spin lock to a blocking lock to release CPU resources for other threads.
[0137] For read-write locks, read-write priority switching is performed. When the predicted write lock competition is low, the reader priority strategy is adopted to allow multiple readers to access resources at the same time and improve the concurrency of read operations. When the predicted write lock competition is high, the writer priority strategy is adopted to ensure that write operations can obtain locks in time and reduce the waiting time for write operations.
[0138] For the dynamic spin and blocking switch of the mutex lock, when the lock competition is predicted to be low, the number of spins can be increased, so that the thread has a greater chance to acquire the lock during the spin wait period, thereby reducing context switching. When the lock competition is predicted to be high, the number of spins is reduced or directly switched to a blocking lock to avoid wasting CPU resources.
[0139] Through the above specific measures, the performance issues of mutex locks and read-write locks in a high-concurrency environment can be effectively handled. Not only can the spin times of spin locks be dynamically adjusted, but the behavior of mutex locks and read-write locks can also be optimized to improve the system's concurrent processing capabilities and resource utilization efficiency.
[0140] S5. Collect system operation data in real time and perform feedback optimization on the machine learning model.
[0141] In this embodiment, a feedback mechanism is designed. During the operation of the system, the effect of the scheduling strategy is monitored in real time, and the results are fed back to the machine learning model to achieve continuous learning and optimization of the model.
[0142] Please refer to Figure 5 , Embodiment 2 of the present invention is:
[0143] A lock scheduling optimization terminal includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps in the lock scheduling optimization method described in the first embodiment are implemented.
[0144] In summary, the lock scheduling optimization method and terminal provided by the present invention can intelligently predict the degree of lock contention, and then dynamically adjust the lock strategy to achieve a balance between high performance and fairness, optimize the lock scheduling strategy, reduce unnecessary spinning and context switching, and improve CPU utilization efficiency, thereby improving the overall stability and responsiveness of the system.
[0145] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A lock strategy adjustment method based on lock scheduling, characterized in that: Includes steps: S1. Predict the lock contention level in real time based on the trained machine learning model and obtain the prediction result. The prediction result is in the form of a probability value of the lock contention degree; S2. Adjusting the lock scheduling strategy according to the prediction result; If the predicted probability value is lower than the preset first threshold, it is considered as low lock contention; if the predicted probability value is higher than the preset second threshold, it is considered as high lock contention; Step S2 is specifically as follows: When the prediction result is low lock contention: For spin locks, increase the number of spin times of the spin lock; For read-write locks, a reader priority strategy is adopted to allow multiple readers to access resources at the same time; For the mutex lock, increase the number of spins of the mutex lock; When the prediction result is high lock contention: For spin locks, reduce the number of spin times of the spin lock, or switch the spin lock to a blocking lock; For read-write locks, a writer-first strategy is adopted; For the mutex lock, reduce the number of spin times of the mutex lock, or switch the mutex lock to a blocking lock.
2. A lock strategy adjustment method based on lock scheduling according to claim 1, characterized in that: The first threshold is 0.3, and the second threshold is 0.
7.
3. The lock strategy adjustment method based on lock scheduling according to claim 1, characterized in that: The training of the machine learning model includes the steps of: S11, acquiring historically collected system operation data, wherein the system operation data includes lock scheduling data, system load data, and system scheduling overhead data; S12. Training a machine learning model based on the system operation data collected historically.
4. The lock strategy adjustment method based on lock scheduling according to claim 3 is characterized in that: The machine learning model uses a random forest algorithm to predict the degree of lock contention, and the formula is as follows: Where P(y=k|x1,x2,...,x n ) means that given the feature vector (x1, x2, ..., x n ), the probability that the target variable y is predicted as category k under the condition of , the predicted category k includes low lock contention and high lock contention, B represents the number of decision trees in the random forest, Tb represents the bth decision tree in the random forest, I Tb (y=k|x1,x2,...,x n ) represents an indicator function, which is used to determine whether the decision tree Tb is suitable for a given feature vector (x1, x2, ..., x n ), whether to predict that y belongs to category k. If the decision tree Tb predicts that y belongs to category k, then I Tb (y=k|x1,x2,...,x n )=1, otherwise I Tb (y=k|x1,x2,...,x n )=0.
5. The lock strategy adjustment method based on lock scheduling according to claim 3 is characterized in that: In step S12, before training the machine learning model, the system operation data needs to be normalized and denoised.
6. A lock strategy adjustment terminal based on lock scheduling conditions, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the following steps are implemented: S1. Predict the lock contention level in real time based on the trained machine learning model and obtain the prediction result. The prediction result is in the form of a probability value of the lock contention degree; S2. Adjusting the lock scheduling strategy according to the prediction result; If the predicted probability value is lower than the preset first threshold, it is considered as low lock contention; if the predicted probability value is higher than the preset second threshold, it is considered as high lock contention; Step S2 is specifically as follows: When the prediction result is low lock contention: For spin locks, increase the number of spin times of the spin lock; For read-write locks, a reader priority strategy is adopted to allow multiple readers to access resources at the same time; For the mutex lock, increase the number of spins of the mutex lock; When the prediction result is high lock contention: For spin locks, reduce the number of spin times of the spin lock, or switch the spin lock to a blocking lock; For read-write locks, a writer-first strategy is adopted; For the mutex lock, reduce the number of spin times of the mutex lock, or switch the mutex lock to a blocking lock.
7. A lock strategy adjustment terminal based on lock scheduling according to claim 6, characterized in that: The first threshold is 0.3, and the second threshold is 0.
7.
8. The lock strategy adjustment terminal based on lock scheduling according to claim 1, characterized in that: The training of the machine learning model includes the steps of: S11, acquiring historically collected system operation data, wherein the system operation data includes lock scheduling data, system load data, and system scheduling overhead data; S12. Training a machine learning model based on the system operation data collected historically.
9. The lock strategy adjustment terminal based on lock scheduling according to claim 8, characterized in that: The machine learning model uses a random forest algorithm to predict the degree of lock contention, and the formula is as follows: Where P(y=k|x1,x2,...,x n ) means that given the feature vector (x1, x2, ..., x n ), the probability that the target variable y is predicted as category k under the condition of , the predicted category k includes low lock contention and high lock contention, B represents the number of decision trees in the random forest, Tb represents the bth decision tree in the random forest, I Tb (y=k|x1,x2,...,x n ) represents an indicator function, which is used to determine whether the decision tree Tb is suitable for a given feature vector (x1, x2, ..., x n ), whether to predict that y belongs to category k. If the decision tree Tb predicts that y belongs to category k, then I Tb (y=k|x1,x2,...,x n )=1, otherwise I Tb (y=k|x1,x2,...,x n )=0.
10. The lock strategy adjustment terminal based on lock scheduling according to claim 8, characterized in that: In step S12, before training the machine learning model, the system operation data needs to be normalized and denoised.
Citation Information
Cited By
Intelligent door lock control method and system based on deep learning
CN121564835A