CN118051113A - Power saving method and device for threads and storage medium - Google Patents

Power saving method and device for threads and storage medium Download PDF

Info

Publication number
CN118051113A
CN118051113A CN202211428956.2A CN202211428956A CN118051113A CN 118051113 A CN118051113 A CN 118051113A CN 202211428956 A CN202211428956 A CN 202211428956A CN 118051113 A CN118051113 A CN 118051113A
Authority
CN
China
Prior art keywords
thread
main processing
processing function
preset
power saving
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211428956.2A
Other languages
Chinese (zh)
Inventor
陈学伟
过晓春
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China United Network Communications Group Co Ltd
Unicom Digital Technology Co Ltd
Unicom Cloud Data Co Ltd
Original Assignee
China United Network Communications Group Co Ltd
Unicom Digital Technology Co Ltd
Unicom Cloud Data Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China United Network Communications Group Co Ltd, Unicom Digital Technology Co Ltd, Unicom Cloud Data Co Ltd filed Critical China United Network Communications Group Co Ltd
Priority to CN202211428956.2A priority Critical patent/CN118051113A/en
Publication of CN118051113A publication Critical patent/CN118051113A/en
Pending legal-status Critical Current

Links

Landscapes

  • Power Sources (AREA)

Abstract

The application provides a power saving method, a device and a storage medium for threads, relates to the technical field of computer storage, and can save the consumption electric quantity of a CPU to the greatest extent under the condition that an input/output IO thread ensures high read-write and low-delay working efficiency. The method comprises the following steps: monitoring continuous idle times of a main processing function operated by an IO thread in the operation process of the IO thread of the CPU, wherein the main processing function is used for processing a service to be processed of the IO thread; and controlling the IO thread to enter a dormant state in response to the fact that the continuous idling frequency of the main processing function is greater than or equal to the preset frequency.

Description

