Dormancy mode selection method and apparatus, electronic device, and computer readable medium
By identifying the target thread and its operating parameters related to user interaction in electronic devices and selecting an appropriate sleep mode, the problem of unreasonable power consumption in existing technologies is solved, thereby improving user experience and energy efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-25
- Publication Date
- 2026-03-17
AI Technical Summary
Existing technologies fail to effectively consider user interaction needs when selecting sleep modes for electronic devices, resulting in unreasonable power consumption and affecting user experience.
By identifying the target thread currently running on the electronic device that is related to user interaction, its running parameters are obtained. Based on these parameters, a specified sleep mode that meets the requirements of the target thread is selected from multiple sleep modes, ensuring that the device enters the sleep mode when the sleep conditions are met.
It improves the rationality of sleep mode selection, reduces the processor wake-up time, improves user experience, and reduces power consumption.
Smart Images

Figure CN115509738B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a method, apparatus, electronic device, and computer-readable medium for selecting a sleep mode. Background Technology
[0002] When an electronic device's processor has no tasks to execute, it enters a sleep mode, or idle state. Furthermore, electronic devices have multiple sleep modes, each with different power consumption and disabled hardware units. Therefore, a solution is urgently needed to rationally determine the appropriate sleep mode for an electronic device. Summary of the Invention
[0003] This application proposes a method, apparatus, electronic device, and computer-readable medium for selecting a sleep mode to improve the above-mentioned deficiencies.
[0004] In a first aspect, embodiments of this application provide a sleep mode selection method applied to an electronic device, wherein the processor of the electronic device corresponds to multiple sleep modes, and the method includes: determining a target thread related to user interaction corresponding to the current running scenario of the electronic device; obtaining running parameters corresponding to the target thread; determining a specified sleep mode that meets the usage requirements of the target thread from the multiple sleep modes based on the running parameters; and controlling the electronic device to enter the specified sleep mode when sleep conditions are met.
[0005] Secondly, this application also provides a sleep mode selection device applied to an electronic device. The processor of the electronic device corresponds to multiple sleep modes. The device includes: a determining unit, an acquiring unit, a setting unit, and a controlling unit. The determining unit is used to determine the target thread related to user interaction corresponding to the current running scenario of the electronic device. The acquiring unit is used to acquire the running parameters corresponding to the target thread. The setting unit is used to determine a specified sleep mode that meets the usage requirements of the target thread from the multiple sleep modes based on the running parameters. The controlling unit is used to control the electronic device to enter the specified sleep mode when sleep conditions are met.
[0006] Thirdly, embodiments of this application also provide an electronic device, including: one or more processors; a memory; one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, and the one or more application programs are configured to perform the methods described above.
[0007] Fourthly, embodiments of this application also provide a computer-readable medium storing processor-executable program code, which, when executed by the processor, causes the processor to perform the above-described method.
[0008] Fifthly, embodiments of this application also provide a computer program product, including a computer program / instructions that, when executed by a processor, implement the above-described method.
[0009] The sleep mode selection method, apparatus, electronic device, and computer-readable medium provided in this application determine the target thread related to user interaction corresponding to the current operating scenario of the electronic device, obtain the operating parameters corresponding to the target thread, and, based on the operating parameters, determine a specified sleep mode from a plurality of sleep modes that meets the usage requirements of the target thread. When sleep conditions are met, the electronic device is controlled to enter the specified sleep mode. Therefore, the specified sleep mode entered by the electronic device determined in this application is set based on the current target thread related to user interaction, so that the determination of the sleep mode can take into account the user interaction requirements, and thus the selection of the sleep mode is more reasonable.
[0010] Other features and advantages of the embodiments of this application will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the embodiments of this application. The objects and other advantages of the embodiments of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 A flowchart of a sleep mode selection method according to an embodiment of this application is shown;
[0013] Figure 2 A flowchart of a sleep mode selection method according to another embodiment of this application is shown;
[0014] Figure 3 A schematic diagram of a display interface provided in an embodiment of this application is shown;
[0015] Figure 4 A schematic diagram of a display interface provided in another embodiment of this application is shown;
[0016] Figure 5 A flowchart of a sleep mode selection method according to another embodiment of this application is shown;
[0017] Figure 6 This paper shows a block diagram of a sleep mode selection device according to an embodiment of the present application;
[0018] Figure 7 A structural block diagram of an electronic device provided in an embodiment of this application is shown;
[0019] Figure 8 A structural block diagram of a computer-readable medium provided in an embodiment of this application is shown;
[0020] Figure 9 A structural block diagram of a computer program product provided in an embodiment of this application is shown. Detailed Implementation
[0021] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, and not all of them. The components of the embodiments of the present application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of the present application. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without inventive effort are within the scope of protection of the present application.
[0022] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0023] Mobile computing technology is advancing rapidly, and handheld terminals, represented by smartphones and tablets, have become widely popular and applied. With the development of mobile computing technology, especially the tremendous progress in mobile processor technology, the application scope of these handheld terminals has expanded from traditional communication and photography functions to the high-speed Internet access, 3D games, and high-definition video functions commonly found in today's smartphones and tablets.
[0024] Mobile processors in handheld smart devices typically consist of two parts: a central processing unit (CPU) and a graphics processing unit (GPU). The CPU handles general computing functions, while the GPU handles 2D and 3D graphics rendering, computation, and display. Currently, applications, games, and high-definition video playback on smartphones, tablets, and other mobile devices place increasingly higher demands on the performance of mobile processors, resulting in greater power consumption.
[0025] To reduce the power consumption of electronic devices, when there are no tasks to execute, the processor enters a sleep mode, or idle state. When the processor is in sleep mode, at least part of the processor's clock and / or power is turned off. When it is woken up, that is, when it exits sleep mode, the processor is woken up, that is, the clock and / or power that were turned off are turned on again.
[0026] Typically, electronic devices have multiple low-power modes, collectively referred to as C-states. When a processor enters sleep mode, it shuts down at least a portion of the clock and / or power through its internal idle unit. Specifically, C-states can be divided into multiple idle states, with C0 being the normal operating mode and the others "C1 to Cn" being sleep modes. Thus, when a processor enters sleep mode, it can directly enter sleep mode (CPuidle). The number of clock and / or power interrupted differs between the different idle states "C1 to Cn," meaning the number of clock and / or power interrupted may vary. However, entering and exiting sleep mode takes time; the switching on and off of clock and / or power consumes time and power, which is the cost of entering sleep mode. In addition, some sleep modes only turn off some clocks and / or power, while others turn off all clocks and / or power. The larger n is, the more clocks and / or power are turned off, resulting in lower power consumption and greater energy saving for the electronic device. However, the time required to wake up (i.e., the time required to exit sleep mode) is also longer.
[0027] Therefore, selecting the appropriate sleep mode from multiple sleep modes to save power is essential. The inventors discovered in their research that the commonly used ladder and menu algorithms have some shortcomings. Specifically, current idle strategy algorithms, such as the menu algorithm, select sleep modes based on information such as the overall system load and I / O operations, without distinguishing between different scenarios and applications. For example, in a scrolling application scenario, only one foreground application might be running with a low CPU load. However, if a deep idle state (i.e., a sleep mode with excessive wake-up time) is incorrectly selected, it will affect the refresh of the foreground application, causing lag and thus impacting the user experience.
[0028] Therefore, in order to overcome the above-mentioned defects, embodiments of this application provide a sleep mode selection method, apparatus, electronic device and computer-readable medium, such that the specified sleep mode entered by the determined electronic device is set based on the current target thread related to user interaction, so that the determination of the sleep mode can take into account the user interaction needs, and thus the selection of the sleep mode is more reasonable.
[0029] Please see Figure 1 , Figure 1 An embodiment of this application illustrates a sleep mode selection method. This method is applied to an electronic device that has multiple sleep modes. That is, the processor of the electronic device can use the multiple sleep modes. Specifically, the method includes: S101 to S104.
[0030] S101: Determine the target thread related to user interaction corresponding to the scenario currently running on the electronic device.
[0031] An application (APP) is typically a collection of multiple programs, each program corresponding to a process, and each process corresponding to at least one thread. That is, a process can be single-threaded or multi-threaded. In essence, a process is an instance; that is, a process can correspond to a function of an application. For example, the video playback function of an application can be a process of that application. Typically, the running process of an application is the main process, and the various functions within the application can be child processes of that main process.
[0032] It's important to note that threads related to user interaction can refer to threads that acquire operational data generated when the user interacts with the application, or threads that output data related to user perception. For the former, user actions can be swiping, clicking, or other actions on a specific screen within the application. In this case, if the application includes threads capable of detecting swipes and clicks, then these threads are considered user-interaction related threads. For the latter, outputting user-perceived data can be data that can be perceived by the user's hearing or vision, such as audio or video data.
[0033] In addition, the thread related to user interaction can also be a thread related to the various display interfaces of the application, that is, a thread that serves the display interface. For example, taking a video playback interface of the application as an example, if the video playback interface has a video playback control, then the thread that serves the video playback control to enable the video playback control to play the video belongs to the target thread related to user interaction.
[0034] The aforementioned user operation-related data, user-perceptible data, or application interface all fall under the category of user interaction-related data. Threads that generate or acquire this data are more likely to cause lag compared to background threads that do not interact with the user. Therefore, this application embodiment searches for target threads related to user interaction from all candidate threads of the application and sets a sleep mode that meets the usage requirements of the target thread to ensure that the operation of functional modules in the application that are clearly perceptible to the user does not lag.
[0035] As one implementation, the currently running scenario can be a currently running application, and the application belongs to a specified type of application. The currently running application can be an application running in the foreground or an application running in the background. For example, for an application running in the foreground, the specified type can be an application that performs interface drawing operations, such as a browser, video playback software, social software, etc. For an application running in the background, the specified type can be an audio playback program.
[0036] Therefore, the electronic device detects whether the currently running scene is a specified scene, i.e., whether it is a foreground interface rendering and / or audio playback scene. If so, it determines the target thread corresponding to that scene. For example, if the current scene is a foreground application's interface rendering scene, the target thread is the thread related to the application's interface rendering, such as the application's main thread. If the current scene is an audio playback scene, the target thread is the audio playback thread. In other words, the current scene is one where changes can be perceived visually and aurally, and the target thread of that scene is the core thread that implements the functionality of that scene, also known as the critical thread.
[0037] S102: Obtain the running parameters corresponding to the target thread.
[0038] As one implementation method, the running parameters may include the execution interval of the target thread, i.e. the cycle between two consecutive executions, and may also include the load corresponding to the target thread. The load may be the size of the data to be processed by the target thread or the resources occupied by the target thread. Specifically, these will be described in subsequent embodiments.
[0039] It should be noted that the electronic device may have multiple processors. For example, the processor of this electronic device may be an 8-core processor, meaning it has 8 CPUs. Additionally, the processor may include a graphics processing unit (GPU). Therefore, the processor in this method embodiment can be referred to as the target processor, which is one of the multiple CPUs or GPUs. Thus, after obtaining the running parameters corresponding to the target thread, it is first determined whether the target thread is running on the processor. Specifically, each CPU has a task queue, and the identifier of a thread running on that CPU is in that CPU's task queue. Therefore, by checking the task queue of the target processor, it can be determined whether the target thread is running on that target processor. If the target thread is running on the processor, it can wake up the processor. Therefore, it is necessary to obtain the running parameters corresponding to the target thread and determine the processor's sleep mode based on these parameters. If the target thread is not running on the processor, a preset sleep mode is configured for the processor based on a preset strategy algorithm, and when the sleep conditions are met, the electronic device is controlled to enter the preset sleep mode. The preset strategy algorithm can be a ladder algorithm or a menu algorithm, etc. That is, "based on the preset strategy algorithm, configure a preset sleep mode for the processor, and when the sleep conditions are met, control the electronic device to enter the preset sleep mode" is the native sleep process of the electronic device.
[0040] S103: Based on the operating parameters, determine the specified sleep mode that meets the usage requirements of the target thread from the plurality of sleep modes.
[0041] These operating parameters can characterize the usage requirements of the target thread, that is, they can characterize the system resources required and the processor usage requirements. Based on the foregoing description, the wake-up time of the processor varies in different sleep modes, and the hardware (e.g., clock and / or power supply) that the processor is shut down varies in different modes. Therefore, considering the timeliness of waking up the processor when the target thread is executed, and whether the sleep mode selected by the processor when the target thread wakes up the processor can really reduce power consumption or increase power consumption, a specific sleep mode that meets the usage requirements of the target thread can be determined from multiple sleep modes. This specific sleep mode can not only meet the target thread's requirement for timely processor wake-up, but also play the power reduction function corresponding to the specific sleep mode.
[0042] S104: When the sleep conditions are met, control the electronic device to enter the specified hibernation mode.
[0043] As one implementation method, meeting the sleep condition means that the processor has entered an idle state, that is, the processor has no task to execute. Then, the electronic device enters the specified sleep mode, so that when the target thread wakes up the processor, the wake-up time corresponding to the specified sleep mode can meet the usage requirements of the target thread.
[0044] Therefore, the specified sleep mode that the electronic device enters as determined in this application is set based on the current target thread related to user interaction, so that the determination of the sleep mode can take into account the user interaction needs, and thus the selection of the sleep mode is more reasonable.
[0045] Please see Figure 2 , Figure 2 An embodiment of this application illustrates a sleep mode selection method. This method is applied to an electronic device that has multiple sleep modes. That is, the processor of the electronic device can use the multiple sleep modes. Specifically, the method includes: S201 to S206.
[0046] S201: Determine the target thread related to user interaction corresponding to the scenario currently running on the electronic device.
[0047] S202: Obtain the load data corresponding to the target thread.
[0048] In this embodiment, the running parameter corresponding to the target thread is load data. This load data can be the data processing volume of the target thread, specifically the amount of data processed by the target thread per unit time. For example, if the target thread is an audio playback thread, the corresponding data processing volume is the audio data played per unit time. Similarly, if the target thread is a UI rendering-related thread, the corresponding data processing volume is the image data rendered by the thread per unit time. Alternatively, the load data can also be the processor utilization rate of the target thread, i.e., CPU utilization rate. In other words, the load data represents the CPU utilization rate occupied by the target thread, i.e., the resources allocated by the processor to the target thread. The magnitude of the CPU utilization rate occupied by the target thread reflects its activity. For example, taking the current running scenario as a UI rendering scenario for a foreground application as an example, if the target thread is a UI rendering-related thread, then a higher CPU utilization rate indicates a higher frequency at which the target thread refreshes the displayed UI content. Therefore, it can be assumed that the target thread's workload is positively correlated with the frequency at which the processor is woken up. This is because when the processor enters sleep mode, the target thread is idle, meaning it is not processing any data. When the target thread needs to process data, it will wake up the processor. Therefore, the target thread's workload is positively correlated with its activity level. Furthermore, when the target thread transitions from sleep to activity, it will wake up the processor. Therefore, the target thread's activity is positively correlated with the frequency at which the processor is woken up. Thus, it can be determined that the target thread's workload is positively correlated with the frequency at which the processor is woken up. In other words, for a target thread with high CPU utilization, it may be woken up shortly after the processor enters sleep mode.
[0049] Therefore, in this embodiment of the application, the frequency at which the processor is woken up is predicted by the load data of the target thread. For example, it can be assumed that the load data of the target thread is positively correlated with the frequency at which the processor is woken up.
[0050] S203: Determine whether the load data is higher than or equal to the threshold.
[0051] As one implementation method, a threshold can be set to identify the level of CPU resources used by the target thread. In other words, the threshold can determine the level of processor activity when running the target thread. If the load data is higher than or equal to the threshold, it means that the processor is busier when running the target thread, that is, the target thread is more active. If the load data is lower than the threshold, it means that the processor is less active when running the target thread compared to when the load data is higher than or equal to the threshold.
[0052] Therefore, if the load data is higher than or equal to the threshold, S204 is executed; if the load data is lower than the threshold, S205 is executed.
[0053] S204: Determine the first hibernation mode from the plurality of hibernation modes as the designated hibernation mode.
[0054] In one implementation, the multiple sleep modes include a first sleep mode and a second sleep mode, where the wake-up time of the first sleep mode is shorter than that of the second sleep mode. In another implementation, the first sleep mode can be called shallow idle, and the second sleep mode can be called deep idle. Shallow idle has a shorter wake-up time than deep idle, but it consumes more power. Furthermore, the number of hardware components disabled by the processor in shallow idle is smaller than that in deep idle. Therefore, under high load conditions, i.e., above or equal to a threshold, shallow idle is designated as the sleep mode, allowing the processor to be quickly woken up when it enters shallow idle, thus ensuring fast execution of the target thread and reducing lag.
[0055] The reason for choosing shallow idle as the specified sleep mode when the load data is higher than or equal to the threshold is that a load data higher than or equal to the threshold indicates that the target thread is highly active. This means that the target thread may enter sleep mode after executing data once, and the target thread will quickly wake up the processor to run again. Therefore, to avoid the processor taking too long to wake up when the target thread is executed again, causing stuttering due to excessive waiting time, shallow idle can be used when the target thread's load data is relatively high. Furthermore, although deep idle consumes less power than shallow idle, this is because more hardware is disabled in deep idle, and the power-saving effect of deep idle requires that the disabled hardware remain in a disabled state for a certain period of time. If the processor is immediately woken up shortly after entering deep idle, the power-saving effect will not be achieved because the power consumption of disabling and enabling hardware is also high.
[0056] Therefore, when the load data is higher than or equal to the threshold, a shallow idle is selected. Then, when the target thread finishes execution and the processor has no other threads to run, that is, when the sleep condition is met, the processor enters the shallow idle state. When the target thread is triggered to execute again, the processor can be quickly woken up, reducing stuttering.
[0057] As one implementation method, it is assumed that the current running scenario includes the rendering of the foreground application's interface. That is, in the current running scenario of the electronic device, a specified application is running in the foreground, and this specified application refreshes the interface content. For example... Figure 3 As shown, taking a browser's display interface as an example, when the browser is running in the foreground, the browser's target thread (e.g., the main thread) loads the content of the current page. At this time, the load data of the target thread is the first data. If this first data is higher than the threshold, it can be determined that the CPU's sleep mode is shallow idle. When the page content is loaded and the user does not interact with the interface, the CPU does not need to run threads, that is, there are no tasks to be executed, and the CPU enters shallow idle. When the user scrolls the interface, the target thread wakes up the processor so that new content can be loaded on the interface, such as... Figure 4 As shown, the processor is woken up from a shallow idle state. Because the wake-up time for a shallow idle state is relatively short, the target thread can be quickly executed by the processor, reducing the time required for user interaction. Figure 3 The page refreshed to Figure 4 When loading content, excessive waiting time should be avoided to reduce the lag and stuttering experience for users.
[0058] S205: Based on a preset strategy algorithm, configure a preset sleep mode for the processor as the specified sleep mode.
[0059] If the load data is below a threshold, a preset sleep mode is configured for the processor based on a preset strategy algorithm, serving as the designated sleep mode. The preset strategy algorithm can be found in the aforementioned embodiments and will not be repeated here. As mentioned earlier, if the target thread's load data is relatively low, it indicates that the target thread is not very active and may not run again soon. In this case, the preset strategy algorithm can be used, which may set the designated sleep mode to deep idle. Alternatively, if the load data is determined to be below a threshold, a second sleep mode can be used as the designated sleep mode, i.e., deep idle can be used as the designated sleep mode.
[0060] S206: When the sleep conditions are met, control the electronic device to enter the specified hibernation mode.
[0061] Additionally, it should be noted that after the electronic device enters the specified sleep mode, if the processor is awakened by the target thread, it needs to return to retrieve the target thread's running parameters and perform subsequent operations.
[0062] In one implementation, when the current running scenario includes a foreground application's interface rendering scenario, the load data is higher than or equal to a threshold, and the foreground application is a specified type of application, then, if the sleep condition is met, in addition to the number of tasks to be processed by the processor being lower than a specified number (e.g., the number of tasks is zero), it also includes the specified type of application still running in the foreground. Specifically, it can be when the specified type of application is running in the foreground and the content displayed in the foreground is not updated, and the sleep condition is met, then the processor can be controlled to enter a shallow idle state.
[0063] Of course, the processor can also be controlled to enter a shallow idle state when the conditions for entering a sleep state are met and the load data of the target thread is higher than or equal to the threshold.
[0064] In addition, when determining the load parameters of the target thread of a specified type of application running in the foreground, an average load can be obtained based on the load data of the specified application running in the foreground from the time of its current startup to the current time, and this average load can be used as the load data of the target thread.
[0065] Therefore, in this embodiment, before the processor goes to sleep, the appropriate sleep state, i.e., shallow idle, can be determined based on the load data of the target thread of a specified type of application with interface rendering function currently running in the foreground. When the conditions for entering the sleep state are met, the processor is controlled to enter the shallow idle state, so that when the target thread is executed again, i.e. when the processor is woken up again, the processor can be quickly woken up from the shallow idle state, reducing the wake-up time and avoiding stuttering.
[0066] Please see Figure 5 , Figure 5 An embodiment of this application illustrates a sleep mode selection method. This method is applied to an electronic device that has multiple sleep modes. That is, the processor of the electronic device can use the multiple sleep modes. Specifically, the method includes: S501 to S505.
[0067] S501: Determine the target thread related to user interaction corresponding to the scenario currently running on the electronic device.
[0068] S502: Obtain the execution interval corresponding to the target thread.
[0069] As one implementation method, the execution interval of a target thread can characterize the time interval between the execution of the target thread once and its subsequent execution. For example, if the target thread executes according to a specified time period, the execution interval can be the time interval between two consecutive executions of the target thread. For instance, when displaying video or playing audio, using a time interval method to execute the thread related to the video display or audio playback at intervals can reduce power consumption and allow the user to perceive the continuity of the video or audio through hearing and sight.
[0070] For example, if the currently running scenario is a foreground application's interface rendering scenario, then the target thread corresponding to the currently running scenario is the interface rendering-related thread. For example, if the foreground application is a video playback software, then for the interface rendering-related thread, the load parameters of the interface rendering-related thread can be obtained, and the specified sleep state corresponding to the target thread can be determined based on the load parameters. If the currently running scenario is an audio playback scenario, then the target thread corresponding to the audio playback scenario is the audio playback-related thread. For example, if the audio playback scenario is an electronic device running audio playback software, and there is no distinction between foreground and background, then for the thread of the audio playback scenario, the execution interval of the audio playback scenario can be obtained, and the specified sleep state corresponding to the target thread can be determined based on the execution interval.
[0071] For the audio playback thread, the electronic device sets the execution interval of the audio playback thread, for example, it can be set to 4ms. That is to say, when the audio playback software is playing the target audio, the audio playback thread plays a segment of the target audio every 4ms. After the segment is finished playing, the CPU will enter an idle state, and thus can enter a sleep state.
[0072] S503: Based on the execution interval, find a candidate sleep mode from the plurality of sleep modes whose wake-up time is less than or equal to the execution interval.
[0073] In one implementation, the wake-up time may include the duration of the hibernation mode and the time taken to wake up from the hibernation mode. For example, if hardware A is turned off when the hibernation mode is entered, the wake-up time of the hibernation mode includes the duration of hardware A being turned off and the time taken to start hardware A.
[0074] S504: Determine the specified hibernation mode from the candidate hibernation modes.
[0075] S505: When the sleep conditions are met, control the electronic device to enter the specified hibernation mode.
[0076] In one implementation, the application corresponding to the target thread can be a foreground application, meaning the target thread is executed when switched to the foreground. In this case, the execution interval of the target thread can be understood as the time interval between switching between the foreground and background. This time interval can be obtained haphazardly: by statistically analyzing the time interval between foreground and background switching of the target thread within a specified time period, and using this statistically analyzed time interval as the execution interval of the target thread. It should be noted that when the target thread is running in the foreground, if the electronic device is locked, the target thread is effectively switched to the background and does not execute. Therefore, when the target thread is running in the foreground, the processor running it is in a non-idle state. When the electronic device is locked, the target thread does not execute, and the processor enters an idle state. Then, when the electronic device is unlocked, the target thread runs in the foreground again, and the processor is woken up. Therefore, in this case, the wake-up time for the specified sleep mode of the processor should be less than or equal to the time interval between switching between the foreground and background of the target thread.
[0077] In another implementation, the target thread is an audio playback thread. The execution interval of the target thread is the time interval between the end of the current execution and the next execution during the playback of audio data. A candidate sleep mode with a wake-up time less than or equal to the execution interval is searched from multiple sleep modes, and a specified sleep mode is determined from these candidate sleep modes. Specifically, assuming there are multiple candidate sleep modes, the sleep mode with the shortest wake-up time can be selected as the specified sleep mode. This ensures that when the target thread executes again, the processor is already awake. For example, if the execution interval of the target thread is 4 seconds, and the processor enters sleep mode at the end of the current execution (denoted as t1), and the wake-up time of this sleep mode is 3 seconds, then the processor will be awakened and exit sleep mode in the third second after t1. In the fourth second after t1, when the target thread executes again, the processor will be awakened. Furthermore, if there are multiple candidate sleep modes, the sleep mode with the longest wake-up time can be selected, thereby minimizing the power consumption of the electronic device while meeting the usage requirements of the target thread.
[0078] It should be noted that if the current running scenario is a foreground application's UI rendering scenario, then the target thread corresponding to this scenario is the UI rendering-related thread. For example, if the foreground application is a video playback software, then for the UI rendering-related thread, the load parameters of that thread can be obtained, and the specified sleep state corresponding to the target thread can be determined based on these load parameters. If the current running scenario is an audio playback scenario, then the target thread corresponding to this scenario is the audio playback-related thread. For example, if the audio playback scenario involves an electronic device running audio playback software without distinguishing between foreground and background, then for the thread in this audio playback scenario, the execution interval of that scenario can be obtained, and the specified sleep state corresponding to the target thread can be determined based on these intervals. If the current running scenario is a foreground application's UI rendering and audio playback scenario, meaning that in this current running scenario, the foreground application is displaying content and also playing audio, then the first thread of the foreground application and the second thread corresponding to the audio playback scenario are determined, their priorities are determined, and the thread with the higher priority is selected as the target thread. The specified sleep mode is determined based on the target thread's running parameters. Of course, it is also possible to use both the first thread and the second thread as target threads, and then use the sleep mode that can meet the usage requirements of both the first thread and the second thread as the specified sleep mode.
[0079] Additionally, for scenarios where the current application is rendering the interface and playing audio, if the application corresponding to the audio playback scenario is the same as the one running in the foreground (e.g., the foreground application is playing audio while displaying the screen), then the type of the foreground application is determined. If it is a video application, then the thread related to the interface rendering of the foreground application is taken as the target thread, and then the specified sleep mode is determined based on the running parameters of the target thread. If the type of the foreground application is an audio application, then the thread related to the audio playback is taken as the target thread, and then the specified sleep mode is determined based on the running parameters of the target thread.
[0080] It's important to note that an application's category can be set by the application developer during development, or it can be set by the user after the application is installed on the electronic device. For example, after a user installs an application on their electronic device and launches it, a dialog box will appear instructing the user to set the application's category. The specific category the application belongs to can be set by the user according to their needs. For instance, a user can set a social networking app to the audio category, the video category, or the social category.
[0081] Additionally, electronic devices often have application installer software installed, such as the App Store on iOS. This installer software contains a list of applications that users can download, update, and open. Furthermore, it can categorize applications by type, such as audio, video, or games. Therefore, users are already aware of the application's category when installing it using this installer software.
[0082] Furthermore, considering that some applications can play both video and audio, if an application supports video playback, its type will be set to video; if it only supports audio playback, its type will be set to audio. Specifically, whether an application supports video playback can be determined by examining its feature description, such as supported playback formats, or by checking if a video playback module is present within the application's program modules, such as the encoding / decoding algorithm used for a particular video.
[0083] Furthermore, if some applications have diverse functions, their category needs to be determined based on their specific operational behavior. For example, if some applications can play both video and audio, such as some video playback software that can play both audio files and videos, then the category of the application can be determined based on the application's usage history. That is, based on the application's usage history over a certain period of time, it can be determined whether the user prefers to play video or audio when using the application.
[0084] Specifically, the system acquires the operational behavior data of all users within a preset time period. Here, "all users" refers to all users who have installed the application. This operational behavior data can be obtained from the server corresponding to the application. In other words, when a user uses the application, they log in with their corresponding user account, and the operational behavior data associated with that user account is sent to the application's server. The server then stores the acquired operational behavior data in association with the corresponding user account. In some embodiments, the electronic device sends an operational behavior query request for the application to the application's server, and the server sends the operational behavior data of all users within a certain preset time period to the electronic device.
[0085] The operation behavior data includes the name and time of the played audio files and the name and time of the played video files. By analyzing this operation behavior data, the number of audio files played by the application and the total time can be determined within a certain preset time period. The number of video files played by the application and the total time can also be obtained. Based on the proportion of the total playback time of audio and video files within the preset time period, the application category is determined. Specifically, the proportion of the total playback time of audio and video files within the preset time period is obtained. For ease of description, the proportion of the total playback time of audio files within the preset time period is recorded as the audio playback proportion, and the proportion of the total playback time of video files within the preset time period is recorded as the video playback proportion. If the video playback proportion is greater than the audio playback proportion, the application category is set to video type; if the audio playback proportion is greater than the video playback proportion, the application category is set to audio type. For example, if the preset time period is 30 days, or 720 hours, and the total playback time of audio files is 200 hours, then the audio playback ratio is 27.8%, and the total playback time of video files is 330 hours, then the video playback ratio is 45.8%. Since the video playback ratio is greater than the audio playback ratio, the application category is set to video type.
[0086] Please see Figure 6 The diagram shows a structural block diagram of a sleep mode selection device 600 provided in an embodiment of this application. The device may include: a determination unit 601, an acquisition unit 602, a setting unit 603, and a control unit 604.
[0087] The determining unit 601 is used to determine the target thread related to user interaction corresponding to the scene currently running on the electronic device.
[0088] The acquisition unit 602 is used to acquire the running parameters corresponding to the target thread.
[0089] Furthermore, the acquisition unit 602 is also used to acquire the running parameters corresponding to the target thread if the target thread is running on the processor.
[0090] Furthermore, the acquisition unit 602 is also configured to configure a preset sleep mode for the processor based on a preset strategy algorithm if the target thread is not running on the processor, and control the electronic device to enter the preset sleep mode when the sleep conditions are met.
[0091] Setting unit 603 is used to determine, based on the operating parameters, a specified sleep mode that meets the usage requirements of the target thread from the plurality of sleep modes.
[0092] Furthermore, the plurality of sleep modes include a first sleep mode and a second sleep mode, wherein the wake-up time of the first sleep mode is less than the wake-up time of the second sleep mode, the operating parameters include load data, and the setting unit 603 is further configured to determine the first sleep mode as the specified sleep mode from the plurality of sleep modes if the load data is higher than or equal to a threshold, wherein the load data size of the target thread is positively correlated with the frequency at which the processor is woken up.
[0093] Furthermore, the setting unit 603 is also used to configure a preset sleep mode for the processor as a specified sleep mode based on a preset strategy algorithm if the load data is lower than a threshold.
[0094] Furthermore, the power consumption of the first sleep mode is higher than that of the second sleep mode, and the number of hardware components entering sleep mode in the first sleep mode is greater than the number entering sleep mode in the second sleep mode. The load data refers to processor utilization. The currently running scenario includes the UI rendering scenario of the foreground application, and the target thread is the thread related to UI rendering.
[0095] Furthermore, the wake-up time for each sleep mode is different. The running parameters include the execution interval of the target thread. The setting unit 603 is also used to search for candidate sleep modes whose wake-up time is less than or equal to the execution interval from the plurality of sleep modes based on the execution interval; and to determine the specified sleep mode from the candidate sleep modes.
[0096] Furthermore, the currently running scenario includes an audio playback scenario, and the target thread is an audio playback-related thread.
[0097] The control unit 604 is used to control the electronic device to enter the specified sleep mode when sleep conditions are met.
[0098] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described device and module can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0099] In the several embodiments provided in this application, the coupling between modules can be electrical, mechanical, or other forms of coupling.
[0100] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.
[0101] Please refer to Figure 7This document illustrates a structural block diagram of an electronic device according to an embodiment of this application. The electronic device 100 can be a smartphone, tablet computer, e-reader, or other electronic device capable of running applications. The electronic device 100 in this application may include one or more of the following components: a processor 110, a memory 120, and one or more applications, wherein the one or more applications can be stored in the memory 120 and configured to be executed by one or more processors 110, and the one or more applications are configured to perform the methods described in the foregoing method embodiments.
[0102] Processor 110 may include one or more processing cores. Processor 110 connects to various parts within the electronic device 100 using various interfaces and lines, and performs various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets, or instruction sets stored in memory 120, and by calling data stored in memory 120. Optionally, processor 110 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). Processor 110 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem handles wireless communication. It is understood that the modem may also not be integrated into processor 110 and may be implemented separately using a communication chip.
[0103] The memory 120 may include random access memory (RAM) or read-only memory (ROM). The memory 120 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 120 may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as touch functionality, sound playback functionality, image playback functionality, etc.), and instructions for implementing the various method embodiments described below. The data storage area may also store data created by the terminal 100 during use (such as phonebook data, audio and video data, chat log data, etc.).
[0104] Please refer to Figure 8This diagram illustrates a structural block diagram of a computer-readable storage medium provided in an embodiment of this application. The computer-readable medium 800 stores program code that can be called by a processor to execute the methods described in the above method embodiments.
[0105] The computer-readable storage medium 800 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. Optionally, the computer-readable storage medium 800 includes a non-transitory computer-readable storage medium. The computer-readable storage medium 800 has storage space for program code 810 that performs any of the method steps described above. This program code can be read from or written to one or more computer program products. The program code 810 may be compressed, for example, in a suitable form.
[0106] Please refer to Figure 9 The diagram illustrates a structural block diagram of a computer program product 900 provided in an embodiment of this application. The computer program product includes a computer program / instructions 910, which, when executed by a processor, implements the aforementioned method.
[0107] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A method of selecting a sleep mode, characterized by, The method is applied to an electronic device, a processor of the electronic device corresponds to multiple sleep modes, and the method comprises the following steps: determining a target thread corresponding to a current running scene of the electronic device and related to user interaction; obtaining a running parameter corresponding to the target thread; based on the running parameter, determining a specified sleep mode from the multiple sleep modes to meet the use requirement of the target thread; when the processor enters an idle state, controlling the electronic device to enter the specified sleep mode; wherein, based on the running parameter, determining a specified sleep mode from the multiple sleep modes to meet the use requirement of the target thread comprises: in the case that the multiple sleep modes include a first sleep mode and a second sleep mode and the running parameter includes load data, if the load data is higher than or equal to a threshold, determining the first sleep mode from the multiple sleep modes as the specified sleep mode, wherein the load data size of the target thread is positively correlated with the frequency of the processor being woken up, and the wake-up time consumption of the first sleep mode is less than that of the second sleep mode; or, in the case that the wake-up time consumption of each sleep mode is different and the running parameter includes the execution interval of the target thread, based on the execution interval, searching for an alternative sleep mode from the multiple sleep modes, whose wake-up time consumption is less than or equal to the execution interval, and determining the specified sleep mode from the alternative sleep mode.
2. The method of claim 1, wherein, The method further comprises: if the target thread is not running on the processor, configuring a preset sleep mode for the processor based on a preset strategy algorithm, and when the processor enters an idle state, controlling the electronic device to enter the preset sleep mode.
3. The method of claim 2, wherein, The method further comprises: if the load data is lower than the threshold, configuring a preset sleep mode for the processor as the specified sleep mode based on a preset strategy algorithm.
4. The method of claim 1, wherein, The power consumption of the first sleep mode is higher than that of the second sleep mode, and the hardware of the processor entering a sleep state in the first sleep mode is more than that in the second sleep mode. The load data is the processor usage rate.
5. The method of claim 1, wherein, The current running scene includes an interface rendering scene of a foreground application, and the target thread is an interface rendering related thread.
6. The method of claim 1, wherein, The current running scene includes an audio playing scene, and the target thread is an audio playing related thread.
7. The method of claim 1, wherein, The method is applied to an electronic device, a processor of the electronic device corresponds to multiple sleep modes, and the device comprises the following steps:
8. The method of claim 1, wherein, a determining unit configured to determine a target thread corresponding to a current running scene of the electronic device and related to user interaction; 9. A hibernate mode selection apparatus, characterized by comprising: an obtaining unit configured to obtain a running parameter corresponding to the target thread; a setting unit configured to determine a specified sleep mode from the multiple sleep modes to meet the use requirement of the target thread based on the running parameter; a control unit configured to control the electronic device to enter the specified sleep mode when the processor enters an idle state. The specified sleep mode is determined from the plurality of sleep modes based on the running parameter, including: In a case where the plurality of sleep modes include a first sleep mode and a second sleep mode and the running parameter includes load data, if the load data is higher than or equal to a threshold, a first sleep mode is determined as the specified sleep mode from the plurality of sleep modes, wherein the load data size of the target thread is positively correlated with the frequency of the processor being woken up, and the wake-up time consumption of the first sleep mode is less than that of the second sleep mode; Or, in a case where the wake-up time consumption of each sleep mode is different and the running parameter includes an execution interval of the target thread, based on the execution interval, an alternative sleep mode with a wake-up time consumption less than or equal to the execution interval is searched from the plurality of sleep modes, and the specified sleep mode is determined from the alternative sleep mode.
10. An electronic device, comprising: The computer readable medium stores processor-executable program code that, when executed by the processor, causes the processor to perform the method of any one of claims 1-8. The computer readable medium stores processor-executable program code that, when executed by the processor, causes the processor to perform the method of any one of claims 1-8. The computer program / instruction, when executed by the processor, implements the method of any one of claims 1-8. 11. A computer readable medium characterized by 12. A computer program product comprising computer programs / instructions, characterized in that,
Citation Information
Patent Citations
Thread importance based processor core parking and frequency selection
CN109906437A
Method and device for reducing server power consumption
CN111966208A