Chugging processing method and device of computer equipment, medium and computer equipment

By monitoring and dynamically adjusting the CPU usage and priority of background processes, the problem of lag caused by resource contention in foreground processes in computer devices is solved, ensuring that foreground processes obtain sufficient resources and improving the system's response speed and stability.

CN119917232BActive Publication Date: 2025-11-07CHENGDU MEGAYOU TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411915127.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-11-07
Estimated Expiration
2044-12-24

AI Technical Summary

Technical Problem

In a multitasking environment, computer devices experience lag due to intense competition for CPU resources between background and foreground processes, leading to slow response times in the foreground processes.

Method used

By monitoring the CPU usage of background processes, their priorities are dynamically adjusted. When the usage exceeds a preset value, their priority is downgraded. In this way, the scheduler can reasonably allocate CPU resources to ensure that foreground processes get enough resources and avoid lag.

Benefits of technology

It effectively avoids lag in the foreground process, improves system response speed and stability, and avoids excessive restrictions on background processes, thereby improving overall resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917232B_ABST
    Figure CN119917232B_ABST
Patent Text Reader

Abstract

The application discloses a computer device lag processing method and device, a storage medium and a computer device. The method comprises the following steps: continuously monitoring the CPU usage of each background process during the running of the computer device; if the CPU usage of any background process is greater than a preset usage, performing a downgrade process on the normal priority corresponding to the any background process, so as to allocate CPU resources to each process according to the priority of each process by a scheduler, wherein the priority of each foreground process and each background process of the computer device is a normal priority before the downgrade. By dynamically adjusting the priority of the background process, the CPU resources can be more reasonably allocated, the foreground process can obtain sufficient resources to maintain smooth running, and thus the user can avoid the perception of the lag phenomenon.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a computer device lag processing method and device, storage medium and computer device. BACKGROUND

[0002] In the rapid development of computer technology, users increasingly require the running fluency of computer devices. However, with the diversification and complexity of application programs, computer devices often encounter lag problems caused by uneven resource allocation during operation. Such lag not only affects user experience, but also may cause important tasks to be interrupted or delayed. In particular, in a multitasking environment, the competition for CPU resources between background processes and foreground processes is particularly fierce. Background processes, such as system updates, data synchronization, background services, etc., although not directly visible to users, their running efficiency directly affects the stability and response speed of the overall system. For example, when a background process abnormally occupies a large amount of CPU resources, the foreground process (such as an application that the user is currently operating) may become sluggish because it does not get enough CPU time, thereby causing the user to perceive the lag phenomenon. SUMMARY

[0003] Therefore, the present application provides a computer device lag processing method and device, storage medium and computer device, which can more reasonably allocate CPU resources by dynamically adjusting the priority of background processes, ensuring that foreground processes can obtain sufficient resources to maintain smooth operation, thereby avoiding the user from perceiving the lag phenomenon.

[0004] According to one aspect of the present application, a computer device lag processing method is provided, comprising:

[0005] During the operation of the computer device, the CPU usage of each background process is continuously monitored;

[0006] If the CPU usage of any background process is greater than the preset usage, the normal priority corresponding to the any background process is downgraded to allocate CPU resources according to the priority of each process through the scheduler, wherein the priority of each foreground process and each background process of the computer device is a normal priority before downgrading.

[0007] According to another aspect of the present application, a computer device lag processing device is provided, comprising:

[0008] A monitoring module is configured to continuously monitor the CPU usage of each background process during the operation of the computer device;

[0009] The degradation module is configured to degrade the normal priority corresponding to any background process if the CPU usage of the background process is greater than the preset usage, so that the CPU resource is allocated to each process according to the priority of the process by the scheduler.

[0010] According to another aspect of the present application, a storage medium is provided, which stores a computer program. The program is executed by a processor to implement the method for processing frame freezing of a computer device.

[0011] According to another aspect of the present application, a computer device is provided, which comprises a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor. The processor implements the method for processing frame freezing of a computer device when executing the program.

[0012] By the above technical solution, the method and device for processing frame freezing of a computer device, the storage medium, and the computer device are provided. During the running of the computer device, the CPU usage data of each background process can be collected in real time or periodically. When the CPU usage of a background process is detected to be greater than the preset usage, the priority adjustment mechanism can be triggered. Specifically, the priority of the background process can be degraded from the normal priority to a lower priority. In the subsequent allocation of CPU resources, the scheduler can allocate the CPU resources according to the new priority order, that is, the foreground process can obtain sufficient resources to maintain smooth running, and the background process can obtain less resources. The priority of the background process is dynamically adjusted in the embodiments of the present application, so that the CPU resources can be more reasonably allocated, the foreground process can obtain sufficient resources to maintain smooth running, and the user can avoid the frame freezing phenomenon.