Power saving method and device for threads and storage medium
Technical Field
The present application relates to the field of computer storage technologies, and in particular, to a method and apparatus for saving power for a thread, and a storage medium.
Background
In the current storage framework, in order to pursue high-performance read-write efficiency, an IO processing thread is generally bound on a central processing unit CPU separately, and works in a manner of always circularly running a main processing function. Once the service to be processed is detected, the processing of the IO thread can be immediately obtained, and the working efficiency of high reading and writing and low time delay is ensured.
However, this mode of operation keeps the IO processing threads running at a high level, resulting in a CPU consuming a large amount of power. Under the condition of ensuring the high read-write and low-delay working efficiency of the thread, how to reduce the power consumption of the CPU becomes a technical problem to be solved.
Disclosure of Invention
The application provides a power saving method, a device and a storage medium for threads, which are used for reducing the power consumption of a CPU (Central processing Unit) on the premise that an IO thread ensures high read-write and low-delay work efficiency.
To achieve the above object. The application adopts the following technical scheme:
In a first aspect, a method for saving power for a thread is provided, the method comprising: monitoring continuous idle times of a main processing function operated by the IO thread in the operation process of the IO thread of the CPU, wherein the main processing function is used for processing a service to be processed of the IO thread; and controlling the IO thread to enter a dormant state in response to the fact that the continuous idling frequency of the main processing function is greater than or equal to the preset frequency.
According to the technical scheme provided by the embodiment of the application, whether the IO thread is in a leisure state at the moment is judged according to the continuous idle times of the main processing function by detecting the continuous idle times of the main processing function, and whether the IO thread needs to enter a dormant state is further judged. Therefore, the power saving method provided by the embodiment of the application can control the IO thread to enter the dormant state under the condition that the normal work of the IO thread is not influenced, so that the electric quantity consumed by a CPU is reduced, and the power saving effect is realized.
As one possible implementation manner, monitoring the continuous idle times of the main processing function operated by the IO thread includes: judging whether the IO thread has a service to be processed or not in the process of running the main processing function once; and under the condition that the IO thread does not have the service to be processed, determining the current running of the main processing function to be idle.
As one possible implementation, the preset number of times is determined according to the following manner: acquiring an idling record of the main processing function, wherein the idling record is used for recording the time of each idling occurrence of the main processing function in a historical time period; generating a distribution probability function of continuous idling times according to the idling record; and determining the preset times based on the distribution probability function of the continuous idle times and a preset probability threshold value.
As one possible implementation manner, after controlling the IO thread to enter the sleep state, the method includes: in response to detecting that the IO thread has a service to be processed, waking up the IO thread; or in response to the sleep time of the IO thread reaching the preset sleep time, waking up the IO thread.
As one possible implementation, after waking up the IO thread, a counter for recording the number of consecutive idlings of the main processing function is cleared.
In a second aspect, a power saving device for a thread is provided, the power saving device for a thread comprising: the monitoring unit and the processing unit.
The monitoring unit is used for monitoring the continuous idle times of a main processing function operated by the IO thread in the running process of the read-write IO thread of the CPU, and the main processing function is used for processing the service to be processed of the IO thread; and the processing unit is used for controlling the IO thread to enter the dormant state in response to the monitoring unit monitoring that the continuous idling frequency of the main processing function is greater than or equal to the preset frequency.
As a possible implementation, the monitoring unit is specifically configured to: judging whether the IO thread has a service to be processed or not in the process of running the main processing function once; and under the condition that the IO thread does not have the service to be processed, determining the current running of the main processing function to be idle.
As one possible implementation, the preset number of times is determined according to the following manner: acquiring an idling record of the main processing function, wherein the idling record is used for recording the time of each idling occurrence of the main processing function in a historical time period; generating a distribution probability function of continuous idling times according to the idling record; and determining the preset times based on the distribution probability function of the continuous idle times and a preset probability threshold value.
As a possible implementation, the processing unit is further configured to: under the condition that the preset condition is met, waking up the IO thread; wherein the preset conditions include at least one of the following: detecting a service to be processed of an IO thread; or the sleep time of the IO thread is greater than or equal to the preset sleep time.
As a possible implementation, the processing unit is further configured to: after waking up the IO thread, a counter for recording the number of consecutive idleness times of the main processing function is cleared.
In a third aspect, a power saving apparatus for a thread is provided that includes a memory and a processor. The memory is used for storing computer execution instructions, and the processor is connected with the memory through a bus. When the power saving device of the thread runs, the processor executes the computer execution instruction stored in the memory, so that the power saving device of the thread executes the power saving method of the thread in the first aspect.
In a fourth aspect, there is provided a computer readable storage medium comprising computer executable instructions which, when run on a computer, cause the computer to perform the power saving method of any one of the threads provided in the first aspect.
In a fifth aspect, a computer program product is provided, directly loadable into a memory and comprising software code, the computer program product being capable of performing, when loaded and executed by a computer, the power saving method of any of the threads provided in the first aspect.
It should be noted that the above-mentioned computer instructions may be stored in whole or in part on a computer-readable storage medium. The computer readable storage medium may be packaged together with the processor of the controller or may be packaged separately from the processor of the controller, which is not limited in the present application.
The advantageous effects described in the second to fifth aspects of the present application may be referred to for the advantageous effect analysis of the first aspect, and will not be described here again.
Drawings
The accompanying drawings are included to provide a further understanding of the application and are incorporated in and constitute a part of this specification, illustrate and do not limit the application.
FIG. 1 is a schematic hardware structure of a thread power saving device according to an embodiment of the present application;
FIG. 2 is a schematic hardware structure of another power saving device for a thread according to an embodiment of the present application;
FIG. 3 is a flowchart of a method for saving power for a thread according to an embodiment of the present application;
FIG. 4 is a flowchart of a method for saving power for a thread according to an embodiment of the present application;
FIG. 5 is a flowchart of a method for saving power for a thread according to an embodiment of the present application;
FIG. 6 is a flowchart illustrating a method for saving power for a thread according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of a power saving device for a thread according to an embodiment of the present application.
Detailed Description
The technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, but not all embodiments, and all other embodiments obtained by those skilled in the art without making creative efforts based on the embodiments in the present application are included in the protection scope of the present application.
In embodiments of the application, words such as "exemplary" or "such as" are used to mean serving as an example, instance, or illustration. Any embodiment or design described herein as "exemplary" or "e.g." in an embodiment should not be taken as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete fashion.
In embodiments of the present application, "at least one" refers to one or more. "plurality" means two or more.
In the embodiment of the present application, "and/or" is merely an association relationship describing an association object, and indicates that three relationships may exist, for example, a and/or B may indicate: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship.
In the existing solution, a function waiting for awakening is added in a main processing function, and the function can forcedly enable an IO processing thread to enter a dormant state and awaken the IO thread when a service needing to be processed arrives.
As described in the background art, in the current storage framework, in order to pursue high-performance read-write efficiency, an IO processing thread is generally bound to a central processing unit CPU separately, and works in a manner of always circularly running a main processing function. Once the service to be processed is detected, the processing of the IO thread can be immediately obtained, and the working efficiency of high reading and writing and low time delay is ensured. However, this mode of operation keeps the IO processing threads running at a high level, resulting in a CPU consuming a large amount of power.
In the related solution, a sleep waiting wake-up function is added in a main processing function, and the function enables an IO thread to forcedly enter a sleep state within a preset time, and the IO thread passively stops working; when the service to be processed exists, the IO thread is forcedly awakened, and the IO thread enters a working state.
In the solution, the IO thread is forcedly controlled to enter the sleep state, so that the IO thread is passively stopped. To a certain extent, the working strength of the IO thread is indeed reduced. However, the solution causes frequent switching of the IO thread between the sleep state and the working state, which is rather more consumed for the CPU, and not only does not achieve the purpose of power saving, but also increases the energy consumption of the CPU.
Aiming at the problems of the method, the embodiment of the application provides a power saving method for threads, which detects the continuous idling times of a main processing function by detecting the main processing function, and further judges whether the IO thread is in a leisure state at the moment according to the continuous idling times of the main processing function, and further determines whether the IO thread needs to enter a dormant state. Therefore, the power saving method provided by the embodiment of the application can control the IO thread to enter the dormant state under the condition that the normal work of the IO thread is not influenced, so that the electric quantity consumed by a CPU is reduced, and the power saving effect is realized.
The power saving device of the thread can be a chip in the device or a system on a chip in the device. Alternatively, the device may be a physical machine, for example: desktop computers, also known as desktop computers or desktops (desktops), cell phones, tablet computers, notebook computers, ultra-mobile personal computer (UMPC), netbooks, personal Digital Assistants (PDAs), and other terminal devices.
For ease of understanding, the structure of the power saving device of the thread in the embodiment of the present application is described below.
Fig. 1 is a schematic diagram of a hardware structure of a power saving device for a thread according to an embodiment of the present application. As shown in fig. 1, the power saving device for the thread includes a processor 11, a memory 12, a communication interface 13, and a bus 14. The processor 11, the memory 12 and the communication interface 13 may be connected by a bus 14.
The processor 11 is a control center of a power saving device for a thread, and may be one processor or a collective name of a plurality of processing elements. For example, the processor 11 may be a general-purpose central processing unit (central processing unit, CPU), or may be another general-purpose processor. Wherein the general purpose processor may be a microprocessor or any conventional processor or the like.
As an example, processor 11 may include one or more CPUs, such as CPU 0 and CPU 1 shown in fig. 1.
Memory 12 may be, but is not limited to, read-only memory (ROM) or other type of static storage device that can store static information and instructions, random access memory (random access memory, RAM) or other type of dynamic storage device that can store information and instructions, or electrically erasable programmable read-only memory (EEPROM), magnetic disk storage or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer.
In a possible implementation, the memory 12 may exist separately from the processor 11, and the memory 12 may be connected to the processor 11 through the bus 14 for storing instructions or program code. When the processor 11 calls and executes the instructions or the program codes stored in the memory 12, the thread power saving method provided by the embodiment of the application can be realized.
In another possible implementation, the memory 12 may also be integrated with the processor 11.
A communication interface 13 for connecting with other devices via a communication network. The communication network may be an ethernet, a radio access network, a wireless local area network (wireless local area networks, WLAN), etc. The communication interface 13 may include a receiving unit for receiving data, and a transmitting unit for transmitting data.
Bus 14 may be an industry standard architecture (Industry Standard Architecture, ISA) bus, an external device interconnect (PERIPHERAL COMPONENT INTERCONNECT, PCI) bus, or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, among others. The bus may be classified as an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in fig. 1, but not only one bus or one type of bus.
It should be noted that the structure shown in fig. 1 does not constitute a limitation on the power saving device of the thread. The power saving means of the thread may comprise more or less components than shown in fig. 1, or certain components may be combined, or a different arrangement of components.
Fig. 2 shows another hardware configuration of the linear power saving device in the embodiment of the present application. As shown in fig. 2, the communication device may include a processor 21 and a communication interface 22. The processor 21 is coupled to a communication interface 22.
The function of the processor 21 may be as described above with reference to the processor 11. The processor 21 also has a memory function, and the function of the memory 12 can be referred to.
The communication interface 22 is used to provide data to the processor 21. The communication interface 22 may be an internal interface of the communication device or an external interface (corresponding to the communication interface 13) of the power saving device of the thread.
It should be noted that the structure shown in fig. 1 (or fig. 2) does not constitute a limitation of the power saving device of the thread, and the power saving device of the thread may include more or less components than those shown in fig. 1 (or fig. 2), or may combine some components, or may be arranged in different components.
The following describes a power saving method for a thread according to an embodiment of the present application in detail with reference to the accompanying drawings.
An embodiment of the present application provides a method for saving power for a thread, as shown in fig. 3, the method includes: step S301 to step 302.
S301, monitoring continuous idle times of a main processing function operated by an IO thread in the operation process of the IO thread of the CPU.
The main processing function is used for processing the service to be processed of the IO thread.
Judging whether the operation is idle according to whether the business to be processed exists in the IO thread or not in the process of operating the main processing function once; if the IO thread does not have the service to be processed, determining that the main processing function runs at this time as idling.
In some embodiments, the IO thread of the CPU operates in a manner that always loops through the main processing function. In the primary operation process of the main processing function, if the service to be processed exists, the operation is not idle; if the service to be processed is not detected in the primary operation process of the main processing function until the operation is finished, determining that the operation is idle.
As a possible implementation, the main processing function idles once, the counter responsible for recording the number of consecutive idlings of the main processing function is incremented by 1; and if the existence of the service to be processed of the IO thread is detected, resetting the counter.
For example, assuming that when the main processing function runs for the first time, the IO thread has no service to be processed, after determining that the running is idle, a counter for recording the continuous idle times of the main processing function is increased by 1, and when determining that the running is idle for the second time, the counter is increased by 1 again, and at this time, the continuous idle times of the main processing function is 2, and the like; when the main processing function runs for the thirty-th time, the counter records the continuous idling frequency of the main processing function as 29 times, and in the running process, the counter is reset and used for recording the continuous idling frequency of the main processing function after detecting that the IO thread has the service to be processed and processing in time; at this time, the continuous idling frequency of the main processing function is 0 times, when the main processing function runs thirty-first time, the IO thread does not have the service to be processed, the counter is added with 1, and at this time, the continuous idling frequency of the main processing function is 1 time.
S302, controlling the IO thread to enter a dormant state in response to the fact that the continuous idle time of the main processing function is greater than or equal to the preset time.
For example, assume that the preset number of times is 1000 times during the running of the IO thread. At this time, the counter records that the main processing function continuously idles 700 times, the continuous idling times are smaller than the preset times, the IO thread cannot be subjected to dormancy operation, and the IO thread continues to run; and if the main processing function runs continuously and idly for 1000 times, controlling the IO thread to enter a dormant state.
In some embodiments, the preset number of times may be determined by a historical idle record of the primary processing function.
In some embodiments, the preset number of times may determine the fixed value through expert experience. For example, the expert determines the optimally set fixed value by researching the preset times of the main processing functions in the plurality of IO threads, and takes the fixed value as the preset times.
In some embodiments, the preset number of times may also be set by the user.
Alternatively, the preset number of times may be periodically changed during the running of the IO thread.
In some embodiments, the preset number of times may be periodically changed during the running of the IO thread according to the historical running conditions.
For example, assume that the preset number of times is 3000 times during the running of the IO thread. As the IO thread runs for many times, the main processing detects that the business to be processed of the IO thread is increased, and the original preset times are overlarge, so that the IO thread is frequently awakened; at this time, the preset times are actively reduced to 2500 times so as to adapt to the existing working conditions.
The embodiment of the application has at least the following beneficial effects: and by detecting the continuous idling times of the main processing function, judging whether the IO thread is in a leisure state at the moment according to the continuous idling times of the main processing function, and further judging whether the IO thread needs to enter a dormant state. Therefore, the power saving method provided by the embodiment of the application can control the IO thread to enter the dormant state under the condition that the normal work of the IO thread is not influenced, so that the electric quantity consumed by a CPU is reduced, and the power saving effect is realized.
In some embodiments, the preset number of times is determined by a historical idle record of the main processing function, as shown in fig. 4, specifically by the following steps:
s401, acquiring idle running records of the main processing function.
The idle record is used for recording duration time of each idle running of the main processing function in the historical running process of the IO thread, namely, time interval between the service to be processed and the last IO thread processing service detected by the main processing function, and continuous idle running times of the main processing function in idle running time.
S402, generating a distribution probability function of continuous idling times according to the idling record.
Wherein the distribution probability function is used for counting the probability value of the continuous idle times of the main processing function.
In some embodiments, the distribution probability function of the number of continuous idleness is generated from the historical number of continuous idleness of the main processing function and the historical idle time.
S403, determining the preset times based on the distribution probability function of the continuous idle times and the preset probability threshold value.
The threshold value is a critical value, and when the preset times exceed the threshold value, the CPU power saving effect is obvious.
For example, according to the distribution probability function generated by the idle running record of the main processing function, the historical continuous idle running times of the main processing function are most widely distributed between 2000 and 4000 times, and the probability threshold value is 2500 times, so that when the preset times are 3000 times and 3500 times, the power saving effect of the CPU is obvious.
It can be seen that the preset times are determined according to the method, and the obtained preset times are more scientific and accurate by means of idle running record of the main processing function and combination of the distribution probability function, so that the electric quantity consumed by the CPU can be remarkably reduced.
In some embodiments, based on the embodiment shown in fig. 3, as shown in fig. 5, the method further comprises the following steps after performing S302:
s303, waking up the IO thread under the condition that the preset condition is met.
Wherein the preset conditions include at least one of the following: detecting a service to be processed of an IO thread; or the sleep time of the IO thread is greater than or equal to the preset sleep time.
Alternatively, the preset sleep period may be preset by the CPU vendor. Or the preset dormancy time can also be determined based on a distribution probability function generated by the main processing function at each idle time in the historical time period and a preset probability threshold value.
In some embodiments, in the sleep process, when the sleep time of the IO thread reaches a preset sleep time length, the IO thread is automatically switched from the sleep state to the working state, and no other factors are required to wake up.
For example, assuming that the IO thread is in a sleep state, the preset sleep duration is 10S. In the dormancy process, the existence of the service to be processed is not detected, and when the dormancy time of the IO thread reaches 10S, the IO thread is automatically awakened, and the IO thread is switched from the dormancy state to the working state to continue running without other factors.
As a possible implementation manner, after the IO thread enters the sleep state, detecting in real time whether the IO thread has a service to be processed, if so, waking up the IO thread, and entering into processing the service to be processed.
For example, assume that the IO thread is in a sleep state at this time, and the preset sleep duration is 10S. Under the condition that the IO thread is dormant for 5S, if the IO thread is detected to have a service to be processed, the IO thread is directly awakened to process the service, and the IO thread does not need to wait for the dormant time of the IO thread to reach the preset dormant time.
As another possible implementation manner, after the IO thread enters the sleep state, judging whether the sleep time of the IO thread is greater than or equal to the preset sleep time, and if the sleep time is greater than or equal to the preset sleep time, waking up the IO thread even if the IO thread does not have a service to be processed at the moment.
Still another example, assume that the IO thread is in a sleep state at this time, and the preset sleep duration is 10S. When the IO thread sleeps for 10 seconds, at the moment, the sleep time is equal to the preset sleep time, and the IO thread is actively awakened.
In some embodiments, after waking the IO thread, a counter for recording the number of consecutive idleness of the main processing function is cleared.
As a possible implementation manner, after the IO thread enters the sleep state, due to detecting that the IO thread has a service to be processed, after the IO thread is awakened to process the service to be processed, a counter for recording the continuous idle times of the main processing function is cleared.
For example, assume that during the running process of the IO thread, the preset number of times is 1000, and the preset sleep duration is 10S. At this time, the counter records the continuous idling frequency of the main processing function as 1000 times, which is equal to the preset frequency, controls the IO thread to enter the sleep state, wakes the IO thread to process the service to be processed when detecting that the service to be processed exists in the IO thread for the 4 th second of sleep, and clears the continuous idling frequency of the main processing function recorded by the counter, and at this time, the continuous idling frequency of the main processing function recorded by the counter is 0 times.
As another possible implementation manner, after the IO thread enters the sleep state, since the IO thread sleep time is greater than or equal to the preset sleep time, after the IO thread is awakened, the counter for recording the continuous idle number of the main processing function is cleared.
For example, assume that during the running process of the IO thread, the preset number of times is 1000, and the preset sleep duration is 10S. At this time, the counter records the continuous idling frequency of the main processing function as 1000 times, which is equal to the preset frequency, controls the IO thread to enter a sleep state, and when the IO thread sleeps for 10 seconds, the sleep time is equal to the preset sleep time, and wakes the IO thread even if the IO thread does not have the service to be processed, further, the continuous idling frequency of the main processing function recorded by the counter is cleared, and at this time, the continuous idling frequency of the main processing function recorded by the counter is 0 times.
The embodiment of the application has at least the following beneficial effects: when the IO thread enters a dormant state, whether a service to be processed exists or whether the dormant time exceeds a preset dormant time is detected, if the service to be processed exists or the dormant time exceeds the preset dormant time, the dormant IO thread is awakened, and therefore high read-write and low-delay working efficiency of the IO thread is guaranteed.
In some embodiments, as shown in fig. 6, an embodiment of the present application provides a method for saving power for a thread, the method including the steps of:
S501, IO thread operation stage.
S502, monitoring the continuous idling times of the main processing function.
S503, whether the continuous idling frequency of the main processing function is larger than or equal to the preset frequency.
If the number of consecutive idlings of the main processing function is greater than or equal to the preset number, S505 is executed.
If the number of continuous idleness times of the main processing function is smaller than the preset number, S504 is executed.
S504, the IO thread continues to run.
The IO thread continues to run and continuously monitors the continuous idle times of the main function.
S505, controlling the IO thread to enter a dormant state.
S506, in the dormancy process, whether a preset condition is met.
In the sleep process, whether the IO thread has a service to be processed or not is always detected, and the sleep time of the IO thread is monitored.
If the IO thread is detected to have the service to be processed; or, if the IO thread sleep time is greater than or equal to the preset sleep time, S508 is executed.
If both the above conditions are not satisfied, S507 is executed, and it is always detected whether the IO thread satisfies the preset condition.
S507, the IO thread continues to sleep.
S508, waking up the IO thread and continuing to run.
S509, a counter for recording the number of consecutive idleness times of the main processing function is cleared.
The foregoing description of the solution provided by the embodiments of the present application has been mainly presented in terms of a method. To achieve the above functions, it includes corresponding hardware structures and/or software modules that perform the respective functions. Those of skill in the art will readily appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The embodiment of the application can divide the functional modules of the communication device according to the method example, for example, each functional module can be divided corresponding to each function, or two or more functions can be integrated in one processing module. The integrated modules may be implemented in hardware or in software functional modules. Optionally, the division of the modules in the embodiment of the present application is schematic, which is merely a logic function division, and other division manners may be implemented in practice.
Fig. 7 is a schematic structural diagram of a power saving device for a thread according to an embodiment of the present application, and as shown in fig. 5, a power saving device 60 for a thread includes: a monitoring unit 601 and a processing unit 602.
The monitoring unit 601 is configured to monitor continuous idle times of a main processing function operated by an IO thread during operation of a read-write IO thread of a CPU, where the main processing function is used to process a service to be processed of the IO thread; the processing unit 602 is configured to control the IO thread to enter the sleep state in response to the monitoring unit monitoring that the continuous idle frequency of the main processing function is greater than or equal to the preset frequency.
As a possible implementation, the monitoring unit 601 is specifically configured to: judging whether the IO thread has a service to be processed or not in the process of running the main processing function once; and under the condition that the IO thread does not have the service to be processed, determining the current running of the main processing function to be idle.
As one possible implementation, the preset number of times is determined according to the following manner: acquiring an idling record of the main processing function, wherein the idling record is used for recording the time of each idling occurrence of the main processing function in a historical time period; generating a distribution probability function of continuous idling times according to the idling record; and determining the preset times based on the distribution probability function of the continuous idle times and a preset probability threshold value.
As a possible implementation, the processing unit 602 is further configured to: under the condition that the preset condition is met, waking up the IO thread; wherein the preset conditions include at least one of the following: detecting a service to be processed of an IO thread; or the sleep time of the IO thread is greater than or equal to the preset sleep time.
As a possible implementation, the processing unit 602 is further configured to: after waking up the IO thread, a counter for recording the number of consecutive idleness times of the main processing function is cleared.
Embodiments of the present application also provide a computer-readable storage medium including computer-executable instructions that, when executed on a computer, cause the computer to perform a method as provided in the above embodiments.
The embodiment of the present application also provides a computer program product, which can be directly loaded into a memory and contains software codes, and the computer program product can implement the method provided by the above embodiment after being loaded and executed by a computer.
Those skilled in the art will appreciate that in one or more of the examples described above, the functions described in the present application may be implemented in hardware, software, firmware, or any combination thereof. When implemented in software, these functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. A storage media may be any available media that can be accessed by a general purpose or special purpose computer.
The foregoing is merely illustrative of specific embodiments of the present application, and the scope of the present application is not limited thereto, but any changes or substitutions within the technical scope of the present application should be covered by the scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims (12)

