Electronic device and its power consumption control method
By receiving busy waiting instructions in the processor's operating system and generating wait-enabled instructions, the control device causes the processor to enter an idle state, solving the problem of high power consumption of the processor in the busy waiting state, and achieving effective optimization of power consumption.
Patent Information
- Application Number
- CN202111231354.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-22
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2041-10-22
AI Technical Summary
During the kernel code processing of the processor's operating system, the processor's power consumption is high in the busy waiting state, and the existing technology is difficult to effectively optimize.
By receiving the busy waiting command, a wait-to-enabled command is generated and a count value is obtained. The control device stops sending the command to the processing device, makes it enter an idle state, and starts the counter for counting.
It effectively reduces the power consumption of the processor in a busy and wait state and increases the convenience of use.
Smart Images

Figure CN113986663B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to an electronic device, and more particularly to an electronic device and a power consumption control method thereof. Background Art
[0002] Generally speaking, in the processing of the kernel code of the operating system of a processor, a situation of busy waiting often occurs, and the time of busy waiting is counted by a time stamp counter (TSC) inside the processor. However, during the busy waiting process of the operating system, the core of the processor is still working continuously, so the power consumption of the processor remains relatively high during the time of the busy waiting process. Therefore, how to effectively optimize the power consumption of the processor in the busy waiting state will become a topic that various manufacturers are eager to study. Summary of the Invention
[0003] The present invention provides an electronic device and a power consumption control method thereof, so as to effectively optimize the power consumption of the electronic device in the busy waiting state.
[0004] The present invention provides a power consumption control method for an electronic device, including the following steps. Receive a busy waiting instruction, where the busy waiting instruction indicates that the operating system of the processing device is in a busy waiting state. According to the busy waiting instruction, obtain the micro-instruction of the busy waiting instruction. According to the micro-instruction, generate a waiting enable instruction, and obtain the count value corresponding to the waiting enable instruction. According to the waiting enable instruction, stop sending instructions to the processing device, so that the processing device enters an idle state, and start a counter, so that the counter starts counting according to the count value.
[0005] The present invention further provides an electronic device, including a processing device and a control device. The processing device receives a busy waiting instruction, where the busy waiting instruction indicates that the operating system of the processing device is in a busy waiting state. According to the busy waiting instruction, obtain the micro-instruction of the busy waiting instruction. According to the micro-instruction, generate a waiting enable instruction, and obtain the count value corresponding to the waiting enable instruction. The control device is coupled to the processing device and includes a counter. The control device receives the waiting enable instruction, and according to the waiting enable instruction, stops sending instructions to the processing device, so that the processing device enters an idle state, and starts the counter, so that the counter starts counting according to the count value.
[0006] The electronic device and its power consumption control method disclosed in the present invention receive a busy waiting instruction by a processing device, where the busy waiting instruction indicates that the operating system of the processing device is in a busy waiting state. According to the busy waiting instruction, a micro-instruction of the busy waiting instruction is obtained, and then according to the micro-instruction, a waiting enable instruction is generated, and a count value corresponding to the waiting enable instruction is obtained. And the control device stops sending instructions to the processing device according to the waiting enable instruction, so that the processing device enters an idle state, and a counter is started, so that the counter starts counting according to the count value. In this way, the power consumption of the electronic device in the busy waiting state can be effectively optimized to increase the convenience in use. BRIEF DESCRIPTION OF THE DRAWINGS
[0007] Figure 1 FIG. is a schematic diagram of an electronic device according to an embodiment of the present invention.
[0008] Figure 2 FIG. is a flowchart of a power consumption control method of an electronic device according to an embodiment of the present invention.
[0009] Figure 3 is Figure 2 a detailed flowchart of step S206 of
[0010] Figure 4 is Figure 3 a detailed flowchart of step S306 of
[0011] Figure 5 is a flowchart of step S208 following Figure 2 in
[0012] Figure 6 is a flowchart of another step S208 following Figure 2 in DETAILED DESCRIPTION OF THE EMBODIMENTS
[0013] In the following listed embodiments, the same reference numerals will represent the same or similar elements or components.
[0014] Figure 1 FIG. is a schematic diagram of an electronic device according to an embodiment of the present invention. Please refer to Figure 1 , the electronic device 100 includes a processing device 110 and a control device 150.
[0015] In this embodiment, the processing device 110 may be a central processing unit (CPU) and includes at least one core. The processing device 110 may receive a busy-waiting instruction (such as ZXPAUSE), where the busy-waiting instruction indicates that the operating system (OS) of the processing device 110 is in a busy-waiting state. For example, when the kernel code of the operating system of the processing device 110 encounters a busy-waiting situation, the operating system will generate a busy-waiting instruction for the processing device 110 to indicate that the operating system is in a busy-waiting state.
[0016] Next, the processing device 110 may obtain the micro-instruction of the busy-waiting instruction according to the busy-waiting instruction. In this embodiment, when the processing device 110 receives the busy-waiting instruction, the processing device 110 may, for example, perform a decoding process on the busy-waiting instruction to obtain the micro-instruction in the busy-waiting instruction.
[0017] After that, the processing device 110 may generate a wait enable instruction (such as wait_nclk_u) according to the micro-instruction and obtain the count value corresponding to the wait enable instruction. In this embodiment, the above count value is used to indicate the waiting time required by the processing device 110 when the operating system is in a busy-waiting state.
[0018] Furthermore, the processing device 110 may further include a first register 120, a second register 130, and a third register 140. In this embodiment, the first register 120 is, for example, an EDX data register, the second register 130 is, for example, an EAX accumulator register, and the third register 140 is, for example, a model specific register (MSR), but the embodiments of the present invention are not limited thereto.
[0019] When the processing device 110 generates a wait enable instruction according to the micro-instruction, the processing device 110 may read the first register 120 and the second register 130 of the processing device 110 to obtain the first bit number of the first register 120 and the second bit number of the second register 130, and generate a first value according to the first bit number and the second bit number. In this embodiment, the first bit number is, for example, the lower 32 bits, the second bit number is, for example, the upper 32 bits, and the first value (such as (EDX:EAX)) is, for example, 64, but the embodiments of the present invention are not limited thereto.
[0020] That is to say, after the processing device 110 reads the first register 120 and the second register 130, the processing device 100 can combine the first digit of the first register 120 and the second digit of the second register 130 to form a first value, so that the first value can be used as the waiting time required by the processing device 110 when the operating system is in the busy waiting state. Additionally, the above first value can be configured, for example, by the processing device 110 executing a software.
[0021] Next, the processing device 110 can read the third register 140 of the processing device 110 to obtain a second value. In this embodiment, the above second value can be used as the waiting time required by the processing device 110 when the operating system is in the busy waiting state. Additionally, the above second value can also be configured, for example, by the processing device 110 executing a software and through the third register 140.
[0022] After that, when the processing device 110 obtains the first value and the second value, the processing device 110 can select the first value or the second value as the count value corresponding to the wait enable instruction. For example, the processing device 110 can select the first value or the second value as the count value corresponding to the wait enable instruction according to the magnitudes of the first value and the second value. That is to say, when the processing device 110 obtains the first value and the second value, the processing device 110 can determine whether the first value is greater than the second value. When it is determined that the first value is greater than the second value, the processing device 110 can select the second value as the count value corresponding to the wait enable instruction. When it is determined that the first value is not greater than the second value, the processing device 110 can select the first value as the count value corresponding to the wait enable instruction.
[0023] In this embodiment, the control device 150 can be a component on the pipeline of the processor, such as a microcode controller. The control device 150 is coupled to the processing device 110 and includes a counter 151. The control device 150 can receive the wait enable instruction generated by the processing device 110, and according to the wait enable instruction, stop sending the subsequent micro-instruction to the processing device 110, that is, stop sending the micro-instructions in the micro-instruction sequence that the processing device needs to process and are arranged after receiving the wait enable instruction, that is, the subsequent micro-instructions. After that, the processing device 110 enters the idle state and starts the counter 151, so that the counter 151 starts counting according to the count value. That is to say, during the period when the counter 151 starts counting and the control device 150 stops sending instructions to the processing device 110, the processing device 110 (such as the core of the processor) can be in the idle state (that is, the pipeline of the processor can be in the idle state) to reduce the power consumption of the processing device 110. In this way, the power consumption of the processing device 110 in the busy waiting state can be effectively optimized to increase the convenience of use.
[0024] For example, in this embodiment, when the counter 151 starts counting according to the count value (such as the first value or the second value), the counter 151, for example, subtracts 1 from the count value every period. Then, the control device 150 can confirm whether the count value reaches a preset value. In this embodiment, the above preset value is, for example, 0, but the embodiments of the present invention are not limited thereto.
[0025] When the control device 150 confirms that the count value does not reach the preset value (such as 0), the counter 151 continues to count (for example, continues to subtract 1 from the count value every period), and the control device 150 continues to stop sending instructions to the processing device 110, so that the processing device 110 remains in an idle state to reduce the power consumption of the processing device 110.
[0026] In addition, when it is confirmed that the count value reaches the preset value (such as 0), the counter 151 stops counting, and the control device 150 resumes sending instructions to the processing device 110, so that the processing device 110 resumes to the normal operation mode. That is to say, the control device 150 can obtain instructions from a memory 152 (such as a microcode read only memory (ucodeROM)) and send them to the processing device 110, and then the processing device 110 will operate normally to process the instructions sent by the control device 150. It can be seen that during the period when the counter 151 starts counting and the control device 150 stops sending instructions to the processing device 110 (that is, the waiting time required by the processing device 110 when the operating system is in a busy waiting state), if the count value of the counter 151 reaches the preset value, the processing device 110 can exit the idle mode and resume the normal mode to process the instructions sent by the control device 150.
[0027] In addition, after the counter 151 starts counting and the control device 150 stops sending instructions to the processing device 110, the operating system of the processing device 110, for example, generates an interrupt instruction. In this embodiment, the interrupt instruction is, for example, a system management interrupt. Then, the processing device 150 can save the current operating state of the processing device 110 according to the interrupt instruction (that is, record and save the operating state of the processing device 110 before the interrupt instruction), and execute an interrupt handling program (handle). In this embodiment, the interrupt management program is, for example, a system management interrupt handling program.
[0028] After that, the control device 150 can, according to the interrupt instruction, resume sending instructions to the processing device 110, causing the processing device 110 to resume the normal operation mode. That is to say, after continuing with the current operating state of the processing device 110, the control device 150 can fetch instructions from a memory (such as a microcode read-only memory) and send them to the processing device 110, and the processing device 110 will operate normally to process the instructions sent by the control device 150. It can be seen that during the period when the counter 151 starts counting and the control device 150 stops sending instructions to the processing device 110 (i.e., the waiting time required for the processing device 110 when the operating system is in the busy waiting state), if an interrupt instruction is generated by the operating system of the processing device 110, the processing device 110 can exit the idle mode and resume the normal mode to process the instructions sent by the control device 150.
[0029] Figure 2 FIG. 4 is a flowchart of a power consumption control method for an electronic device according to an embodiment of the present invention. In step S202, a busy waiting instruction is received, where the busy waiting instruction indicates that the operating system of the processing device is in the busy waiting state. In step S204, according to the busy waiting instruction, the micro-instruction of the busy waiting instruction is obtained.
[0030] In step S206, according to the micro-instruction, a wait enable instruction is generated, and the count value corresponding to the wait enable instruction is obtained. In step S208, according to the wait enable instruction, sending instructions to the processing device is stopped, causing the processing device to enter the idle state, and a counter is started, causing the counter to start counting according to the count value.
[0031] Figure 3 is Figure 2 a detailed flowchart of step S206 of FIG. 4. In step S302, the first register and the second register of the processing device are read, the first digit and the second digit are obtained, and according to the first digit and the second digit, a first value is generated. In step S304, the third register of the processing device is read, and a second value is obtained. In step S306, either the first value or the second value is selected as the count value corresponding to the wait enable instruction. In this embodiment, the first register is, for example, the EDX register, the second register is, for example, the EAX register, and the third register is, for example, a special module register.
[0032] Figure 4 is Figure 3 a detailed flowchart of step S306 of FIG. 5. In step S402, it is judged whether the first value is greater than the second value. When it is judged that the first value is greater than the second value, step S404 is entered, and the second value is selected as the count value corresponding to the wait enable instruction. When it is judged that the first value is not greater than the second value, step S406 is entered, and the first value is selected as the count value corresponding to the wait enable instruction.
[0033] Figure 5 is a flowchart for continuing step S208 in Figure 2 . In step S502, it is confirmed whether the count value reaches a preset value. When it is confirmed that the count value does not reach the preset value, step S504 is entered, the counter continues to count, and the instruction sending to the processing device is continuously stopped. When it is confirmed that the count value reaches the preset value, step S506 is entered, the counter stops counting, and the instruction sending to the processing device is resumed, so that the processing device resumes to the normal operation mode.
[0034] Figure 6 is another flowchart for continuing step S208 in Figure 2 . In step S602, an interrupt instruction is generated. In step S604, according to the interrupt instruction, the current operation state of the processing device is saved, and the interrupt handling program is executed. In step S606, according to the interrupt instruction, the instruction sending to the processing device is resumed, so that the processing device resumes to the normal operation mode.
[0035] It should be noted that Figure 2 , Figure 3 , Figure 4 , Figure 5 and Figure 6 The order of the steps is only for illustrative purposes and is not used to limit the order of the steps of the embodiments of the present invention, and the order of the above steps can be changed by the user according to their needs. Also, without departing from the spirit and scope of the present invention, additional steps can be added or fewer steps can be used.
[0036] In summary, for the electronic device and its power consumption control method disclosed in the present invention, by receiving a busy waiting instruction by the processing device, where the busy waiting instruction instructs the operating system of the processing device to be in a busy waiting state, and according to the busy waiting instruction, the micro-instruction of the busy waiting instruction is obtained, and then according to the micro-instruction, a waiting enable instruction is generated, and the count value corresponding to the waiting enable instruction is obtained, and by the control device according to the waiting enable instruction, the instruction sending to the processing device is stopped, so that the processing device enters an idle state, and the counter is started, so that the counter starts counting according to the count value. In this way, the power consumption of the electronic device in the busy waiting state can be effectively optimized to increase the convenience in use.
[0037] Although the present invention is disclosed as above with embodiments, it is not intended to limit the scope of the present invention. Those skilled in the art can make some changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the scope defined by the appended claims.
Claims
1. A power consumption control method for an electronic device, the electronic device including a processing device and a control device, the power consumption control method comprises: The processing device receives a busy wait instruction, where the busy wait instruction indicates that the operating system of the processing device is in a busy wait state; The processing device obtains the micro-instruction of the busy wait instruction according to the busy wait instruction; The processing device generates a wait enable instruction according to the micro-instruction, and obtains the count value corresponding to the wait enable instruction; and The control device stops sending subsequent micro-instructions to the processing device according to the wait enable instruction, so that the processing device enters an idle state, starts the counter of the control device, and the counter starts counting according to the count value.
2. The power consumption control method for an electronic device according to claim 1, further comprises: The control device confirms whether the count value reaches a preset value; When it is confirmed that the count value does not reach the preset value, the counter continues to count and continues to stop sending the subsequent micro-instructions to the processing device; and When it is confirmed that the count value reaches the preset value, the counter stops counting, and resumes sending the subsequent micro-instructions to the processing device, so that the processing device resumes to the normal operation mode.
3. The power consumption control method for an electronic device according to claim 1, wherein the step of obtaining the count value corresponding to the wait enable instruction comprises: Reading a first register and a second register of the processing device, obtaining a first digit and a second digit, and generating a first value according to the first digit and the second digit; Reading a third register of the processing device to obtain a second value; and Selecting the first value or the second value as the count value corresponding to the wait enable instruction.
4. The power consumption control method for an electronic device according to claim 3, wherein the step of selecting the first value or the second value as the count value corresponding to the wait enable instruction comprises: Judging whether the first value is greater than the second value; When it is judged that the first value is greater than the second value, selecting the second value as the count value corresponding to the wait enable instruction; and When it is judged that the first value is not greater than the second value, selecting the first value as the count value corresponding to the wait enable instruction.
5. The power consumption control method for an electronic device according to claim 3, wherein the first register is a data register, the second register is an accumulator register, and the third register is a special module register.
6. The power consumption control method for an electronic device according to claim 1, further comprises: The processing device generates an interrupt instruction; The processing device saves the current operation state of the processing device according to the interrupt instruction and executes an interrupt handling program; and The control device resumes sending the subsequent micro-instructions to the processing device according to the interrupt instruction, so that the processing device resumes to the normal operation mode.
7. An electronic device, comprises: A processing device, which receives a busy wait instruction, where the busy wait instruction indicates that the operating system of the processing device is in a busy wait state, obtains the micro-instruction of the busy wait instruction according to the busy wait instruction, generates a wait enable instruction according to the micro-instruction, and obtains the count value corresponding to the wait enable instruction; and A control device, coupled to the processing device, and includes a counter. The control device receives the waiting enable instruction, and according to the waiting enable instruction, stops sending subsequent microinstructions to the processing device, causes the processing device to enter an idle state, and starts the counter, so that the counter starts counting according to the count value.
8. The electronic device according to claim 7, wherein the control device confirms whether the count value reaches a preset value. When it is confirmed that the count value does not reach the preset value, the counter continues to count, and the control device continues to stop sending the subsequent microinstructions to the processing device. When it is confirmed that the count value reaches the preset value, the counter stops counting, and the control device resumes sending the subsequent microinstructions to the processing device, so that the processing device resumes to the normal operation mode.
9. The electronic device according to claim 7, wherein the processing device reads the first register and the second register of the processing device, obtains a first digit and a second digit, and generates a first value according to the first digit and the second digit. The processing device reads the third register of the processing device to obtain a second value, and the processing device selects the first value or the second value as the count value corresponding to the waiting enable instruction.
10. The electronic device according to claim 9, wherein the processing device determines whether the first value is greater than the second value. When it is determined that the first value is greater than the second value, the processing device selects the second value as the count value corresponding to the waiting enable instruction. When it is determined that the first value is not greater than the second value, the processing device selects the first value as the count value corresponding to the waiting enable instruction.
11. The electronic device according to claim 9, wherein the first register is a data register, the second register is an accumulator register, and the third register is a special module register.
12. The electronic device according to claim 7, wherein the operating system of the processing device generates an interrupt instruction. The processing device, according to the interrupt instruction, saves the current operating state of the processing device and executes an interrupt handling program. The control device resumes sending the subsequent microinstructions to the processing device according to the interrupt instruction, so that the processing device resumes to the normal operation mode.
Citation Information
Patent Citations
Instruction for enabling a procesor wait state
CN102103484A