[0013] The above description is only a summary of the technical solutions of the present application. In order to more clearly understand the technical means of the present application, the embodiments of the present application can be implemented according to the content of the description, and in order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the following specific embodiments of the present application are described. BRIEF DESCRIPTION OF DRAWINGS

[0014] The drawings described herein are used to provide further understanding of the present application, and form a part of the present application. The schematic embodiments of the present application and the description thereof are used to explain the present application, and do not constitute an improper limitation on the present application. In the drawings:

[0015] Figure 1 A flowchart of a method for processing frame freezing of a computer device provided by the embodiments of the present application is shown;

[0016] Figure 2A structural schematic diagram of a computer device is shown.

[0017] Figure 3 A structural schematic diagram of a computer device is shown. DETAILED DESCRIPTION

[0018] The present application will be described in detail below with reference to the accompanying drawings and embodiments. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.

[0019] In the present embodiment, a computer device is provided with a lag processing method, as shown in the figure, the method comprises: Figure 1

[0020] Step 101, during the running of the computer device, continuously monitor the CPU usage of each background process.

[0021] Step 102, if the CPU usage of any background process is greater than the preset usage, the normal priority corresponding to the any background process is downgraded, so that the CPU resources are allocated by the scheduler according to the priority of each process, wherein the priority of each foreground process and each background process of the computer device is normal priority before downgrading.

[0022] During the running of the computer device, multitasking is the norm. Foreground processes (interface, user can interact with the program) and background processes (no interface, user can not directly operate the program) can run at the same time and compete for limited CPU resources. When the background process abnormally occupies a large amount of CPU resources, the foreground process may become slow in response because it cannot get enough CPU time, resulting in the user perceiving the lag phenomenon. Based on this, the present application provides a computer device with a lag processing method, which can effectively monitor the CPU usage of the background process, and dynamically adjust its priority according to the preset usage, and allocate CPU resources by the scheduler according to the adjusted priority, so as to ensure that the foreground process can obtain enough resources, thereby avoiding the occurrence of lag phenomenon.

[0023] ​In this embodiment, during the running of the computer device, the CPU usage rate data of each background process can be collected in real time or periodically. Specifically, the monitoring tool or API provided by the operating system can be used to achieve this. The monitored CPU usage rate data includes but is not limited to the CPU occupancy percentage of each background process, the usage time, etc. In addition, a preset usage rate can also be set, which can be determined according to the performance of the computer device, the user's usage habits and other factors, and is used to determine whether the background process abnormally occupies resources. Through the preset usage rate, it can be ensured that the resource occupation of the background process can be effectively limited, and the normal function execution of the background process will not be affected.

[0024] When it is detected that the CPU usage rate of a certain background process exceeds the preset usage rate, the priority adjustment mechanism can be triggered. Specifically, the priority of the background process can be downgraded from the normal priority to a lower priority. In this way, in subsequent CPU resource allocation, the scheduler can allocate CPU resources according to the new priority order, that is, the foreground process will obtain sufficient resources to maintain smooth running, and the background process will obtain less resources. Among them, the scheduler is the core component of the operating system responsible for resource allocation, which can allocate CPU resources according to the priority of each process.

[0025] It should be noted that for the Windows system, the processes on the system are usually of normal priority, whether they are foreground processes or background processes. The scheduler can fairly allocate CPU resources to these processes. If the background process suddenly occupies a high CPU for a long time, the situation that the foreground process cannot be scheduled may occur. If the foreground process cannot be scheduled, the operation will not respond to the user, and the situation of lagging will occur. For the user, the response of the foreground process is very important, so the priority of the background process should not be reduced from the normal priority to a lower priority than the normal priority. In this way, the scheduler can prioritize the foreground process (that is, the user's active operation is prioritized), and the situation of lagging is solved. Since the user's operation usually only needs a small amount of CPU resources, the impact on the background process is almost zero.

[0026] By applying the technical solution of the embodiment, during the running of the computer device, the CPU usage rate data of each background process can be collected in real time or periodically. When it is detected that the CPU usage rate of a certain background process exceeds the preset usage rate, a priority adjustment mechanism can be triggered. Specifically, the priority of the background process can be degraded from the normal priority to a lower priority. In this way, in subsequent CPU resource allocation, the scheduler can allocate CPU resources according to the new priority order, that is, the foreground process will obtain sufficient resources to maintain smooth running, and the background process will obtain less resources. The embodiment of the present application can more reasonably allocate CPU resources by dynamically adjusting the priority of the background process, ensure that the foreground process can obtain sufficient resources to maintain smooth running, thereby avoiding that the user perceives the phenomenon of lag.

[0027] In the embodiment of the present application, optionally, after the normal priority corresponding to the any background process is degraded, the method further comprises: continuing to monitor the CPU usage rate of the any background process, and when the CPU usage rate of the any background process is less than or equal to the preset usage rate, restoring the priority corresponding to the any background process to the normal priority.

[0028] In this embodiment, during the running of the computer device, the CPU usage rate of each background process can be continuously and uninterruptedly monitored, ensuring that changes in the resource occupation of the background process can be captured in real time. Thus, after a certain background process is degraded due to high CPU usage rate, the CPU usage rate of the degraded background process can continue to be monitored. When it is monitored that the CPU usage rate of the process decreases to below (or equal to) the preset usage rate, a priority restoration mechanism can be triggered, at which time the priority of the background process can be restored from the degraded lower priority to the normal priority, that is, in subsequent CPU resource allocation, the background process will compete for resources with other processes of normal priority, and will no longer be subject to additional restrictions. Here, the priority restoration can be immediate or at the start of the next scheduling period, which is not limited.

[0029] The embodiment of the present application can ensure that resources are reasonably allocated between foreground processes and background processes by continuously monitoring the CPU usage rate of the background process and dynamically adjusting the priority thereof. This not only guarantees the smooth running of the foreground process, but also avoids excessive restriction of the performance of the background process. The priority restoration mechanism enables the background process to restore to the normal working state when a large amount of resources is not required, thereby improving the overall response speed and stability of the system.

[0030] In the embodiment of the present application, the computer device is optionally installed with a Windows system; the method further comprises: in response to a response rate display instruction, starting a response rate calculation process in the Windows system at a target priority, wherein the target priority is higher than the normal priority; initializing a time variable and a loop count variable, to assign the time variable as a current first system time, and to assign the loop count variable as zero; starting a loop thread in the response rate calculation process, and starting a timer by using a Windows mechanism, to calculate the response rate of the computer device based on the loop thread, the timer, the first system time, and the loop count variable; displaying the calculated response rate on a display interface of the computer device, reassigning the time variable as a current first system time, and reassigning the loop count variable as zero, again calculating the response rate of the computer device based on the loop thread, the timer, the new first system time, and the loop count variable, and returning to the step of displaying the calculated response rate on the display interface of the computer device, until a stop display instruction is received.

[0031] In the embodiment, the computer device can be installed with a Windows system, which is a basic environment for performing subsequent operations. When the computer device receives a response rate display instruction, a response rate calculation process is started in the Windows system at a target priority. Here, the target priority is higher than the normal priority, that is, the process is given higher execution right, so as to complete the response rate calculation task more timely. The response rate display instruction can be triggered by a user through a certain interface (such as a button, a menu, etc.), or can be automatically triggered after the computer device is started. After the response rate calculation process is started, two variables, a time variable and a loop count variable, can be initialized. The time variable is assigned as a current first system time, and the loop count variable is assigned as zero, for recording the number of loops.

[0032] Subsequently, a loop thread can be started in the response rate calculation process, which is responsible for performing subsequent response rate calculation tasks. Here, the loop thread can be a thread with a window. A timer is started by using a Windows mechanism under the loop thread, which will be used to trigger the calculation loop of the response rate in a fixed preset time interval. Then, the response rate of the computer device can be calculated based on the loop thread and the timer. Specifically, the loop thread can be used to determine whether the response rate can be calculated each time the timer is triggered. After the loop thread outputs a response rate, the calculated response rate can be displayed on the display interface of the computer device for the user to view.

[0033] Then, the time variable is re-assigned to the current first system time, and the loop count variable is re-assigned to zero. The response rate of the computer device is calculated again based on the loop thread and the timer, the new first system time, and the loop count variable recorded loop count, and returns to the step of displaying the response rate. This process will be repeated until the stop display instruction is received. Here, the stop display instruction can be triggered by the user in some way (such as clicking a stop button), or automatically triggered when the computer device is powered off.

[0034] The embodiment of the present application calculates and displays the response rate of the computer device in real time by starting the response rate calculation process, using a loop thread and a timer, etc. in a Windows system environment, so that the calculation and display of the response rate are dynamic and real-time, and can provide intuitive feedback on system performance for users.

[0035] In the embodiment of the present application, optionally, the "calculating the response rate of the computer device based on the loop thread, the timer, the first system time, and the loop count variable recorded loop count" comprises: when the timing time of the timer reaches the preset time interval, the loop count variable corresponding to the loop count is incremented by one based on the loop thread; the current second system time is obtained, and the time difference between the second system time and the first system time is calculated; if the time difference is greater than a first preset time threshold, the response rate of the computer device is calculated according to the response rate calculation formula; if the time difference is less than or equal to the first preset time threshold, the timing time of the timer is waited to reach the preset time interval again, and the loop count variable corresponding to the loop count is incremented by one again based on the loop thread, the current second system time is obtained again, the time difference between the new second system time and the first system time is calculated, and until the time difference is greater than the first preset time threshold, the response rate of the computer device is calculated according to the response rate calculation formula;

[0036] The response rate calculation formula is as follows:

[0037] rate = 100 * time_count / (kDelay / kTimes);

[0038] Rate represents the response rate, time_count represents the loop count corresponding to the time difference greater than the first preset time threshold, kDelay represents the first preset time threshold, and kTimes represents the preset time interval.

[0039] In this embodiment, the timer can be responsible for triggering each response rate calculation loop. Each time the timer reaches the preset time interval, the loop thread can perform the following operations:

[0040] (1) increase the loop count corresponding to the loop count variable by one, that is, the loop count is increased once per timer trigger.

[0041] (2) obtain the current second system time, that is, the system time at the time of the timer trigger.

[0042] (3) calculate the time difference between the second system time and the first system time (that is, the system time at the time when the time variable is initialized).

[0043] (4) check whether the time difference is greater than a first preset time threshold, wherein the first preset time threshold can be determined according to requirements and is used to limit the reference time of each monitoring response rate.

[0044] If the time difference is greater than the first preset time threshold, it indicates that the reference time of the monitoring response rate has been passed, and the response rate can be calculated.

[0045] If the time difference is less than or equal to the first preset time threshold, the next trigger of the timer is continued to wait, and the above process (that is, increasing the loop count and checking the time difference again) is repeated.

[0046] The response rate calculation formula is: rate = 100 * time_count / (kDelay / kTimes)

[0047] As can be seen from the response rate calculation formula, in a specified time length (kDelay), the more the loop count (time_count) is, the faster the device processes tasks, and the higher the response rate is. The formula calculates the ratio of the actual number of loops completed in this period of time to the number of loops (kDelay / kTimes) that should be theoretically completed, and then multiplies by 100 to obtain the percentage of the response rate. The response rate calculation method in the embodiment of the application can accurately determine the current response of the computer device, quantifies the response, and thus provides more intuitive feedback on system performance for the user.

[0048] In the embodiment of the application, optionally, step 101 comprises: continuously monitoring the CPU resource occupation of the foreground process during the running of the computer device; when the CPU resource occupation of the foreground process is greater than the foreground reserved resource, allocating the remaining CPU resource to the foreground process and the background process according to the priority of each process through the scheduler, and continuously monitoring the CPU usage of each background process, wherein the remaining CPU resource is determined according to the total CPU resource and the foreground reserved resource.

[0049] In this embodiment, during the running of the computer device, the CPU resource occupation of the foreground process can be continuously monitored. The foreground process is usually the process that the user is currently interacting with, such as an opened application, a game or a browser, etc. The smooth running of these processes is crucial for the user experience. In order to ensure that the foreground process can have enough resources to maintain its performance and response speed, a part of CPU resources can be reserved for it, and this part of reserved resources is usually determined based on the demand of the foreground process and the overall performance of the device. When it is detected that the CPU resource occupation of the foreground process exceeds the reserved resources for it, it means that the foreground process may need more resources to maintain its running. At this time, the CPU resources can be reallocated by the scheduler. Specifically, the scheduler can allocate the remaining CPU resources to the foreground process and the background process according to the priority of each process. Here, the remaining CPU resources refer to the part of the total CPU resources minus the foreground reserved resources. After the CPU resources are reallocated, the CPU usage of each background process can be continuously monitored. Monitoring the CPU usage of the background process can help the system understand the running state of these processes and prevent them from occupying too much CPU resources and affecting the performance of the foreground process. If the CPU usage of a background process is abnormally high, the above step 102 can be continuously executed to ensure the normal running of the foreground process. The embodiments of the present application aim to ensure that the foreground process has enough resources to provide a good user experience and improve the running efficiency of the device and the satisfaction of the user through the dynamic resource management and allocation mechanism.

[0050] In the embodiments of the present application, optionally, the "during the running of the computer device" in step 101, the method further comprises: continuously monitoring the last activity time corresponding to each background process, and calculating the unused time corresponding to each background process based on the last activity time and the current third system time; when the unused time corresponding to any background process is greater than a second preset time threshold, a sleep signal is sent to the any background process to change the state of the any background process to a sleep state; accordingly, the method further comprises: when receiving the calling instruction of the any background process, a wake-up signal is sent to the any background process to change the state of the any background process to a wake-up state, and the CPU resources are allocated to the any background process by the scheduler according to the normal priority of the any background process.

[0051] In this embodiment, the unused time of the background processes can also be monitored during the running of the computer device. Specifically, the last activity time of each background process can be continuously monitored. The last activity time refers to the time point at which the background process last performed an operation or responded to a system event. Continuous monitoring of this time point is crucial for understanding the activity and necessity of the background process. By continuously monitoring the last activity time of each background process, it can be understood which processes are active and which processes can no longer be needed or have been unused for a long time. Then, the unused time of each background process can be calculated according to the last activity time. The unused time refers to the interval time from the last activity time of the background process to the current system time (the third system time), which reflects how long the background process has been idle since the last activity. By comparing the last activity time of the background process with the current system time, the unused time of each background process can be calculated.

[0052] When the unused time of any background process exceeds the second preset duration threshold, it is considered that this background process can no longer be needed or has been unused for a long time, and therefore it can be placed in a hibernation state to save resources. After meeting the hibernation condition, a hibernation signal can be sent to the background process. This signal is an instruction that tells the background process to enter the hibernation state. After receiving the hibernation signal, the background process can perform corresponding operations to change its state from the active state to the hibernation state. In the hibernation state, the background process no longer occupies CPU resources, but is still retained in the memory so that it can be quickly awakened when needed, in which case certain CPU resources can be released.

[0053] Then, when receiving a call instruction for a background process in the hibernation state, it is indicated that this background process is now needed, and at this time a wake-up signal can be sent to the background process. This signal is an instruction that tells the background process to recover from the hibernation state to the active state. After receiving the wake-up signal, the background process can perform corresponding operations to change its state from the hibernation state to the active state. At the same time, the scheduler assigns CPU resources to the background process according to its normal priority to ensure that it can perform normally. The embodiments of the present application dynamically adjust the state of the background process to save resources by monitoring the activity and necessity of the background process. When the background process has been unused for a long time, it is placed in the hibernation state to release CPU resources; and when needed, it can be quickly awakened and allocated necessary resources. This strategy helps to further improve the utilization rate of CPU resources.

[0054] Optionally, after the "if the CPU usage of any background process is greater than the preset usage" in step 102, the method further includes: extracting process features corresponding to the any background process, wherein the process features include at least one of process startup path features, process startup parameter features, process interaction data features, process communication data features, and resource usage data features; inputting the process features into a pre-trained malicious process identification model to obtain an identification result corresponding to the any background process; when the identification result indicates that the any background process is a malicious process, ending the any background process; and when the identification result indicates that the any background process is not a malicious process, performing a downgrade process on a normal priority corresponding to the any background process.

[0055] In this embodiment, if it is found in the monitoring process that the CPU usage of a certain background process is too high, the background process can be first judged whether it is a malicious process before the priority downgrade process is performed, because a malicious process often has high CPU usage. Specifically, when the CPU usage of a certain background process is too high, process features corresponding to the background process can be extracted, where the process features refer to various information that can reflect the behavior and attributes of the background process. Here, the process features can include process startup path features, process startup parameter features, process interaction data features, process communication data features, and resource usage data features, etc. The process startup path features are used to indicate the startup path of the background process or the location of the executable file; the process startup parameter features are used to indicate the parameters used when starting the background process; the process interaction data features are used to indicate the way and content of data interaction between the background process and other processes or system components; the process communication data features are used to indicate the way and content of communication between the background process and other processes, such as network communication, pipe communication, etc.; and the resource usage data features are used to indicate the usage of system resources (such as CPU, memory, disk, etc.) by the background process. The extracted process features can be subsequently input into a malicious process identification model for identification.

[0056] Here, a malicious process identification model can be pre-trained, which can be a machine learning or deep learning model, and can identify whether a background process is a malicious process according to the input process features. Specifically, process startup path features, process startup parameter features, process interaction data features, process communication data features, and resource usage data features of malicious processes can be pre-collected, and then the machine learning model or the deep learning model is trained through these data, and finally the malicious process identification model is obtained.

[0057] Thus, the extracted process features are input into the malicious process identification model, the model can calculate and judge according to the features, and then output an identification result. When the identification result indicates that a background process is a malicious process, the background process can be ended immediately to prevent it from continuing to cause damage to the system; when the identification result indicates that a background process is not a malicious process, although its CPU usage is too high, it will not be ended immediately, and the normal priority of the background process can be degraded at this time.

[0058] The embodiment of the application extracts process features and uses a malicious process identification model to identify, and then takes corresponding measures according to the identification result. This strategy helps to discover and handle potential malicious processes in time, and reasonable degradation measures are also taken for non-malicious but high-CPU-usage processes to balance the security and performance of the system.

[0059] Further, another method for calculating the response rate is provided, which comprises:

[0060] 1. Starting a response rate calculation process on a Windows system, starting with a high priority (ABOVE_NORMAL_PRIORITY_CLASS);

[0061] 2. Initialization: c0_time = current system time; time_count = 0 (number of loops);

[0062] 3. Starting a loop thread with a window, using the Windows mechanism Timer to start a timer (interval is a fixed value kTimes milliseconds). The logic of each loop is:

[0063] 3.1: time_count + 1 (record the number of loops, increase by 1 each time);

[0064] 3.2: Get the current system time c1_time, and the difference between (c0_time), if the interval is greater than kDelay milliseconds interval, continue to execute 3.3; otherwise, interrupt from the current and wait for the loop to start from 3.1 to execute again;

[0065] 3.3: Actual calculation of response rate: rate = 100*time_count / (kDelay / kTimes);

[0066] 3.4: time_count is set to zero, and c0_time is updated to the current system time;

[0067] 3.5: Wait for the loop to start from 3.1 again.

[0068] Further, as Figure 1The embodiment of the present application provides a computer device lag processing device, as shown in the method, the device comprises: Figure 2

[0069] a monitoring module, configured to continuously monitor CPU usage of each background process during computer device running;

[0070] a degradation module, configured to perform degradation processing on normal priority corresponding to any background process if the CPU usage of the background process is greater than preset usage, so as to allocate CPU resources according to the priority of each process by a scheduler, wherein the priority of each foreground process and each background process of the computer device is normal priority before degradation.

[0071] Optionally, the monitoring module is further configured to:

[0072] continue to monitor the CPU usage of the any background process after the degradation processing on the normal priority corresponding to the any background process, and restore the priority corresponding to the any background process to the normal priority when the CPU usage of the any background process is less than or equal to the preset usage.

[0073] Optionally, the computer device is installed with a Windows system; the device further comprises a response rate calculation module; the response rate calculation module is configured to:

[0074] start a response rate calculation process with a target priority in the Windows system in response to a response rate display instruction, wherein the target priority is higher than the normal priority;

[0075] initialize a time variable and a loop number variable, so as to assign the time variable to a current first system time and assign the loop number variable to zero;

[0076] start a loop thread in the response rate calculation process, and start a timer by using a Windows mechanism, calculate the response rate of the computer device based on the loop thread, the timer, the first system time and the loop number variable;

[0077] display the calculated response rate on a display interface of the computer device, reassign the time variable to the current first system time and reassign the loop number variable to zero, calculate the response rate of the computer device again based on the loop thread, the timer, the new first system time and the loop number variable, and return to the step of displaying the calculated response rate on the display interface of the computer device until a stop display instruction is received. ​

[0078] Optionally, the response rate calculation module is further configured to:

[0079] when the timing time of the timer reaches the preset time interval, increment the loop count corresponding to the loop count variable based on the loop thread;

[0080] obtain the current second system time, and calculate a time difference between the second system time and the first system time;

[0081] if the time difference is greater than a first preset time threshold, calculate the response rate of the computer device according to a response rate calculation formula;

[0082] if the time difference is less than or equal to the first preset time threshold, wait for the timing time of the timer to reach the preset time interval again, and increment the loop count corresponding to the loop count variable based on the loop thread again, re-obtain the current second system time, calculate a time difference between the new second system time and the first system time, and until the time difference is greater than the first preset time threshold, calculate the response rate of the computer device according to the response rate calculation formula;

[0083] wherein the response rate calculation formula is as follows:

[0084] rate = 100 * time_count / (kDelay / kTimes);

[0085] rate represents the response rate, time_count represents the loop count corresponding to the time difference greater than the first preset time threshold, kDelay represents the first preset time threshold, and kTimes represents the preset time interval.

[0086] Optionally, the monitoring module is further configured to:

[0087] monitor the CPU resource occupation of the foreground process during the running of the computer device;

[0088] when the CPU resource occupation of the foreground process is greater than the foreground reserved resource, allocate the remaining CPU resource to the foreground process and the background process according to the priority of each process through the scheduler, and continuously monitor the CPU usage of each background process, wherein the remaining CPU resource is determined according to the total CPU resource and the foreground reserved resource.

[0089] Optionally, the monitoring module is further configured to:

[0090] The last activity time corresponding to each background process is continuously monitored during running of the computer device, and based on the last activity time and a current third system time, an unused time corresponding to each background process is calculated;

[0091] When the unused time corresponding to any background process is greater than a second preset time threshold, a hibernation signal is sent to the any background process to change a state of the any background process to a hibernation state;

[0092] Correspondingly, the apparatus further includes a recovery module; the recovery module is used for:

[0093] When the calling instruction of the any background process is received, a wake-up signal is sent to the any background process to change the state of the any background process to a wake-up state, and the scheduler is used to allocate CPU resources according to the normal priority of the any background process.

[0094] Optionally, the apparatus further includes a malicious process identification module; the malicious process identification module is used for:

[0095] After the CPU usage rate of the any background process is greater than a preset usage rate, process features corresponding to the any background process are extracted, wherein the process features include at least one of a process startup path feature, a process startup parameter feature, a process interaction data feature, a process communication data feature, and a resource usage data feature;

[0096] The process features are input into a pre-trained malicious process identification model to obtain an identification result corresponding to the any background process;

[0097] When the identification result indicates that the any background process is a malicious process, the any background process is ended;

[0098] When the identification result indicates that the any background process is not a malicious process, a normal priority corresponding to the any background process is subjected to a downgrade processing.

[0099] It should be noted that other corresponding descriptions of the functions of the computer device jitter processing apparatus provided in the embodiments of the present application can be referred to the corresponding descriptions in the method, which will not be repeated here. Figure 1

[0100] The embodiments of the present application further provide a computer device, which can be a personal computer, a server, a network device, etc., such as a personal computer. Figure 3 ​As shown, the computer device includes a bus, a processor, a memory and a communication interface, and can further include an input / output interface and a display device. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The database of the computer device is configured to store location information. The network interface of the computer device is configured to communicate with an external terminal through a network connection. The computer program is executed by the processor to implement the steps in the method embodiments.

[0101] Those skilled in the art can understand that, Figure 3 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0102] In one embodiment, a computer readable storage medium is provided, which can be non-volatile or volatile, and has stored thereon a computer program. The computer program is executed by a processor to implement the steps in the method embodiments described above.