1.A method of saving power for a thread, the method comprising:
monitoring continuous idle times of a main processing function operated by an IO thread in the operation process of the IO thread of an input/output CPU of the CPU, wherein the main processing function is used for processing a service to be processed of the IO thread;
And controlling the IO thread to enter a dormant state in response to the fact that the continuous idling frequency of the main processing function is greater than or equal to the preset frequency.
2. The method of claim 1, wherein the monitoring the number of consecutive idlings of the main processing function run by the IO thread comprises:
Judging whether the IO thread has a service to be processed or not in the process of running the main processing function once;
and adding one to the continuous idling frequency of the main processing function under the condition that the IO thread does not have the service to be processed.
3. The method according to claim 1, wherein the preset number of times is determined according to the following manner:
Acquiring an idle record of the main processing function, wherein the idle record is used for recording the time of each idle occurrence of the main processing function in a historical time period;
generating a distribution probability function of continuous idling times according to the idling record;
And determining the preset times based on the distribution probability function of the continuous idle times and a preset probability threshold value.
4. A method according to any one of claims 1 to 3, wherein after said controlling said IO thread to enter a sleep state, said method further comprises:
In response to detecting that the IO thread has a service to be processed, waking up the IO thread; or in response to the sleep time of the IO thread reaching a preset sleep time, waking up the IO thread.
5. The method according to claim 4, wherein the method further comprises:
after waking up the IO thread, a counter for recording the continuous idle times of the main processing function is cleared.
6. A power saving device for a thread, comprising:
the monitoring unit is used for monitoring the continuous idle times of a main processing function operated by the IO thread in the operation process of the input/output IO thread of the CPU, wherein the main processing function is used for processing the service to be processed of the IO thread;
And the processing unit is used for controlling the IO thread to enter a dormant state in response to the monitoring unit monitoring that the continuous idling frequency of the main processing function is greater than or equal to the preset frequency.
7. The power saving device of a thread according to claim 6, wherein the monitoring unit is specifically configured to:
Judging whether the IO thread has a service to be processed or not in the process of running the main processing function once;
and under the condition that the IO thread does not have the service to be processed, determining that the current operation of the main processing function is idle.
8. The power saving device of claim 6, wherein the preset number of times is determined according to the following manner:
Acquiring an idle record of the main processing function, wherein the idle record is used for recording the time of each idle occurrence of the main processing function in a historical time period;
generating a distribution probability function of continuous idling times according to the idling record;
And determining the preset times based on the distribution probability function of the continuous idle times and a preset probability threshold value.
9. The apparatus according to any one of claims 6 to 8, wherein the processing unit is further configured to:
in response to detecting that the IO thread has a service to be processed, waking up the IO thread; or alternatively
And waking up the IO thread in response to the sleep time of the IO thread reaching a preset sleep time.
10. The apparatus of claim 9, wherein the processing unit is further configured to:
after waking up the IO thread, a counter for recording the continuous idle times of the main processing function is cleared.
11. A power saving device for a thread, comprising a memory and a processor; the memory is used for storing computer execution instructions, and the processor is connected with the memory through a bus;
When the power saving device of the thread runs, the processor executes the computer execution instructions stored in the memory, so that the power saving device of the thread executes the power saving method of the thread according to any one of claims 1 to 5.
12. A computer readable storage medium comprising computer executable instructions which, when run on a computer, cause the computer to perform the power saving method of the thread of any of claims 1-5.
CN202211428956.2A 2022-11-15 2022-11-15 Power saving method and device for threads and storage medium Pending CN118051113A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211428956.2A CN118051113A (en) 2022-11-15 2022-11-15 Power saving method and device for threads and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211428956.2A CN118051113A (en) 2022-11-15 2022-11-15 Power saving method and device for threads and storage medium

