Jamming processing method and device of computer equipment, medium and computer equipment
By dynamically adjusting the priority of background processes to reasonably allocate CPU resources, the problem of lag in computer equipment in a multi-tasking environment is solved, and the smooth operation of the foreground process and the overall stability of the system is achieved.
Patent Information
- Application Number
- CN202411915127.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2044-12-24
AI Technical Summary
The lag caused by uneven resource allocation in a multitasking environment by computer equipment affects the user experience and may lead to interruptions or delays in important tasks.
By dynamically adjusting the priority of background processes, monitoring the CPU usage of each background process, and degrading its priority when the usage exceeds the preset value, so as to reasonably allocate CPU resources to ensure that the foreground process obtains sufficient resources.
It effectively avoids the lag phenomenon perceived by users, ensures the smooth operation of the foreground process, and avoids excessive limitation of the performance of the background process, and improves the overall response speed and stability of the system.
Smart Images

Figure CN119917232A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method and device for processing a jam of a computer device, a storage medium, and a computer device. Background Art
[0002] With the rapid development of computer technology, users have increasingly higher requirements for the smooth operation of computer devices. However, with the diversification and complexity of application programs, computer devices often encounter jamming problems caused by uneven resource allocation during operation. This jamming not only affects the user experience, but may also cause the interruption or delayed completion of important tasks. Especially in a multi-tasking environment, the competition for CPU resources between background processes and foreground processes is particularly fierce. Although background processes, such as system updates, data synchronization, and background services, are not directly visible to users, their operating 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 the application the user is operating) may become slow to respond due to insufficient CPU time, thereby causing jamming perceived by the user. Summary of the invention
[0003] In view of this, the present application provides a method and device for handling jamming of a computer device, a storage medium, and a computer device. By dynamically adjusting the priority of background processes, CPU resources can be allocated more reasonably to ensure that the foreground process can obtain sufficient resources to maintain smooth operation, thereby avoiding the user's perception of jamming.
[0004] According to one aspect of the present application, a method for processing jamming of a computer device is provided, comprising:
[0005] During the operation of the computer equipment, 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 background process is downgraded so that CPU resources can be allocated according to the priority of each process through the scheduler, wherein before the downgrade, the priorities of the foreground processes and the background processes of the computer device are all normal priorities.
[0007] According to another aspect of the present application, a jamming processing device for a computer device is provided, comprising:
[0008] A monitoring module is used to continuously monitor the CPU usage of each background process during the operation of the computer device;
[0009] A downgrading module is used to downgrade the normal priority corresponding to any background process if the CPU usage of the background process is greater than a preset usage, so as to allocate CPU resources according to the priority of each process through the scheduler, wherein before the downgrading, the priorities of the foreground processes and the background processes of the computer device are all normal priorities.
[0010] According to another aspect of the present application, a storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the above-mentioned method for handling jamming of the computer device is implemented.
[0011] According to another aspect of the present application, a computer device is provided, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the above-mentioned method for processing jams in the computer device when executing the program.
[0012] By means of the above technical scheme, the present application provides a method and device for processing jams in a computer device, a storage medium, and a computer device, which can collect the CPU usage data of each background process in real time or periodically during the operation of the computer device. When it is detected that the CPU usage of a background process exceeds the preset usage, the priority adjustment mechanism can be triggered. Specifically, the priority of the background process can be downgraded from a normal priority to a lower priority. In this way, in the 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 operation, and the background process will obtain fewer resources. The embodiment of the present application can allocate CPU resources more reasonably by dynamically adjusting the priority of the background process, ensuring that the foreground process can obtain sufficient resources to maintain smooth operation, thereby avoiding the user's perception of jams.
[0013] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions 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 schematic flow chart of a method for processing a jam in a computer device provided in an embodiment of the present application is shown;
[0016] Figure 2A schematic diagram of the structure of a computer device jam processing device provided in an embodiment of the present application is shown;
[0017] Figure 3 A schematic diagram of the device structure of a computer device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0018] The present application will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.
[0019] In this embodiment, a method for processing a jam of a computer device is provided. Figure 1 As shown, the method includes:
[0020] Step 101, during the operation 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 any background process is downgraded so that CPU resources are allocated according to the priority of each process through the scheduler, wherein before the downgrade, the priorities of the foreground processes and the background processes of the computer device are all normal priorities.
[0022] During the operation of computer equipment, multitasking is the norm. Foreground processes (programs with interfaces that users can interact with) and background processes (programs without interfaces that users cannot directly operate) can run at the same time and compete for limited CPU resources. When background processes abnormally occupy a large amount of CPU resources, the foreground process may become sluggish due to insufficient CPU time, causing the user to perceive the jamming phenomenon. Based on this, the present application provides a jamming processing method for a computer device, which can effectively monitor the CPU usage of background processes, and dynamically adjust their priorities according to preset usage rates, and allocate CPU resources according to the adjusted priorities through the scheduler to ensure that the foreground process can obtain sufficient resources, thereby avoiding the occurrence of jamming.
[0023] In this embodiment, during the operation of the computer device, the CPU usage data of each background process can be collected in real time or periodically. This can be achieved specifically through the monitoring tool or API provided by the operating system, and the monitored CPU usage data includes but is not limited to the CPU occupancy percentage, usage time, etc. of each background process. In addition, a usage rate can be preset, and the preset usage rate can be determined based on factors such as the performance of the computer device and the user's usage habits to determine whether the background process occupies resources abnormally. The preset usage rate can ensure that the resource occupation of the background process can be effectively limited without affecting the execution of its normal functions.
[0024] When it is detected that the CPU usage of a background process exceeds the preset usage, 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 the subsequent CPU resource allocation, the scheduler can allocate CPU resources according to the new priority order, that is, the foreground process will obtain enough resources to maintain smooth operation, while the background process will obtain fewer resources. Among them, the scheduler is the core component responsible for resource allocation in the operating system, which can allocate CPU resources according to the priority of each process.
[0025] It should be noted that for Windows systems, the processes on the system are usually of normal priority. Whether it is a foreground process or a background process, the scheduler can fairly schedule CPU resources to allocate to these processes. If the background process suddenly and continuously occupies a high CPU, the foreground process may not be scheduled. If the foreground process cannot be scheduled, then for the user, the operation will not respond, and there will be a jam. For the user, the response of the foreground process is very important, so the background process should not continue to occupy a high CPU resource. The priority of the background process should be reduced from the normal priority to a lower than normal priority, so the scheduler can prioritize the foreground process (that is, prioritize the user's active operation), and the jam will be solved. Since the user's operation usually requires very little CPU resources, the impact on the background process is almost zero.
[0026] By applying the technical solution of this embodiment, the CPU usage data of each background process can be collected in real time or periodically during the operation of the computer device. When it is detected that the CPU usage of a background process exceeds the preset usage, 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 the subsequent CPU resource allocation, the scheduler can allocate CPU resources according to the new priority order, that is, the foreground process will obtain enough resources to maintain smooth operation, and the background process will obtain fewer resources. The embodiment of the present application can allocate CPU resources more reasonably by dynamically adjusting the priority of the background process, ensuring that the foreground process can obtain enough resources to maintain smooth operation, thereby avoiding the user's perception of the jamming phenomenon.
[0027] In an embodiment of the present application, optionally, after downgrading the normal priority corresponding to any background process, the method further includes: continuing to monitor the CPU usage of any background process, and when the CPU usage of any background process is less than or equal to the preset usage, restoring the priority corresponding to any background process to the normal priority.
[0028] In this embodiment, during the operation of the computer device, the CPU usage of each background process can be continuously and uninterruptedly monitored to ensure that changes in the resource occupancy of the background process can be captured in real time. Therefore, after a background process is downgraded due to excessive CPU usage, the CPU usage of the downgraded background process can also continue to be monitored. When the CPU usage of the process is monitored to drop below the preset usage (or equal to the preset usage), the priority recovery mechanism can be triggered. At this time, the priority of the background process can be restored from the lower priority after the downgrade to the normal priority, that is, in the subsequent CPU resource allocation, the background process will compete for resources with other normal priority processes without being subject to additional restrictions. Here, priority recovery can be immediate or at the beginning of the next scheduling cycle, which is not limited here.
[0029] The embodiment of the present application can ensure that resources are reasonably allocated between the foreground process and the background process by continuously monitoring the CPU usage of the background process and dynamically adjusting its priority. This not only ensures the smooth operation of the foreground process, but also avoids excessively restricting the performance of the background process. The priority recovery mechanism enables the background process to return to a normal working state when a large amount of resources is not needed, thereby improving the overall response speed and stability of the system.
[0030] In an embodiment of the present application, optionally, the computer device is installed with a Windows system; the method also includes: in response to a response rate display instruction, starting a response rate calculation process with a target priority in the Windows system, wherein the target priority is higher than the normal priority; initializing a time variable and a loop count variable to assign the time variable to the current first system time, and assigning the loop count variable to zero; starting a loop thread in the response rate calculation process, and using the Windows mechanism to start the timer, and calculating the response rate of the computer device based on the loop thread, the timer, the first system time, and the number of cycles recorded by the loop count variable; displaying the calculated response rate on the display interface of the computer device, reassigning the time variable to the current first system time, and assigning the loop count variable to zero, and again calculating the response rate of the computer device based on the loop thread, the timer, the new first system time, and the number of cycles recorded by 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 this embodiment, the computer device may be installed with a Windows system, which is the basic environment for performing subsequent operations. When the computer device receives the response rate display instruction, a response rate calculation process is started in the Windows system with a target priority. Here, the target priority is higher than the normal priority, that is, the process is given a higher execution right so that the response rate calculation task can be completed more promptly. Among them, the response rate display instruction can be triggered by the user through a certain interface (such as a button, menu, etc.), or it can be automatically triggered after the computer device is turned on. After starting the response rate calculation process, two variables can be initialized: a time variable and a loop count variable. During the initialization process, the time variable is assigned to the current first system time, and the loop count variable is assigned to zero to record the number of cycles.
[0032] Subsequently, a loop thread can be started in the response rate calculation process, and this thread is responsible for executing the subsequent response rate calculation tasks. Here, the loop thread can be a thread with a window. A timer is started using the Windows mechanism under the loop thread, and this timer will be used to trigger the response rate calculation cycle within a fixed preset time interval. After that, the response rate of the computer device can be calculated based on the loop thread and the timer. Specifically, each time the timer is triggered, it can be determined whether the response rate can be calculated through the loop thread. Every time 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] Next, the time variable is reassigned to the current first system time, and the loop count variable is reassigned 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 number of cycles recorded by the loop count variable, and the step of displaying the response rate is returned. This process will be repeated until a 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 it can be automatically triggered when the computer device is shut down.
[0034] In the Windows system environment, the embodiment of the present application starts a response rate calculation process, uses a loop thread and a timer, etc. to calculate and display the response rate of a computer device in real time, so that the calculation and display of the response rate are dynamic and real-time, and can provide users with intuitive feedback on system performance.
[0035] In an 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 number of cycles recorded by the loop number variable" includes: when the timing time of the timer reaches a preset time interval, based on the loop thread, the number of cycles corresponding to the loop number variable is increased by one; 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 the 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, wait for the timing time of the timer to reach the preset time interval again, and based on the loop thread, the number of cycles corresponding to the loop number variable is increased by one again, the current second system time is re-acquired, and the time difference between the new second system time and the first system time is calculated, 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 number of cycles corresponding to when the time difference is 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 may be responsible for triggering each response rate calculation cycle. Each time when the calculation time of the timer reaches a preset time interval, the loop thread may perform the following operations:
[0040] (1) Increase the number of loops corresponding to the loop count variable by one, that is, the number of loops increases once each time the timer is triggered.
[0041] (2) Obtain the current second system time, that is, the system time when the timer is triggered.
[0042] (3) Calculate the time difference between the second system time and the first system time (ie, the system 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 demand and is used to limit the benchmark time for each monitoring response rate.
[0044] If the time difference is greater than the first preset time threshold, it means that the reference time for monitoring the response rate has passed, and the response rate can be calculated.
[0045] If the time difference is less than or equal to the first preset duration threshold, continue to wait for the next triggering of the timer and repeat the above process (ie, increase the number of cycles and check the time difference again).
[0046] The response rate calculation formula is: rate = 100*time_count / (kDelay / kTimes)
[0047] It can be seen from the response rate calculation formula that within a specified time length (kDelay), the more cycles (time_count) there are, the faster the device processes tasks, and the higher the response rate. The formula calculates the ratio of the number of cycles actually completed during this period to the number of cycles that should be completed theoretically (kDelay / kTimes), and then multiplies it by 100 to obtain the percentage of the response rate. The embodiment of the present application uses this response rate calculation method to accurately determine the current response status of the computer device and quantify the response status, thereby providing users with more intuitive feedback on system performance.
[0048] In an embodiment of the present application, optionally, step 101 includes: during the operation of the computer device, continuously monitoring the CPU resource occupancy of the foreground process; when the CPU resource occupancy of the foreground process is greater than the foreground reserved resources, allocating the remaining CPU resources 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 resources are determined based on the total CPU resources and the foreground reserved resources.
[0049] In this embodiment, during the operation of the computer device, the CPU resource occupancy 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 open application, game or browser. The smooth operation of these processes is crucial to the user experience. In order to ensure that the foreground process has enough resources to maintain its performance and response speed, a portion of CPU resources can be reserved for it, and this portion of reserved resources is usually determined based on the needs of the foreground process and the overall performance of the device. When it is detected that the CPU resource occupancy of the foreground process exceeds the resources reserved for it, it means that the foreground process may need more resources to maintain its operation. 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. The remaining CPU resources here refer to 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 status of these processes and prevent them from excessively occupying 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 continued to ensure the normal operation of the foreground process. The embodiments of the present application aim to ensure that the foreground process has sufficient resources to provide a good user experience, improve the operating efficiency of the device and the user's satisfaction through a dynamic resource management and allocation mechanism.
[0050] In an embodiment of the present application, optionally, as stated in step 101, "during the operation of the computer device", the method further includes: 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 duration threshold, sending a sleep signal to any background process to change the state of any background process to a sleep state; accordingly, the method further includes: when a call instruction of any background process is received, sending a wake-up signal to any background process to change the state of any background process to a wake-up state, and allocating CPU resources through the scheduler according to the normal priority of any background process.
[0051] In this embodiment, during the operation of the computer device, the unused time of the background process can also be monitored. Specifically, the last active time of each background process can be continuously monitored. Wherein, the last active time refers to the time point when the background process last performed an operation or responded to a system event. Continuously monitoring this time point is crucial for understanding the activity and necessity of the background process. By continuously monitoring the last active time of each background process, it is possible to understand which processes are active and which processes may no longer be needed or have not been used for a long time. Afterwards, the unused time of each background process can be calculated based on the last active time. Wherein, the unused time refers to the interval time from the last active 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 active time of the background process and 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 time threshold, it is considered that the background process may no longer be needed or has not been used for a long time, so it can be put into a dormant state to save resources. After the dormancy conditions are met, a dormancy signal can be sent to the background process. This signal is an instruction that tells the background process to enter a dormant state. After receiving the dormancy signal, the background process can perform corresponding operations to change its state from an active state to a dormant state. In the dormant state, the background process no longer occupies CPU resources, but it is still retained in memory so that it can be quickly awakened when needed. In this case, a certain amount of CPU resources can be released.
[0053] Afterwards, when a call instruction is received for a background process in a dormant state, it means that the background process is now needed, and a wake-up signal can be sent to the background process. This signal is an instruction that tells the background process to recover from a dormant state to an active state. After receiving the wake-up signal, the background process can perform corresponding operations to change its state from a dormant state to an active state. At the same time, the scheduler allocates CPU resources to the background process according to its normal priority to ensure that it can execute normally. The embodiment of the present application dynamically adjusts its state to save resources by monitoring the activity and necessity of the background process. When the background process is not used for a long time, it is put into a dormant state to release CPU resources; and when needed, it can be quickly awakened and the necessary resources can be allocated. This strategy helps to further improve the utilization of CPU resources.
[0054] In an embodiment of the present application, optionally, after the "if the CPU usage rate of any background process is greater than a preset usage rate" in step 102, the method further includes: extracting process features corresponding to 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 any background process; when the identification result indicates that any background process is a malicious process, terminating any background process; when the identification result indicates that any background process is not a malicious process, downgrading the normal priority corresponding to any background process.
[0055] In this embodiment, if it is found that the CPU usage rate of a background process is too high during the monitoring process, before the priority is downgraded, it can also be determined whether the background process is a malicious process, because malicious processes often have high CPU usage. Specifically, when the CPU usage rate of a background process is too high, the process features corresponding to the background process can be extracted. Here, 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. Among them, the process startup path feature is used to indicate the startup path or executable file location of the background process; the process startup parameter feature is used to indicate the parameters used when starting the background process; the process interaction data feature is used to indicate the way and content of the background process to interact with other processes or system components; the process communication data feature is used to indicate the way and content of the background process to communicate with other processes, such as network communication, pipeline communication, etc.; the resource usage data feature is used to indicate the use of system resources (such as CPU, memory, disk, etc.) by the background process. These extracted process features can be subsequently input into the malicious process identification model for identification.
[0056] Here, a malicious process identification model can be pre-trained, specifically a machine learning or deep learning model, which can identify whether a background process is a malicious process based on the input process features. Specifically, the process startup path features, process startup parameter features, process interaction data features, process communication data features, and resource usage data features of the malicious process can be collected in advance, and then the machine learning model or deep learning model is trained with these data to finally obtain a malicious process identification model.
[0057] Therefore, the extracted process features are input into the malicious process identification model, and the model can perform calculations and judgments based on these 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 terminated 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 terminated immediately, and the normal priority of the background process can be downgraded.
[0058] The embodiment of the present application extracts process features and uses a malicious process identification model to identify the process, and then takes corresponding measures based on the identification results. This strategy helps to timely discover and handle potential malicious processes. At the same time, reasonable downgrade measures are also taken for non-malicious processes with excessive CPU usage to balance the security and performance of the system.
[0059] Further, another method for calculating the response rate is provided, the method comprising:
[0060] 1. Start a response rate calculation process on Windows system with a higher priority (ABOVE_NORMAL_PRIORITY_CLASS);
[0061] 2. Initialization: c0_time = current system time; time_count = 0 (number of cycles);
[0062] 3. Start a loop thread with a window, and use the Windows mechanism Timer to start a timer (with a fixed interval of 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 make a difference with (c0_time). If the interval is greater than kDelay milliseconds, continue to execute 3.3; otherwise, interrupt from the current state and wait for the loop to restart from 3.1;
[0065] 3.3: Actual calculation 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 cycle to restart from 3.1.
[0068] Further, as Figure 1The specific implementation of the method, the embodiment of the present application provides a computer device jam processing device, such as Figure 2 As shown, the device comprises:
[0069] A monitoring module is used to continuously monitor the CPU usage of each background process during the operation of the computer device;
[0070] A downgrading module is used to downgrade the normal priority corresponding to any background process if the CPU usage of the background process is greater than a preset usage, so as to allocate CPU resources according to the priority of each process through the scheduler, wherein before the downgrading, the priorities of the foreground processes and the background processes of the computer device are all normal priorities.
[0071] Optionally, the monitoring module is further used to:
[0072] After downgrading the normal priority level corresponding to any background process, continue to monitor the CPU usage of any background process, and when the CPU usage of any background process is less than or equal to the preset usage level, restore the priority level corresponding to any background process to the normal priority level.
[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 used to:
[0074] In response to the response rate display instruction, starting a response rate calculation process at a target priority in the Windows system, wherein the target priority is higher than the normal priority;
[0075] Initializing a time variable and a loop count variable to assign the time variable to the current first system time and to assign the loop count variable to zero;
[0076] In the response rate calculation process, a loop thread is started, and a timer is started by using a Windows mechanism, and the response rate of the computer device is calculated based on the loop thread, the timer, the first system time, and the number of cycles recorded by the cycle number variable;
[0077] The calculated response rate is displayed on the display interface of the computer device, the time variable is reassigned to the current first system time, and the loop number variable is assigned to zero, and the response rate of the computer device is calculated again based on the loop thread, the timer, the new first system time and the number of loops recorded by the loop number variable, and the process returns 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 used to:
[0079] When the timing time of the timer reaches a preset time interval, the number of loops corresponding to the loop number variable is increased by one based on the loop thread;
[0080] Obtaining the current second system time, and calculating the 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, calculating 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 duration threshold, wait for the timing time of the timer to reach the preset time interval again, and increase the number of loops corresponding to the loop number variable by one again based on the loop thread, re-acquire the current second system time, calculate the time difference between the new second system time and the first system time, and until the time difference is greater than the first preset duration threshold, calculate the response rate of the computer device according to the response rate calculation formula;
[0083] 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 number of cycles corresponding to when the time difference is 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 used to:
[0087] During the operation of the computer equipment, the CPU resource usage of the foreground process is continuously monitored;
[0088] When the CPU resource occupancy of the foreground process is greater than the foreground reserved resources, the scheduler allocates the remaining CPU resources to the foreground process and the background process according to the priority of each process, and continuously monitors the CPU usage of each background process, wherein the remaining CPU resources are determined based on the total CPU resources and the foreground reserved resources.
[0089] Optionally, the monitoring module is further used to:
[0090] During the operation of the computer device, 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;
[0091] When the unused time corresponding to any background process is greater than a second preset time threshold, sending a sleep signal to the any background process to change the state of the any background process to a sleep state;
[0092] Accordingly, the device further comprises a recovery module; the recovery module is used to:
[0093] When a call instruction of any background process is received, a wake-up signal is sent to any background process to change the state of any background process to a wake-up state, and CPU resources are allocated according to the normal priority of any background process through the scheduler.
[0094] Optionally, the device further includes a malicious process identification module; the malicious process identification module is used to:
[0095] If the CPU usage rate of any background process is greater than a preset usage rate, extracting a process feature corresponding to the any background process, wherein the process feature includes 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] Inputting the process features into a pre-trained malicious process identification model to obtain an identification result corresponding to any background process;
[0097] When the identification result indicates that any background process is a malicious process, terminating any background process;
[0098] When the identification result indicates that any background process is not a malicious process, a normal priority level corresponding to any background process is downgraded.
[0099] It should be noted that for other corresponding descriptions of the functional units involved in the computer device jam processing device provided in the embodiment of the present application, reference can be made to Figure 1 The corresponding description in the method will not be repeated here.
[0100] The present application also provides a computer device, which may be a personal computer, a server, a network device, etc. Figure 3As shown, the computer device includes a bus, a processor, a memory and a communication interface, and may also include an input and output interface and a display device. Among them, the processor of the computer device is used 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 the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store location information. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the steps in each method embodiment are implemented.
[0101] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may 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. The computer-readable storage medium may be non-volatile or volatile, and stores a computer program thereon. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0103] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[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 used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully 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, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the 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 (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0106] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0107] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for processing jamming of a computer device, characterized in that: include: During the operation of the computer equipment, the CPU usage of each background process is continuously monitored; If the CPU usage of any background process is greater than the preset usage, the normal priority corresponding to the background process is downgraded so that CPU resources can be allocated according to the priority of each process through the scheduler, wherein before the downgrade, the priorities of the foreground processes and the background processes of the computer device are all normal priorities.
2. The method according to claim 1, characterized in that After downgrading the normal priority corresponding to any background process, the method further includes: Continue to monitor the CPU usage of any background process, and when the CPU usage of any background process is less than or equal to the preset usage, restore the priority corresponding to any background process to the normal priority.
3. The method according to claim 1, characterized in that: The computer device is installed with Windows system; the method further comprises: In response to the response rate display instruction, starting a response rate calculation process at a target priority in the Windows system, wherein the target priority is higher than the normal priority; Initializing a time variable and a loop count variable to assign the time variable to the current first system time and to assign the loop count variable to zero; In the response rate calculation process, a loop thread is started, and a timer is started by using a Windows mechanism, and the response rate of the computer device is calculated based on the loop thread, the timer, the first system time, and the number of cycles recorded by the cycle number variable; The calculated response rate is displayed on the display interface of the computer device, the time variable is reassigned to the current first system time, and the loop number variable is assigned to zero, and the response rate of the computer device is calculated again based on the loop thread, the timer, the new first system time and the number of loops recorded by the loop number variable, and the process returns to the step of displaying the calculated response rate on the display interface of the computer device until a stop display instruction is received.
4. The method according to claim 3, characterized in that The calculating the response rate of the computer device based on the loop thread, the timer, the first system time, and the number of loops recorded by the loop number variable includes: When the timing time of the timer reaches a preset time interval, the number of loops corresponding to the loop number variable is increased by one based on the loop thread; Obtaining the 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 is less than or equal to the first preset duration threshold, wait for the timing time of the timer to reach the preset time interval again, and increase the number of loops corresponding to the loop number variable by one again based on the loop thread, re-acquire the current second system time, calculate the time difference between the new second system time and the first system time, and until the time difference is greater than the first preset duration threshold, calculate the response rate of the computer device 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 number of cycles corresponding to when the time difference is greater than the first preset time threshold, kDelay represents the first preset time threshold, and kTimes represents the preset time interval.
5. The method according to claim 1, characterized in that: The method of continuously monitoring the CPU usage of each background process during the operation of the computer device includes: During the operation of the computer equipment, the CPU resource usage of the foreground process is continuously monitored; When the CPU resource occupancy of the foreground process is greater than the foreground reserved resources, the scheduler allocates the remaining CPU resources to the foreground process and the background process according to the priority of each process, and continuously monitors the CPU usage of each background process, wherein the remaining CPU resources are determined based on the total CPU resources and the foreground reserved resources.
6. The method according to claim 1, characterized in that During the operation of the computer device, the method further includes: 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, sending a sleep signal to the any background process to change the state of the any background process to a sleep state; Accordingly, the method further comprises: When a call instruction of any background process is received, a wake-up signal is sent to any background process to change the state of any background process to a wake-up state, and CPU resources are allocated according to the normal priority of any background process through the scheduler.
7. The method according to claim 1, characterized in that If the CPU usage rate of any background process is greater than a preset usage rate, the method further includes: Extracting a process feature corresponding to any one of the background processes, wherein the process feature includes 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; Inputting the process features into a pre-trained malicious process identification model to obtain an identification result corresponding to any background process; When the identification result indicates that any background process is a malicious process, terminating any background process; When the identification result indicates that any background process is not a malicious process, a normal priority level corresponding to any background process is downgraded.
8. A computer device jam processing device, characterized in that: include: A monitoring module is used to continuously monitor the CPU usage of each background process during the operation of the computer device; A downgrading module is used to downgrade the normal priority corresponding to any background process if the CPU usage of the background process is greater than a preset usage, so as to allocate CPU resources according to the priority of each process through the scheduler, wherein before the downgrading, the priorities of the foreground processes and the background processes of the computer device are all normal priorities.
9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. A computer device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Resource processing method and device, computer readable storage medium and mobile terminal
CN107391259A
Resource management method and device, mobile terminal and computer readable storage medium
CN107526640A
Application program processing method and device, electronic equipment and computer readable storage medium
CN109992370A
Information processing method and device, computer equipment and computer readable storage medium
CN109992438A
Process control method and device, storage medium and electronic equipment
CN111309400A