[0103] In one embodiment, a computer program product is provided, which includes a computer program. The computer program is executed by a processor to implement the steps in the method embodiments described above.

[0104] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties.

[0105] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive random access memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric memory (Ferroelectric Random Access Memory, FRAM), phase change memory (Phase Change Memory, PCM), graphene memory, etc. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.

[0106] Any combination of the technical features of the above embodiments can be made. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist contradictory, it should be considered as the scope of the present application.

[0107] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are within the scope of protection of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.

Claims

1. A method for handling lag in computer equipment, characterized in that, The method comprises the following steps: monitoring the CPU usage of each background process during the running of the computer device; if the CPU usage of any background process is greater than a preset usage, performing a downgrade process on the normal priority corresponding to the any background process, so as to allocate CPU resources to each process according to the priority of each process by a scheduler, wherein the priority of each foreground process and each background process of the computer device is normal priority before the downgrade; the computer device is installed with a Windows system; the method further comprises the following steps: starting a response rate calculation process with a target priority in the Windows system in response to a response rate display instruction, wherein the target priority is higher than the normal priority; initializing a time variable and a loop count variable, and assigning the time variable with a current first system time and the loop count variable with zero; starting a loop thread in the response rate calculation process, and starting a timer by a Windows mechanism, and calculating the response rate of the computer device based on the loop thread, the timer, the first system time and the loop count variable, wherein the loop thread is a thread with a window, the timer is used to trigger the calculation loop of the response rate in a fixed preset time interval, and the response rate is displayed on the display interface of the computer device based on the window; displaying the calculated response rate on the display interface of the computer device, reassigning the time variable with the current first system time and the loop count variable with zero, calculating the response rate of the computer device again based on the loop thread, the timer, the new first system time and the loop count variable, and returning to the step of displaying the calculated response rate on the display interface of the computer device until a stop display instruction is received.