Publications (1)

Publication Number Publication Date
CN118051113A true CN118051113A (en) 2024-05-17

Family

ID=91045428

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211428956.2A Pending CN118051113A (en) 2022-11-15 2022-11-15 Power saving method and device for threads and storage medium

Country Status (1)

Country Link
CN (1) CN118051113A (en)

Similar Documents

Publication Publication Date Title
US8996895B2 (en) Method, apparatus, and system for energy efficiency and energy conservation including optimizing C-state selection under variable wakeup rates
KR101029414B1 (en) Method and apparatus for providing for detecting processor state transitions
US9618997B2 (en) Controlling a turbo mode frequency of a processor
US8082459B2 (en) Power management based on policy
US6298448B1 (en) Apparatus and method for automatic CPU speed control based on application-specific criteria
US8560749B2 (en) Techniques for managing power consumption state of a processor involving use of latency tolerance report value
US9329671B2 (en) Power-efficient inter processor communication scheduling
EP2073097B1 (en) Transitioning a processor package to a low power state
US7966506B2 (en) Saving power in a computer system
US8775838B2 (en) Limiting the number of unexpected wakeups in a computer system implementing a power-saving preemptive wakeup method from historical data
US20150227476A1 (en) Reducing latency in a peripheral component interconnect express link
EP3268842B1 (en) Methods and systems for coordination of operating states amongst multiple socs within a computing device
US6898718B2 (en) Method and apparatus to monitor performance of a process
EP3717987B1 (en) Dynamic interrupt rate control in computing systems
US9116699B2 (en) Memory refresh rate throttling for saving idle power
CN118051113A (en) Power saving method and device for threads and storage medium
CN112114651B (en) Power saving method and device for processor cluster, chip, equipment and storage medium
CN114610578A (en) Resource state management method and device, electronic equipment and storage medium
WO2016058149A1 (en) Method for predicting utilization rate of processor, processing apparatus and terminal device
CN116610204B (en) Power management method, system, electronic equipment and medium for electric equipment
US7822999B2 (en) Computer system and method for controlling a processor thereof
EP4336703A1 (en) Electronic device
CN115964090A (en) Chip-based dormancy and awakening method and device
CN117492848A (en) Method, device, equipment and medium for switching processor states
CN116225672A (en) Task processing method and device based on many-core chip, processing core and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination