Method, device and equipment for controlling CPU load by trusted measurement process and storage medium
By cutting the process into a fixed size and controlling the number of slices in the appetizing queue in the CPU sampling cycle, the problem of congestion and idle unevenness that the CPU occurs during the dynamic process is solved, and the balance of the CPU load and the range of fluctuations are realized. Control and meet the strict requirements in the field of industrial control.
Patent Information
- Application Number
- CN202411343364.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2044-09-25
AI Technical Summary
In the prior art, CPUs are prone to congestion and idle imbalance in the process of performing dynamic measurements, resulting in large fluctuations in CPU utilization and unable to meet the strict requirements of the industrial control field for the CPU fluctuation range.
By cutting the memory data that requires a dynamic attitude, it is cut into a fixed size, and the number of slices in the intriguing queue in the CPU sampling cycle will be controlled to ensure the load balancing of the CPU. Specific steps include the cutting process as the slice, scheduling slicing to the ready queue, executing the fabricated motivation attitude weight, releasing the CPU resources, and repeating this process.
The CPU usage rate of the CPU is not exceeded during the sampling cycle, and the CPU load is balanced during the sampling cycle, the CPU load is balanced, and the fluctuation range of the CPU usage rate is reduced to meet the requirements of the CPU fluctuation range in the industrial control field.
Smart Images

Figure CN119336492A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of DCS control technology, and in particular relates to a method, device, equipment and storage medium for controlling CPU load through a trusted measurement process. Background Art
[0002] Trusted Computing (TC) is a technology promoted and developed by TCG (Trusted Computing Group). One of the main goals of trust is to ensure consistency with applications, thereby ensuring that the system or software runs in the trust environment expected by the design objectives. Trust and security are closely related. Trust is the basis of security. Only by understanding trust can we better understand security and lay a solid foundation for building a more solid security management system.
[0003] Trusted dynamic measurement is the core of trusted computing and an indispensable key link in the trusted computing process. Dynamic measurement generally refers to the periodic or triggered measurement of the code segment and read-only data segment of the program in the memory during the program running process. Cryptographic signatures or hash algorithms are required to measure memory data. Calculating hashes or signatures generally consumes system CPU resources. Many processes can run in an operating system. Because the memory data size of each process is different and the measurement trigger conditions of each process are different, congestion and idle imbalance are prone to occur during the actual execution of dynamic measurement. At some times, many processes may meet the measurement conditions and request measurement at the same time, and at some times, no process meets the measurement conditions, and the CPU is idle for a long time. The result is that the system CPU utilization viewed through top sometimes reaches 100% for a long time and sometimes 0%, and the data fluctuates greatly and is extremely unstable.
[0004] In some specific fields, especially in the field of industrial control, there are very strict restrictions on the fluctuation of the system's CPU utilization. For example, the DCS distributed control system in some power generation fields limits the CPU utilization rate to no more than 30%. Therefore, such services that cause excessive fluctuations in CPU utilization will not be applicable in the power generation field. Summary of the invention
[0005] The purpose of the present invention is to overcome the shortcomings of the above-mentioned prior art and provide a technical solution of a method, device, equipment and storage medium for controlling CPU load by a trusted measurement process, so as to solve the problem in the prior art that the CPU is prone to congestion and idle imbalance during the execution of dynamic measurement.
[0006] In order to achieve the above object, the present invention adopts the following technical solutions: The method for controlling CPU load of a trusted measurement process comprises the following steps: S1, cut each process into several slices of fixed size and put the sliced processes into the waiting queue; S2, calling a process after a number of slices from the waiting queue and placing it in the ready queue; the sum of the slices of the multiple processes is less than or equal to the maximum slice capacity, and the maximum slice capacity is the maximum slice capacity of the ready queue; S3, calling the trusted dynamic measurement thread, and performing trusted dynamic measurement on all slices in the ready queue in the order in which the slices enter the ready queue, wherein the trusted dynamic measurement time is less than or equal to the CPU sampling period; S4, releasing the CPU resources of the trusted dynamic measurement thread, and the trusted dynamic measurement thread enters a sleep state until the CPU sampling period ends; S5, repeat S1 to S4.
[0007] A further improvement of the present invention is: Preferably, in S2, the maximum slice capacity is the maximum number of slices that the CPU performs trusted dynamic measurement within a sampling period.
[0008] Preferably, in S2, the calculation formula of the maximum slice capacity M is:
[0009] Among them, T is the CPU occupancy time of the trusted dynamic measurement thread within a sampling period of one week, and t is the time consumed by the CPU to measure a slice.
[0010] Preferably, the calculation formula of T is:
[0011] The unit of T is milliseconds, and P% is the CPU utilization during the trusted dynamic measurement within a sampling period of one week, where 0%<P%<100%.
[0012] Preferably, in S2, the number of slices retrieved from the waiting queue is not greater than the maximum slice capacity.
[0013] Preferably, in S3, the process of performing trusted dynamic measurement on all slices in the ready queue is completed at one time.
[0014] Preferably, in S2, if the number of all slices in the waiting queue is ≤ the maximum slice capacity, all slices in the waiting queue are transferred to the ready queue; if the number of all slices in the waiting queue is > the maximum slice capacity, a number of slices are transferred whose number is ≤ the maximum slice capacity.
[0015] Trusted measurement process controls the CPU load, including: The slicing module is used to cut each process into several slices of fixed size and put the sliced processes into a waiting queue; A calling module is used to call a number of slices from the waiting queue and place them in the ready queue; the sum of the slices of multiple processes is less than or equal to the maximum slice capacity, and the maximum slice capacity is the maximum slice capacity of the ready queue; The measurement module is used to call the trusted dynamic measurement thread to perform trusted dynamic measurement on all slices in the ready queue in turn, and the trusted dynamic measurement time is less than or equal to the sampling period of the CPU; A release module, used to release the CPU resources of the trusted dynamic measurement thread, and the trusted dynamic measurement thread enters a sleep state until the sampling period of the CPU ends; A loop module is used to repeat the slice module, call module, measure module and release module.
[0016] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements any one of the above-mentioned methods for controlling CPU load by a trusted measurement process when executing the computer program.
[0017] A computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements any of the above-mentioned methods for controlling CPU load by a trusted measurement process.
[0018] Compared with the prior art, the present invention has the following beneficial effects: In view of the large fluctuation of CPU usage during trusted dynamic measurement, the present invention proposes a method for controlling CPU load by a trusted dynamic measurement process. The specific steps of the method include: slicing the process memory data that needs to be dynamically measured according to a predetermined size, and calculating the time consumption of CPU measurement of a complete slice. At the same time, two queues are created, a waiting queue and a ready queue. The processes that meet the dynamic measurement conditions are placed in the waiting queue in a first-in-first-out manner. A CPU sampling cycle is specified as 1 second. At each sampling cycle, a certain number of processes are dispatched from the waiting queue to the ready queue to perform dynamic measurement. After all the processes in the ready queue are measured, the CPU is released and continues to wait until the next sampling cycle arrives, and this is repeated. The CPU load balancing is controlled by the maximum slice capacity in the ready queue within the CPU sampling cycle. The method balances the CPU load by controlling the CPU usage of the dynamic measurement thread within the sampling cycle to not exceed the expected threshold, thereby controlling the fluctuation range of the CPU usage in the trusted dynamic measurement process to meet the requirements of the CPU fluctuation range in the industrial control field. The scheme is simple to implement, safe and reliable, and can be widely used in multiple fields such as network servers, industrial control, cloud computing, and data centers.
[0019] Furthermore, in order to ensure that the CPU occupancy time of the trusted dynamic measurement thread does not exceed the set time within a sampling period, the memory data of the dynamically measured process is sliced according to a fixed size.
[0020] Furthermore, although the total number of slices of all processes cannot be greater than M, in order to improve the efficiency of the entire trusted dynamic measurement, the number of slices of the process in the ready queue is added to the number of slices of one process each time, that is, greater than M, so that the number of processes in each trusted dynamic measurement is the maximum possible number.
[0021] Furthermore, due to the technical conditions of trusted dynamic measurement, when dynamically measuring a process, all slices of the process must be completed at one time without interruption, otherwise it will affect the measured process, causing the measured process to freeze, affecting the user experience. To avoid interruptions during the dynamic measurement of the process, the call-in rules are set for the process slices scheduled to the ready queue. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 A flow chart of a method for controlling CPU load in a trusted measurement process of the present invention; Figure 2 It is a CPU operation diagram within a sampling period of the present invention; Figure 3 A diagram of a trusted measurement process control CPU load device of the present invention. DETAILED DESCRIPTION
[0023] It should be noted that the terms "first", "second", etc. in the specification and drawings of the present invention are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0024] First, a unified explanation of the abbreviations of the present invention is given.
[0025] CPU, Central Processing Unit, is the central processing unit.
[0026] PAGE is a memory management technology in an operating system. The operating system partitions data in auxiliary storage (usually a disk) into fixed-size blocks called "pages".
[0027] The present invention discloses a method for controlling CPU load in a trusted measurement process, specifically a method for controlling CPU load balancing in a trusted dynamic measurement process of a process, comprising the following steps: S1, cut each process into several slices of fixed size and put the sliced processes into the waiting queue; S2, calling a process after a number of slices from the waiting queue and placing it in the ready queue; the sum of the slices of the multiple processes is less than or equal to the maximum slice capacity, and the maximum slice capacity is the maximum slice capacity of the ready queue; S3, calling the trusted dynamic measurement thread to perform trusted dynamic measurement on all slices in the ready queue in turn, where the trusted dynamic measurement time is less than or equal to the CPU sampling period; S4, releasing the CPU resources for the trusted dynamic measurement, and the trusted dynamic measurement thread enters a sleep state until the CPU sampling period ends; S5, repeat S1 to S4.
[0028] Assuming that there are several processes in the system that need to perform trusted dynamic measurement, the sizes of the code segments and read-only data segments that each process needs to perform trusted dynamic measurement are different, so the CPU time consumed by each process when performing trusted dynamic measurement is different. The present invention cuts processes of different sizes into slices of fixed size. Each time trusted dynamic measurement is performed, only a fixed number of slices are trusted dynamically measured, so that the CPU load is the same within a sampling period, and the CPU load balance is controlled by the maximum slice capacity in the ready queue within the CPU sampling period, and the CPU will not be idle. The method balances the CPU load by controlling the CPU usage rate of the dynamic measurement thread within the sampling period not to exceed the expected threshold, thereby controlling the fluctuation range of the CPU usage rate during the trusted dynamic measurement process to meet the requirements of the CPU fluctuation range in the industrial control field.
[0029] In some implementation schemes of the present invention, in S1, the processes in the waiting queue are first-in-first-out.
[0030] In some implementation schemes of the present invention, in order to prevent the CPU from being overloaded and causing system instability, it is set that when the system performs trusted dynamic measurement on the process, the CPU utilization cannot exceed P%, 0<P<100. Assuming that a sampling period of CPU utilization is 1 second, if the CPU utilization cannot exceed P% during trusted dynamic measurement, then the CPU occupancy time T of the trusted dynamic measurement thread cannot exceed 1 second*P% during a CPU sampling period (1 second = 1000 milliseconds), which satisfies the following formula (1):
[0031] The unit of T is milliseconds.
[0032] Furthermore, in order to ensure that the CPU occupancy time of the trusted dynamic measurement thread does not exceed T milliseconds within a sampling period of 1 second, the memory data of the dynamically measured process is sliced according to a fixed-size PAGE. The fixed-size PAGE is usually inherent in the operating system and is usually 4096 bytes.
[0033] Assuming that the size of a PAGE is 4096 bytes, the time consumed by the CPU to measure a PAGE is t (unit: milliseconds). The size of time t is mainly related to the hardware configuration of the system. The higher the hardware configuration, the smaller the time t, and the lower the hardware configuration, the larger the time t. If the time t is set to a fixed value, then within a sampling period of 1 second, the maximum number of slices that the CPU can measure is M, that is, the calculation formula for the CPU's maximum slice capacity M is shown in the figure below.
[0034]
[0035] It should be understood that the capacity of the waiting queue is unlimited, and processes that meet the dynamic measurement conditions are placed in the waiting queue in a first-in-first-out manner. The capacity of the ready queue is fixed and can accommodate a maximum of M slices.
[0036] Furthermore, in S2, although the total number of slices of all processes cannot be greater than M, in order to improve the efficiency of the entire trusted dynamic measurement, the number of slices of the process in the ready queue is added to the number of slices of one process each time, which is greater than M, so that the number of processes in each trusted dynamic measurement is the maximum possible number.
[0037] In some embodiments of the present invention, during the measurement process of a sampling cycle, the dynamic measurement thread first measures the M slices at one time, and then releases the CPU to enter a sleep state until the end of a sampling cycle, and the CPU utilization rate of the dynamic measurement thread is controlled not to exceed P% (0 <P<100)。
[0038] Due to the limitations of trusted dynamic measurement technology, when dynamically measuring a process, all slices of the process must be completed at one time without any interruption in the middle, otherwise it will affect the measured process, causing the measured process to become stuck and affecting the user experience.
[0039] Furthermore, to avoid interruption during the dynamic measurement of the process, the following rules are set for the process slices scheduled to the ready queue: (1) If the number of slices of a process is less than the maximum slice capacity M, all slices of the entire process are transferred to the ready queue; (2) If the number of slices of the process is greater than the maximum slice capacity M, some slices are selected and transferred to the ready queue according to the predetermined rules and algorithms.
[0040] The following is a further description of the specific embodiments. Example Assume that at a certain moment, S processes meet the dynamic measurement conditions and are sent to the waiting queue. The execution process of the CPU in a sampling period is as follows: S1, cut S processes, each process is cut into slices of fixed size, and all the cut S processes are placed in the waiting queue.
[0041] S2, schedule no more than n processes from the waiting queue to the ready queue at one time, assuming that the number of slices of these n processes is k 1 , k 2 , …k n , then the following formula (3) must be satisfied:
[0042] That is, the sum of the slices of the n processes scheduled from the waiting queue to the ready queue each time cannot exceed the maximum slice capacity M of the ready queue.
[0043] S3, within a sampling period, the trusted dynamic measurement thread performs trusted dynamic measurement on these n processes in turn; S4, the trusted dynamic measurement thread releases CPU resources and enters the sleep state until the sampling period ends; S5, repeat the above S1 to S5 in sequence until the process requiring trusted dynamic measurement is completed.
[0044] The second aspect of the present invention discloses a trusted measurement process control CPU load device, the device comprising: The slicing module is used to cut each process into several slices of fixed size and put the sliced processes into a waiting queue; A calling module is used to call a number of sliced processes from the waiting queue and place them in the ready queue; the sum of the slices of the multiple processes is less than or equal to the maximum slice capacity, and the maximum slice capacity is the maximum slice capacity of the ready queue; The measurement module is used to call the trusted dynamic measurement thread to perform trusted dynamic measurement on all slices in the ready queue in turn, and the trusted dynamic measurement time is less than or equal to the sampling period of the CPU; A release module, used to release the CPU resources for performing trusted dynamic measurement, wherein the trusted dynamic measurement thread enters a sleep state until the sampling period of the CPU ends; A loop module is used to repeat the slice module, call module, measure module and release module.
[0045] The third aspect of the present invention discloses a computer device, which includes a processor and a memory, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is used to execute the program instructions stored in the computer storage medium. The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. It is the computing core and control core of the terminal, which is suitable for implementing one or more instructions, and is specifically suitable for loading and executing one or more instructions to implement the corresponding method flow or Corresponding functions; the processor described in this embodiment can be used to implement a method for controlling CPU load by a trusted measurement process, comprising the following steps: S1, cutting each process into several slices of fixed size, and placing the cut processes in a waiting queue; S2, retrieving several sliced processes from the waiting queue and placing them in a ready queue; the sum of the slices of multiple processes is less than or equal to the maximum slice capacity, and the maximum slice capacity is the maximum slice capacity of the ready queue; S3, calling a trusted dynamic measurement thread, and performing trusted dynamic measurement on all slices in the ready queue in turn, and the trusted dynamic measurement time is less than or equal to the sampling period of the CPU; S4, releasing the CPU resources for trusted dynamic measurement, and the trusted dynamic measurement thread enters a sleep state until the sampling period of the CPU ends; S5, repeating S1~S4.
[0046] The fourth aspect of the present invention discloses a storage medium, specifically a computer-readable storage medium (Memory), which is a memory device in a terminal device for storing programs and data. It can be understood that the computer-readable storage medium here can include both the built-in storage medium in the terminal device and the extended storage medium supported by the terminal device. The computer-readable storage medium provides a storage space, which stores the operating system of the terminal. In addition, one or more instructions suitable for being loaded and executed by the processor are also stored in the storage space, and these instructions can be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one disk memory. A processor can load and execute one or more instructions stored in a computer-readable storage medium to implement a method for controlling CPU load by a trusted measurement process in the above embodiment, including the following steps: S1, cutting each process into several slices of fixed size, and placing the cut processes in a waiting queue; S2, retrieving several sliced processes from the waiting queue and placing them in a ready queue; the sum of the slices of multiple processes is less than or equal to the maximum slice capacity, and the maximum slice capacity is the maximum slice capacity of the ready queue; S3, calling a trusted dynamic measurement thread, and performing trusted dynamic measurement on all slices in the ready queue in turn, and the trusted dynamic measurement time is less than or equal to the sampling period of the CPU; S4, releasing the CPU resources for trusted dynamic measurement, and the trusted dynamic measurement thread enters a sleep state until the sampling period of the CPU ends; S5, repeating S1 to S4.
[0047] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for controlling CPU load by a trusted measurement process, characterized in that: The following steps are involved: S1, cut each process into several slices of fixed size and put the sliced processes into the waiting queue; S2, retrieve several slices from the waiting queue and place them in the ready queue; The sum of the slices of the multiple processes is less than or equal to the maximum slice capacity, where the maximum slice capacity is the maximum slice capacity of the ready queue; S3, calling the trusted dynamic measurement thread, and performing trusted dynamic measurement on all slices in the ready queue in the order in which the slices enter the ready queue, wherein the trusted dynamic measurement time is less than or equal to the CPU sampling period; S4, releasing the CPU resources of the trusted dynamic measurement thread, and the trusted dynamic measurement thread enters a sleep state until the CPU sampling period ends; S5, repeat S1 to S4.
2. The method for controlling CPU load by a trusted measurement process according to claim 1, characterized in that: In S2, the maximum slice capacity is the maximum number of slices that the CPU performs trusted dynamic measurement within a sampling period.
3. The method for controlling CPU load by a trusted measurement process according to claim 3, characterized in that: In S2, the calculation formula of the maximum slice capacity M is: Among them, T is the CPU occupancy time of the trusted dynamic measurement thread within a sampling period of one week, and t is the time consumed by the CPU to measure a slice.
4. The method for controlling CPU load by a trusted measurement process according to claim 3, characterized in that: The calculation formula of T is: The unit of T is milliseconds, and P% is the CPU utilization during the trusted dynamic measurement within a sampling period of one week, where 0%<P%<100%.
5. The method for controlling CPU load by a trusted measurement process according to claim 1, characterized in that: In S2, the number of slices retrieved from the waiting queue is not greater than the maximum slice capacity.
6. The method for controlling CPU load by a trusted measurement process according to claim 1, characterized in that: In S3, the process of reliable dynamic measurement of all slices in the ready queue is completed at one time.
7. The method for controlling CPU load by a trusted measurement process according to claim 1, characterized in that: In S2, if the number of all slices in the waiting queue is ≤ the maximum slice capacity, all slices in the waiting queue are transferred to the ready queue; if the number of all slices in the waiting queue is greater than the maximum slice capacity, a number of slices are transferred whose number is ≤ the maximum slice capacity.
8. A device for controlling CPU load by a trusted measurement process, characterized in that: include: The slicing module is used to cut each process into several slices of fixed size and put the sliced processes into a waiting queue; The calling module is used to call several slices from the waiting queue and put them in the ready queue; The sum of the slices of the multiple processes is less than or equal to the maximum slice capacity, where the maximum slice capacity is the maximum slice capacity of the ready queue; The measurement module is used to call the trusted dynamic measurement thread to perform trusted dynamic measurement on all slices in the ready queue in turn, and the trusted dynamic measurement time is less than or equal to the sampling period of the CPU; A release module, used to release the CPU resources of the trusted dynamic measurement thread, and the trusted dynamic measurement thread enters a sleep state until the sampling period of the CPU ends; A loop module is used to repeat the slice module, call module, measure module and release module.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method for controlling CPU load by a trusted measurement process according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for controlling CPU load by a trusted measurement process as claimed in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Compute optimizations for low precision machine learning operations
CN113496457A
Trusted measurement method and device, computer equipment and readable medium
CN115964117A
Dynamic trusted measurement method, electronic equipment and storage medium
CN116418593A
METHOD AND ARRANGEMENT FOR SYNCHRONIZING THE TASKS IN PERIPHERAL DEVICES IN A DATA PROCESSING EQUIPMENT
DE2507405A1
Compute optimizations for low precision machine learning operations
EP3396547A2