2. The method of claim 1, wherein, after the downgrade process on the normal priority corresponding to the any background process, the method further comprises the following steps: continuing to monitor the CPU usage of the any background process, and restoring the priority corresponding to the any background process to the normal priority when the CPU usage of the any background process is less than or equal to the preset usage.

3. The method of claim 1, wherein, the calculation of the response rate of the computer device based on the loop thread, the timer, the first system time and the loop count variable comprises the following steps: when the timing time of the timer reaches the preset time interval, increasing the loop count corresponding to the loop count variable by one based on the loop thread; obtaining a current second system time, and calculating the time difference between the second system time and the first system time; if the time difference is greater than a first preset time threshold, calculating the response rate of the computer device according to a response rate calculation formula. If the time difference value is less than or equal to a first preset time threshold, the counting time of the timer is waited to reach the preset time interval again, the loop count corresponding to the loop count variable is increased by one again based on the loop thread, the current second system time is reacquired, the time difference value between the new second system time and the first system time is calculated, and until the time difference value is greater than the first preset time threshold, the response rate of the computer device is calculated according to the response rate calculation formula. The response rate calculation formula is as follows: Rate = 100 * time_count / (kDelay / kTimes); Rate represents the response rate, time_count represents the loop count corresponding to the time difference value greater than the first preset time threshold, kDelay represents the first preset time threshold, and kTimes represents the preset time interval.

4. The method of claim 1, wherein, The CPU usage of each background process is continuously monitored during the running of the computer device, including: The CPU resource occupation of the foreground process is continuously monitored during the running of the computer device. When the CPU resource occupation of the foreground process is greater than the foreground reserved resource, the remaining CPU resource is allocated to the foreground process and the background process according to the priority of each process through the scheduler, and the CPU usage of each background process is continuously monitored, wherein the remaining CPU resource is determined according to the total CPU resource and the foreground reserved resource.

5. The method of claim 1, wherein, The method further includes: The last activity time corresponding to each background process is continuously monitored, and the unused time corresponding to each background process is calculated based on the last activity time and the current third system time. When the unused time corresponding to any background process is greater than a second preset time threshold, a sleep signal is sent to the any background process to change the state of the any background process to a sleep state. Correspondingly, the method further includes: When the calling instruction of the any background process is received, a wake-up signal is sent to the any background process to change the state of the any background process to a wake-up state, and the CPU resource is allocated to the any background process according to the normal priority of the any background process through the scheduler.

6. The method of claim 1, wherein, The method further includes: Extracting the process features corresponding to the any background process, wherein the process features include at least one of process startup path features, process startup parameter features, process interaction data features, process communication data features, and resource usage data features; Inputting the process features into a pre-trained malicious process identification model to obtain an identification result corresponding to the any background process; When the identification result indicates that the any background process is a malicious process, ending the any background process; When the identification result indicates that the any background process is not a malicious process, performing a downgrade process on the normal priority corresponding to the any background process.

7. A device for handling frame freezing of a computer device, characterized in that, Including: The monitoring module is configured to monitor the CPU usage of each background process during the running of the computer device; The degradation module is configured to degrade the normal priority corresponding to any background process if the CPU usage of the background process is greater than a preset usage, so that the CPU resource is allocated to each process according to the priority of the process by the scheduler, wherein the priority of each foreground process and each background process of the computer device is the normal priority before degradation. The computer device is installed with a Windows system; the device further comprises a response rate calculation module; the response rate calculation module is configured to: Start a response rate calculation process in the Windows system at a target priority in response to a response rate display instruction, wherein the target priority is higher than the normal priority; Initialize a time variable and a loop count variable, and assign the time variable to a current first system time and the loop count variable to zero; Start a loop thread in the response rate calculation process, and start a timer by using a Windows mechanism, and calculate the response rate of the computer device based on the loop thread, the timer, the first system time, and the loop count recorded by the loop count variable; Display the calculated response rate on the display interface of the computer device, reassign the time variable to the current first system time and the loop count variable to zero, calculate the response rate of the computer device again based on the loop thread, the timer, the new first system time, and the loop count recorded by the loop count variable, and return to the step of displaying the calculated response rate on the display interface of the computer device until a stop display instruction is received.

8. A storage medium having stored thereon a computer program, characterized in that The computer program is executed by the processor to implement the method of any one of claims 1 to 6.

9. A computer device comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, characterized in that, The processor executes the computer program to implement the method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Process control method and device, storage medium and electronic equipment

    CN111309400A

  • Process management method, electronic equipment and readable storage medium

    CN117707718A