Task running method, device, storage medium and terminal
By detecting the terminal working temperature and calculating the running time and idle time of the processor, the problem of lag caused by reducing the CPU frequency when the smart terminal device is heated is solved, and the terminal is maintained efficiently while cooling is achieved.
Patent Information
- Application Number
- CN202110957428.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-19
- Publication Date
- 2025-06-17
- Estimated Expiration
- 2041-08-19
AI Technical Summary
When smart terminal devices generate heat, they usually reduce power consumption by reducing the CPU frequency, which leads to a decrease in task operation efficiency and lag.
By detecting the operating temperature of the terminal, the idle duty cycle of the task on the processor is determined, and the run time and idle time of the processor are calculated based on the initial run time and idle duty cycle, and the task is run according to these times.
While alleviating the terminal's heat, it avoids the problem of terminal lag, ensuring that the processor runs tasks within the run time and remains idle for the idle time.
Smart Images

Figure CN113849284B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular, to a task running method, apparatus, storage medium, and terminal. Background Art
[0002] With the development of intelligent terminal devices, the processing performance of intelligent terminal devices is also constantly becoming more powerful. A powerful processor can bring a better performance experience to users. However, while users experience the good performance of the processor, the power consumption of intelligent terminal devices is also getting higher and higher, and the resulting heat problem cannot be ignored.
[0003] In related technologies, when an intelligent terminal device gets hot, the use of hardware resources is usually restricted. For example, when the working temperature of the central processing unit (CPU) is relatively high, the CPU frequency is usually reduced to reduce power consumption, thereby reducing the working temperature of the CPU and achieving the effect of alleviating the heat generation of the intelligent terminal device. However, reducing the CPU frequency will also reduce the running efficiency of some tasks, resulting in a lag situation. Summary of the Invention
[0004] Embodiments of this application provide a task running method, apparatus, computer storage medium, and terminal, which can avoid the problem of lag in the terminal while alleviating the heat generation of the terminal. The technical solutions are as follows:
[0005] In a first aspect, an embodiment of this application provides a task running method, which includes:
[0006] Detect the current working temperature of the terminal, and determine the idle duty ratio corresponding to at least one task on the processor at the working temperature;
[0007] Determine the initial running duration corresponding to each of the tasks;
[0008] Based on the initial running duration and the idle duty ratio corresponding to each of the tasks, calculate the processor running duration and the processor idle duration corresponding to each of the tasks;
[0009] Run each of the tasks according to the processor running duration and the processor idle duration corresponding to each of the tasks.
[0010] In a second aspect, an embodiment of this application provides a task running apparatus, which includes:
[0011] A first determination module, configured to detect the current working temperature of the terminal, and determine the idle duty ratio corresponding to at least one task on the processor at the working temperature;
[0012] A second determination module, configured to determine the initial running duration corresponding to each of the tasks;
[0013] A third calculation module, configured to calculate the processor running duration and the processor idle duration corresponding to each of the tasks based on the initial running duration corresponding to each of the tasks and the idle duty ratio;
[0014] A fourth operation module, configured to operate each of the tasks according to the processor running duration and the processor idle duration corresponding to each of the tasks.
[0015] In a third aspect, an embodiment of the present application provides a computer storage medium, which has multiple instructions, and the instructions are adapted to be loaded and executed by a processor to perform the above method steps.
[0016] In a fourth aspect, an embodiment of the present application provides a terminal, which may include: a memory and a processor; wherein, the memory stores a computer program, and the computer program is adapted to be loaded and executed by the memory to perform the above method steps.
[0017] The beneficial effects brought by the technical solution provided by the embodiment of the present application at least include:
[0018] When the solution of the embodiment of the present application is executed, it detects the current working temperature of the terminal, determines the idle duty ratio corresponding to at least one task on the processor at the working temperature, determines the initial running duration corresponding to each of the tasks, and calculates the processor running duration and the processor idle duration corresponding to each of the tasks based on the initial running duration corresponding to each of the tasks and the idle duty ratio, and operates each of the tasks according to the processor running duration and the processor idle duration corresponding to each of the tasks. The present application can calculate the processor running duration and the processor idle duration corresponding to at least one task on the processor at the current working temperature of the terminal, and can allow the processor to run the corresponding tasks during the processor running duration and keep the processor in an idle state during the processor idle duration, avoiding the situation in the related art where the processor frequency is limited to achieve the purpose of cooling due to the increase in the terminal temperature, resulting in the terminal becoming stuck, while the present application can relieve the terminal temperature and ensure that the terminal does not become stuck. Description of the Drawings
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention, and those skilled in the art can obtain other drawings without creative efforts based on these drawings.
[0020] Figure 1It is a schematic diagram of a scenario of a task running method provided by an embodiment of the present application;
[0021] Figure 2 It is a schematic flowchart of a task running method provided by an embodiment of the present application;
[0022] Figure 3 It is a schematic flowchart of another task running method provided by an embodiment of the present application;
[0023] Figure 4 It is a broken line schematic diagram in a task running method provided by an embodiment of the present application;
[0024] Figure 5 It is a schematic flowchart of yet another task running method provided by an embodiment of the present application;
[0025] Figure 6 It is a broken line schematic diagram in another task running method provided by an embodiment of the present application;
[0026] Figure 7 It is a schematic structural diagram of a task running device provided by an embodiment of the present application;
[0027] Figure 8 It is a schematic structural diagram of a terminal provided by an embodiment of the present application. Detailed implementation manners
[0028] To make the invention objectives, features, and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in 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. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative efforts fall within the protection scope of the present application.
[0029] In the description of the present application, it should be understood that terms such as "first" and "second" are only for descriptive purposes and cannot be construed as indicating or implying relative importance. In the description of the present application, it should be noted that unless otherwise clearly specified and limited, "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally further include steps or units not listed, or may optionally further include other steps or units inherent to these processes, methods, products, or devices. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to specific circumstances. In addition, in the description of the present application, unless otherwise stated, "a plurality" means two or more. "And / or" describes the association relationship of associated objects and indicates that three relationships may exist. For example, A and / or B may represent three situations: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects before and after.
[0030] In the related art, when the terminal gets hot, the use of hardware resources is usually restricted. For example, when the temperature of the CPU rises to a certain value, some manufacturers will reduce the CPU frequency. As the CPU frequency decreases, the power consumption of the CPU decreases, further reducing heat generation, thereby alleviating the temperature of the terminal.
[0031] The advantage of reducing the CPU frequency is that it can reduce the temperature of the terminal. However, reducing the CPU frequency causes the CPU to run all tasks corresponding to applications at the reduced frequency. When running some tasks that require a high processing speed, such as the task currently interacting with the user, there will be a lag situation, bringing a bad experience to the user.
[0032] The present application will be described in detail below with specific embodiments.
[0033] Please refer to Figure 1 , which is a schematic diagram of a scenario of a task running method provided by an embodiment of the present application.
[0034] As Figure 1 shown, Figure 1 it includes a user and a terminal, and the terminal can be a mobile phone.
[0035] Exemplarily, Figure 1 when the user in Figure 1The quantities shown. When multiple applications are running on a mobile phone simultaneously, when the mobile phone has a split-screen mode and is in the split-screen mode, there can be multiple applications interacting with the user simultaneously; while when the mobile phone is in the single-screen mode, there is only 1 application interacting with the user.
[0036] When multiple applications are running simultaneously, the tasks corresponding to the applications currently interacting with the user need to be run by the CPU, and the tasks corresponding to the applications that are not currently interacting with the user also need to be run by the CPU. For applications that are not currently interacting with the user, such as some chat and social software, the CPU needs to push messages to the user in real time. For applications that are not currently interacting with the user, such as some software that does not need to push messages to the user in real time, they can periodically obtain update information and push the update information to the user. Such software can include weather software, music software, etc. Of course, these applications can also not push messages to the user during the process of not interacting with the user and can wait in the background to be awakened by the user.
[0037] In the following method embodiments, for the convenience of description, only the execution subject of each step is introduced as the terminal.
[0038] Please refer to Figure 2 , in Figure 1 Based on the scene schematic diagram shown, a flowchart of a task running method provided by an embodiment of the present application is shown. As Figure 2 shown, the method of the embodiment of the present application may include the following steps:
[0039] S201, Detect the current working temperature of the terminal and determine the idle duty ratio corresponding to at least one task on the processor at the working temperature.
[0040] Among them, the working temperature refers to the temperature of the CPU in the embodiment of the present application.
[0041] Optionally, detecting the current working temperature of the terminal can be understood as obtaining the temperature of the CPU by reading the value of the temperature sensor built in the terminal and converting the read value. Usually, temperature sensors can be installed at different parts inside the terminal to measure the temperature of each hardware.
[0042] Among them, a task refers to a task in Android. Generally speaking, a task can be said to be a set of Activity components aggregated in a stack mode. These Activities can be from the same application or from different applications. In an Android application, an Activity is usually a single screen. It can display some controls, listen for and handle user events, and respond to user events. The Activities in a task have potential forward and backward associations. The newly added Activity is located at the top of the stack, and only the Activity at the top of the stack has the opportunity to interact with the user. When the Activity at the top of the stack completes its mission and exits, the task will pop it from the stack and let the next Activity that will run to the top of the stack interact with the user until there are no more Activities in the stack and the task ends.
[0043] Among them, the idle duty ratio refers to the percentage of the processor idle time when the processor is in the idle state to the processor running time when the processor is actually running tasks during the initial running duration. The initial running duration refers to the duration required for the processor to run a task in the related technology. This duration can be set by the processing strategy of the processor. The specific processing strategy can be determined according to the actual application. The tasks corresponding to different applications can be set with the same initial running duration, or the tasks corresponding to different applications can also be set with different initial running durations according to the application type. In addition, this duration can also be determined according to the historical running duration of the same-source or same-type tasks.
[0044] Optionally, determining the idle duty ratio corresponding to at least one task on the processor at the working temperature can be understood as first determining at least one task to be run on the processor in the current operating environment of the terminal, and then obtaining the duty ratio of these tasks at the working temperature. At least one task to be run on the processor can refer to the task currently interacting with the user or the task that is currently not interacting with the user but is also running. After obtaining at least one task to be run on the processor, these tasks can be classified according to their importance to the user and can be divided into three types of tasks: primary tasks, foreground tasks, and background tasks. A primary task can refer to the task currently interacting with the user; a foreground task can refer to the task that is running without interacting with the user after being invoked by the user and will push messages to the user in real time; a background task can refer to the task that is running without interacting with the user after being invoked by the user and will not push messages to the user in real time.
[0045] In a feasible implementation manner, the corresponding relationship between different types of tasks and the idle duty ratio can be preset under scenarios with different working temperatures. The corresponding relationship can be stored locally on the terminal. When a task is obtained and the task type corresponding to the task is determined, the idle duty ratio corresponding to each task type at the current working temperature can be obtained from the local, and then the idle duty ratio of each task can be determined.
[0046] In a feasible implementation manner, after determining the task type corresponding to the task, these tasks can be grouped according to the task type, and a primary task group, a foreground task group, and a background task group can be obtained respectively. All tasks in the primary task group are tasks of the primary type, all tasks in the foreground task group are tasks of the foreground type, and all tasks in the background task group are tasks of the background type. The corresponding relationship between different task groups and the idle duty ratio can be preset under scenarios with different working temperatures. The corresponding relationship can be stored locally on the terminal. When a task is obtained and the task group where the task is located is determined, the idle duty ratio corresponding to each task group at the current temperature can be obtained from the local, and then the idle duty ratio of each task can be determined.
[0047] S202, determine the initial running duration corresponding to each of the tasks.
[0048] Among them, the initial running duration refers to the duration required for the processor to run a task in the related art. This duration can be set by the processing strategy of the processor. The specific processing strategy can be determined according to the actual application. In addition, this duration can also be determined according to the historical running duration of homologous or similar tasks.
[0049] Optionally, in the embodiments of the present application, the initial running duration of each task can be preset and stored locally on the terminal. After determining the idle duty ratio corresponding to each task, the initial running duration corresponding to each task can be directly obtained from the local.
[0050] In a feasible implementation, the initial running time corresponding to each task is set. The initial running time corresponding to each task type can be set according to the task type, including three types: primary task, foreground task and background task. The initial running time can be an original initial running time set by the processor of the task terminal based on the processing strategy of the processor. The terminal can directly obtain an original initial running time set based on the processing strategy of the processor; further: the initial running time corresponding to different types of tasks can be different. Of course, the historical running time corresponding to the task of each task type can also be obtained, and the historical running time can be set as the initial running time corresponding to each task type. Therefore, after determining the task type corresponding to each task, the initial running time corresponding to each task can be found according to the task type. It can be understood that regardless of the task type, the same initial running time can be set for all tasks. The initial running time can be a fixed value, which can be directly obtained when needed.
[0051] In a feasible implementation, the initial running time corresponding to each task is set. The initial running time corresponding to each task group can be set according to the task group to which each task is located, including three types of task groups: primary task group, foreground task group, and background task group. The initial running time corresponding to tasks in different task groups may be different. Of course, the historical running time corresponding to the tasks of each task group can also be obtained, and the historical running time can be set as the initial running time corresponding to each task group. Therefore, after determining the task group to which each task is located, the initial running time corresponding to each task can be found according to the task group. It is understandable that regardless of the task group, the same initial running time can also be set for all tasks. The initial running time can be a fixed value, which can be directly obtained when needed.
[0052] In some implementations, the terminal may execute step S201 "detecting the current operating temperature of the terminal and determining the idle duty cycle corresponding to at least one task on the processor at the operating temperature" in any order and step S202 "determining the initial running time corresponding to each of the tasks" in any order, that is, the terminal may execute step S201 first and then step S202; or, the terminal may execute step S202 first and then step S201; or, the terminal may execute step S201 and step S202 simultaneously. The specific order may be determined based on the actual application situation and is not specifically limited here.
[0053] S203: Calculate the processor running time and processor idle time corresponding to each task based on the initial running time and the idle duty cycle corresponding to each task.
[0054] Among them, the running duration of the processor: when a task is running, it is the actual duration required for the processor to run the task. The idle duration of the processor: when a task is running, within the initial running duration, after the actual duration required for the processor to run the task, it is the duration in the idle state.
[0055] Optionally, by calculating the product of the initial running duration and the idle duty cycle corresponding to each task, the idle duration of the processor corresponding to each task can be obtained. Further, by subtracting the idle duration of the processor corresponding to each task from the initial running duration corresponding to each task, the running duration of the processor can be obtained.
[0056] S204, run each of the tasks according to the running duration and the idle duration of the processor corresponding to each task.
[0057] Optionally, in the embodiments of the present application, at least one task on the processor can be arranged on the task queue corresponding to the processor. The task queue contains at least one task to be run by the processor. Each task waits to be run by the processor in the queue order. The at least one task on the queue follows the first-in, first-out queue order. When the processor is running these tasks, it can run each task in the first-in, first-out queue order. Since the running duration and the idle duration of the processor are set for each task, and the sum of the running duration and the idle duration of the processor is equal to the initial running duration. When the processor runs each task, it can arrange the running duration of the processor in the first half of the initial running duration, and arrange the idle duration of the processor in the second half of the initial running duration. Then the processor can first run the task during the running duration of the processor, and then be in the idle state during the idle duration of the processor. For example, taking a task A as an example, when the processor runs task A, it can run task A during the running duration of the processor, and can be in the idle state during the idle duration of the processor without running task A. It can be understood that in the related art, when the processor is running task A, running task A is what the processor has to do within the initial running duration. Then in the embodiments of the present application, the processor works during the running duration of the processor and rests during the idle duration of the processor.
[0058] When the solution of the embodiment of the present application is executed, the current working temperature of the terminal is detected, the idle duty ratio corresponding to at least one task on the processor at the working temperature is determined, the initial running duration corresponding to each task is determined, and based on the initial running duration and the idle duty ratio corresponding to each task, the processor running duration and the processor idle duration corresponding to each task are calculated, and each task is run according to the processor running duration and the processor idle duration corresponding to each task. The present application can calculate the processor running duration and the processor idle duration corresponding to at least one task on the processor at the current working temperature of the terminal, and can make the processor run the corresponding task during the processor running duration and make the processor idle during the processor idle duration, avoiding the situation in the related art that the processor frequency is limited to achieve the purpose of cooling due to the increase in the terminal temperature, resulting in the terminal becoming stuck. The present application can relieve the terminal temperature while ensuring that the terminal does not become stuck.
[0059] Please refer to Figure 3 , on the basis of the scenario schematic diagram shown in Figure 1 , a flowchart of a task running method provided by an embodiment of the present application is shown. As Figure 3 shown, the method of the embodiment of the present application may include the following steps:
[0060] S301, Detect the current working temperature of the terminal.
[0061] Specifically, reference can be made to Figure 2 S201 in, which will not be elaborated here.
[0062] S302, Determine that the working temperature range is within the reference temperature range, determine the task type corresponding to each task among at least one task on the processor, and determine the target temperature range to which the working temperature belongs.
[0063] Among them, the reference temperature range can be a preset reference temperature range, and different temperature ranges can be preset within the reference temperature range. For example, the processor temperature is usually 30 degrees higher than the room temperature, the reference temperature range can be set to 40 degrees to 60 degrees, and the temperature ranges can be divided into 10 ranges, which can be 40 degrees to 42 degrees, 42 degrees to 44 degrees, 44 degrees to 46 degrees, 46 degrees to 48 degrees... respectively. The temperature values in these temperature ranges can be greater than or equal to the temperature lower limit and less than the temperature upper limit.
[0064] Among them, the task types can include three types: primary task, foreground task, and background task. A primary task refers to a task that is currently interacting with the user during operation; a foreground task refers to a task that pushes messages to the user when the user is not interacting with it during operation; a background task refers to a task that does not need to push messages to the user when the user is not interacting with it during operation.
[0065] For example: The current operating environment of the terminal is that the user is browsing products in Taobao, and the currently running applications also include WeChat, QQ, email, weather, and music. The tasks corresponding to the above applications can be classified. The task corresponding to Taobao can be used as the primary task, the tasks corresponding to WeChat, QQ, and email can be used as foreground tasks, and the tasks corresponding to weather and music can be used as background tasks.
[0066] Optionally, since the current working temperature of the terminal is determined, the target temperature range within which the current working temperature belongs can be determined. Determining the task types corresponding to each task to be run currently can be understood as classifying each task to be run currently, and these tasks can be divided into primary tasks, foreground tasks, and background tasks.
[0067] S303, based on the correspondence between task types and idle duty ratios at different temperature ranges, determine the idle duty ratios corresponding to each of the tasks at the target temperature range.
[0068] Optionally, the correspondence between task types, temperature ranges, and idle duty ratios can be set in advance and stored locally in the terminal. Since there are three task types set in the embodiments of the present application, therefore, the correspondence between primary tasks, temperature ranges, and idle duty ratios, the correspondence between foreground tasks, temperature ranges, and idle duty ratios, and the correspondence between background tasks, temperature ranges, and idle duty ratios can be set respectively. When the target temperature range to which the current working temperature belongs is determined and the tasks are classified by task type, the correspondence between the task type, temperature range, and idle duty ratio can be queried locally according to the task type. Further, the idle duty ratio corresponding to the target temperature range can be found from the queried correspondence.
[0069] For example: Refer to the Figure 4 shown broken line schematic diagram. Exemplarily, Figure 4 shows the correspondence between tasks of different task types, temperature ranges, and idle duty ratios. For primary tasks, when the CPU temperature is in the range of 40 degrees to 56 degrees, the idle duty ratio is set to 0; when the CPU temperature is in the range of 56 degrees to 60 degrees, the idle duty ratio is set to 5%.
[0070] For foreground tasks, when the CPU temperature is in the range of 40°C to 44°C, the idle duty ratio is set to 0; when the CPU temperature is in the range of 44°C to 46°C, the idle duty ratio is set to 10%; when the CPU temperature is in the range of 46°C to 48°C, the idle duty ratio is set to 15%; when the CPU temperature is in the range of 48°C to 50°C, the idle duty ratio is set to 20%; when the CPU temperature is in the range of 50°C to 52°C, the idle duty ratio is set to 25%; when the CPU temperature is in the range of 44°C to 46°C, the idle duty ratio is set to 10%; when the CPU temperature is in the range of 46°C to 48°C, the idle duty ratio is set to 15%; when the CPU temperature is in the range of 48°C to 50°C, the idle duty ratio is set to 15%; when the CPU temperature is in the range of 50°C to 52°C, the idle duty ratio is set to 20%; when the CPU temperature is in the range of 52°C to 54°C, the idle duty ratio is set to 25%; when the CPU temperature is in the range of 54°C to 60°C, the idle duty ratio is set to 30%.
[0071] For background tasks, when the CPU temperature is in the range of 40°C to 42°C, the idle duty ratio is set to 10%; when the CPU temperature is in the range of 42°C to 44°C, the idle duty ratio is set to 15%; when the CPU temperature is in the range of 44°C to 46°C, the idle duty ratio is set to 20%; when the CPU temperature is in the range of 46°C to 48°C, the idle duty ratio is set to 25%; when the CPU temperature is in the range of 48°C to 50°C, the idle duty ratio is set to 30%; when the CPU temperature is in the range of 50°C to 52°C, the idle duty ratio is set to 35%; when the CPU temperature is in the range of 54°C to 56°C, the idle duty ratio is set to 40%; when the CPU temperature is in the range of 56°C to 58°C, the idle duty ratio is set to 45%; when the CPU temperature is in the range of 58°C to 60°C, the idle duty ratio is set to 50%.
[0072] S304. Divide the estimated total running duration by the total number of current tasks to be run to obtain the average duration, and use the average duration as the reference running duration.
[0073] Among them, the estimated total running duration refers to the duration required for the CPU to run multiple tasks in a loop each time within a period of time. For example, continuing with the example in S302, the currently running applications include Taobao, WeChat, QQ, email, weather, and music. In a short period of time, the CPU needs to run the multiple tasks corresponding to these applications in a loop, and the estimated total running duration can be set to 1000 milliseconds. That is to say, the CPU needs to run all the above tasks once within 1000 milliseconds. It can be understood that the estimated total running duration can be preset according to the actual application, and when the embodiments of the present application are executed, the preset estimated total running duration can be directly obtained.
[0074] In a feasible implementation, the total number of tasks to be run currently can be determined. Further, the quotient obtained by dividing the expected total running duration by the total number of tasks to be run currently can be the average duration of each task, and this average duration can be used as the reference running duration of each task.
[0075] S305. Based on the task types corresponding to the respective tasks, adjust the reference running duration to obtain the initial running durations corresponding to the respective tasks.
[0076] Optionally, in the related art, without considering the task type, it can be determined that the reference running duration of each task is the same. In the implementation of this application, in order to ensure the user experience, the primary task is the task that is currently interacting with the user, and the reference running duration can be appropriately increased. For a foreground task that is not currently interacting with the user, the reference running duration can be maintained, or it can also be increased. The increment step of the reference running duration of the foreground task can be less than the increment step of the primary task, or the increment step of the reference running duration of the foreground task can also be equal to the increment step of the primary task. When a background task is not interacting with the user, it does not affect the user experience, and the reference running duration can be appropriately reduced. It should be noted that when the reference running duration corresponding to a task is adjusted, the sum of the reference durations corresponding to all tasks may not be equal to the expected total running duration. At this time, the adjusted reference running duration can be used as the initial running duration of each task.
[0077] For example: Continuing with the example in S304, the expected total running duration is 1000 milliseconds, and there is 1 primary task, 3 foreground tasks, and 2 background tasks, resulting in a reference running duration of 166 milliseconds for the 6 tasks. The reference running duration of the primary task can be adjusted to 200 milliseconds, and the running durations of the 3 foreground tasks can also be adjusted to 200 milliseconds respectively. The reference running durations of the 2 background tasks can be adjusted to 100 milliseconds respectively. Therefore, for the 6 adjusted tasks, the initial running duration of the primary task can be 200 milliseconds, the initial running duration of the foreground tasks can be 200 milliseconds, and the initial running duration of the background tasks can be 100 milliseconds.
[0078] It should be noted that in the embodiments of this application: The aforementioned S304 and S305 are steps for the terminal to "determine the initial running durations corresponding to the respective tasks". Their technical concepts are different from the technical concepts corresponding to "directly obtaining the original initial running duration corresponding to a task" involved in the foregoing of this application. The aforementioned S304 and S305 are equivalent to the update process of the original initial running duration, and the initial running duration is updated by introducing the task types of the tasks, and the smoothness of the task running can be achieved based on the readjustment of the initial running duration.
[0079] S306. Calculate the product of the initial running duration and the idle duty cycle corresponding to each of the tasks, and use the product as the processor idle duration corresponding to each of the tasks.
[0080] Optionally, by calculating the product of the initial running duration and the idle duty cycle corresponding to each task, the processor idle duration corresponding to each task can be obtained. Generally, the CPU can run a task within the initial running duration corresponding to each task. However, in the embodiments of the present application, the CPU can be in an idle state during the processor idle duration within the initial running duration and does not run the task that should be run. The CPU being in an idle state can be understood as follows: the CPU running a task within the initial running duration corresponding to each task is the work done by the CPU within the initial running duration. In the embodiments of the present application, the CPU works during the processor running duration and rests during the processor idle duration.
[0081] S307. Calculate the difference between the initial running duration and the processor idle duration corresponding to each of the tasks, and use the difference as the processor running duration corresponding to each of the tasks.
[0082] Optionally, the processor running duration can be obtained by subtracting the processor idle duration from the initial running duration. Generally, the CPU can run a task within the initial running duration corresponding to each task. However, in the embodiments of the present application, the CPU can run a task within the processor running duration within the initial running duration. It can be understood that the processor running duration plus the processor idle duration is equal to the initial running duration. During the processor running duration, the CPU can run a task, and during the processor idle duration, the CPU can not run a task and is in an idle state. When within the initial running duration of a certain task, the CPU can first run the task during the processor running duration and then not run the task during the processor idle duration. In short, the CPU can work first and then rest. The working period can be the processor running duration, and the resting period can be the processor idle duration.
[0083] For example: the examples in S305 and S303 can be used. When the current CPU temperature is 47 degrees, for the tasks corresponding to the six applications Taobao, WeChat, QQ, mailbox, weather, and music, the initial running time of the task corresponding to Taobao is 200 milliseconds, and the idle duty cycle is 0, then the corresponding processor running time is 200 milliseconds, and the processor idle time is 0 milliseconds. The tasks corresponding to WeChat, QQ, and mailbox can have an initial running time of 200 milliseconds, and the idle duty cycle is 10%, then the corresponding processor running time is 180 milliseconds, and the processor idle time is 20 milliseconds. The tasks corresponding to weather and music can have an initial running time of 100 milliseconds, and the idle duty cycle is 25%, then the corresponding processor running time is 75 milliseconds, and the processor idle time is 25 milliseconds.
[0084] S308: Obtain the execution order corresponding to each of the tasks.
[0085] Optionally, the tasks to be executed can be arranged in a first-in-first-out queue order, waiting to be executed by the CPU. During the execution of the application, the tasks corresponding to the application are also repeatedly executed by the CPU. Therefore, when the tasks are waiting to be executed by the CPU in order, the execution order corresponding to the tasks can be obtained.
[0086] For example, following the example in S304, the tasks currently run by the CPU may include tasks corresponding to Taobao, tasks corresponding to WeChat, tasks corresponding to QQ, tasks corresponding to email, tasks corresponding to weather, and tasks corresponding to music. At a certain moment, the order of arrangement corresponding to these tasks may be, from first to last, the tasks corresponding to WeChat, the tasks corresponding to Taobao, the tasks corresponding to QQ, the tasks corresponding to email, the tasks corresponding to weather, and the tasks corresponding to music. According to this order of arrangement, when the tasks corresponding to WeChat are run by the CPU, the order of arrangement corresponding to these tasks may be changed to: tasks corresponding to Taobao, tasks corresponding to QQ, tasks corresponding to email, tasks corresponding to weather, tasks corresponding to music, and tasks corresponding to WeChat. According to the new order of arrangement, when the tasks corresponding to Taobao are run by the CPU, the latest order of arrangement of these tasks may be: tasks corresponding to QQ, tasks corresponding to email, tasks corresponding to weather, tasks corresponding to music, tasks corresponding to WeChat, and tasks corresponding to Taobao. It is understandable that after a task is run, the task may continue to queue up on the existing task queue, waiting to be run by the CPU next time.
[0087] S309, reading each of the tasks in sequence according to the execution order, and executing the target task according to the processor execution time and processor idle time corresponding to the currently read target task.
[0088] Optionally, the CPU can read each task in the order of their running sequence. For the currently read target task, it can run the target task within the processor running duration corresponding to the target task. When the processor running duration has elapsed, the CPU can stop running the target task. Further, when entering the processor idle duration corresponding to the target task, the CPU can continue to remain stopped from running the target task and can be in an idle state, which can be understood as the CPU being in a rest state.
[0089] S310, read the next task of the target task, use the next task as the target task, and execute the step of running the target task according to the processor running duration and processor idle duration corresponding to the currently read target task.
[0090] Optionally, when the processor running duration and processor idle duration corresponding to the target task have elapsed, the CPU can read the next task of the target task and use the next task as the current target task. Further, within the processor running duration corresponding to the current target task, it can run the current target task. When entering the processor idle duration corresponding to the current target task, the CPU can be in an idle state and not run the current target task.
[0091] For example: Continuing with the example in S308, the tasks currently being run by the CPU can include the tasks corresponding to Taobao, WeChat, QQ, email, weather, and music. At a certain moment, the arrangement order of these tasks, from first to last, can be in turn: the task corresponding to WeChat, the task corresponding to Taobao, the task corresponding to QQ, the task corresponding to email, the task corresponding to weather, and the task corresponding to music. According to this arrangement order, when the target task is the task corresponding to WeChat, the next task of the target task is the task corresponding to Taobao. After the CPU finishes running the task corresponding to WeChat, the task corresponding to Taobao is used as the target task. The CPU can read the processor running duration and processor idle duration corresponding to the task corresponding to Taobao. Further, the CPU can run the task corresponding to Taobao within this processor running duration and rest during this processor idle duration. And so on, the CPU can read the next task in the queue order and run the next task.
[0092] S311, until all tasks have been run to completion.
[0093] Specifically, each task to be run can be read according to the steps of S310. As long as there are tasks arranged in the task queue, the CPU can keep reading each task to be run and run each task to be run until there are no tasks to be run in the task queue.
[0094] When the solution of the embodiment of the present application is executed, the current working temperature of the terminal is detected. When the working temperature range is within the reference temperature range, the task types corresponding to each task to be run currently are determined, and the target temperature range to which the working temperature belongs is determined. Further, according to the correspondence relationship among the task type, the temperature range, and the idle duty ratio, the idle duty ratio of each task at the target temperature range can be determined. Further, the reference running duration of each task can be calculated according to the estimated total running duration, and the reference running duration of each task can be adjusted according to the task type to which the task belongs to obtain the initial running duration. Therefore, reasonable initial running durations can be set for each task according to different task types, and a good experience can be brought to users while ensuring the performance of the terminal. For example, for the primary task that affects the user experience, a slightly longer running duration can be set; for the background task that has no interaction with the user, a slightly shorter running duration can be set. Further, when the CPU runs each task, it can run the task within the processor running duration and be in the idle state during the processor idle duration, so that when the CPU runs certain tasks, it can be in the idle state. When the CPU temperature rises, the heat generation of the terminal can be alleviated, and it can also be ensured that the terminal will not freeze.
[0095] Please refer to Figure 5 , on the basis of the scenario schematic diagram shown in Figure 1 , a flowchart of a task running method provided by an embodiment of the present application is shown. As Figure 5 shown, the method of the embodiment of the present application may include the following steps:
[0096] S501, detect the current working temperature of the terminal.
[0097] Specifically, reference can be made to Figure 2 S201 in
[0098] S502, determine that the working temperature is within the reference temperature range, determine the task types corresponding to each task among at least one task on the processor, and determine the target temperature range to which the working temperature belongs.
[0099] Specifically, reference can be made to Figure 3 S302 in
[0100] S503, based on the task groups corresponding to each of the task types, perform task grouping processing on each of the tasks to generate at least one task group corresponding to the task type after the grouping processing.
[0101] Among them, when the task type is the primary task, the corresponding task group can be the primary task group; when the task type is the foreground task, the corresponding task group can be the foreground task group; when the task type is the background task, the corresponding task group can be the background task group.
[0102] Optionally, based on the primary task, the foreground task, and the background task, the primary task group, the foreground task group, and the background task group can be determined. The tasks belonging to the primary task type among these tasks can be assigned to the primary task group, the tasks belonging to the foreground task type can be assigned to the foreground task group, and the tasks belonging to the background task type can be assigned to the background task group.
[0103] S504. Based on the corresponding relationship between the task group and the idle duty ratio at different temperature levels, determine the idle duty ratio corresponding to each task group at the target temperature level, and set the idle duty ratio for all tasks in the task group.
[0104] Optionally, the corresponding relationship between the task group, the temperature level, and the idle duty ratio can be preset and stored locally in the terminal. Since three task groups are set in the embodiments of the present application, therefore, the corresponding relationship between the primary task group, the temperature level, and the idle duty ratio can be set, and all tasks of the primary task group can be determined according to this corresponding relationship; the corresponding relationship between the foreground task group, the temperature level, and the idle duty ratio can be set, and all tasks of the foreground task group can be determined according to this corresponding relationship; the corresponding relationship between the background task group, the temperature level, and the idle duty ratio can be set, and all tasks of the background task group can be determined according to this corresponding relationship. Therefore, after determining the target temperature level to which the current working temperature belongs, the corresponding relationship between each task group, the temperature level, and the idle duty ratio can be queried locally according to the task group. Further, the idle duty ratio corresponding to each task group at the target temperature level can be found from the queried corresponding relationship. Further, the corresponding idle duty ratio can be set for the tasks included in each task group.
[0105] For example: Refer to Figure 6 The corresponding relationship between the task group, the temperature level, and the idle duty ratio shown. It can be understood that for the primary task group, which has the greatest impact on the user, a relatively low or even 0 idle duty ratio can be set; for the foreground task group, which also has a certain impact on the user, a relatively low idle duty ratio can still be set when the temperature rises; for the background task group, which has little impact on the user, the idle duty ratio can be continuously increased when the temperature rises.
[0106] S505. Determine the initial running duration corresponding to each task.
[0107] S506. Calculate the processor running duration and the processor idle duration corresponding to each of the tasks based on the initial running duration and the idle duty ratio corresponding to each of the tasks.
[0108] Specifically, for S505 and S506, reference can be made to Figure 2 S202 and S203 in [reference document], which will not be elaborated here.
[0109] S507. Obtain the task processing order corresponding to all the tasks in each of the task groups.
[0110] Among them, the task processing order refers to the arrangement order of tasks in the queue waiting to be run by the CPU, and this queue follows the first-in, first-out order.
[0111] Optionally, when all the tasks in each task group are sorted in the queue, they can be randomly sorted. For example, the task group where Task 1 is located is the primary task group, the task groups where Task 2, Task 3, and Task 4 are located are the foreground task groups, and the task groups where Task 5 and Task 6 are located are the background task groups. The order of Tasks 1 - 6 in the queue can be: Task 1, Task 5, Task 2, Task 3, Task 6, Task 4. The current queue order can then be referred to as the task processing order.
[0112] S508. Determine the target task processing order for each of the tasks based on the task processing order and the task types corresponding to each of the tasks.
[0113] Among them, the target task processing order refers to the task processing order obtained after re - sorting the tasks arranged based on the task types.
[0114] Optionally, the tasks arranged can be re - sorted according to the task types. Specifically, a calculation method can be used to re - sort the tasks. For example, the calculation formula can be: target value = current position + weight value. Among them, the weight value corresponding to the primary task type can be set to 6, the weight value corresponding to the foreground task can be set to 3, and the weight value corresponding to the background task can be set to 1. The current position is the arrangement position of each task in the task processing order. Finally, the tasks are re - sorted in descending order of the target value to obtain a new queue order, and this queue order is the target task processing order. When there are tasks of different task types with the same target value, the tasks of the primary task type are ranked at the front, the tasks of the foreground task type are ranked in the middle, and the tasks of the background task type are ranked at the end.
[0115] For example: Continuing with the example in S507, recalculate tasks 1-6 according to the above calculation formula. The target value for task 1 is 7, the target value for task 2 is 6, the target value for task 3 is 7, the target value for task 4 is 9, the target value for task 5 is 3, and the target value for task 6 is 6. The resulting target task processing order is: task 4, task 1, task 3, task 2, task 6, task 5. From this example, it can be seen that after adjusting the arrangement order, tasks of the primary task type and tasks of the foreground task type are both ranked ahead of tasks of the background task type, which can, to a certain extent, ensure the execution order of tasks of the primary type and tasks of the foreground task type, and delay the execution of tasks of the background task type.
[0116] S509. Run each of the tasks in the target task processing order according to the processor running duration and the processor idle duration corresponding to each of the tasks.
[0117] Optionally, the target task processing order is the adjusted queue order, and this queue order still follows the first-in, first-out rule. When the processor runs these tasks, it can run each task in sequence according to the adjusted queue order. Since the processor running duration and the processor idle duration are set for each task, and the sum of the processor running duration and the processor idle duration is equal to the initial running duration, when the processor runs each task, it can arrange the processor running duration in the first part of the initial running duration and the processor idle duration in the second part of the initial running duration. Then the processor can first run the task during the processor running duration and then be idle during the processor idle duration.
[0118] When the solution of the embodiment of the present application is executed, when it is determined that the working temperature is within the reference temperature range, the task types corresponding to each task in at least one task on the processor are determined, and the target temperature range to which the working temperature belongs is determined. Based on the task groups corresponding to each of the task types, the tasks are grouped, and at least one task group corresponding to the task type after the grouping process is generated. Based on the correspondence between the task group and the idle duty ratio at different temperature ranges, the idle duty ratio corresponding to each of the task groups at the target temperature range is determined, and the idle duty ratio is set for all tasks in the task group. Therefore, the present application groups tasks of the same type in the current queue to obtain different task groups, determines the idle duty ratio corresponding to each task group, and sets the idle duty ratio for each task in the task group. When running each task subsequently, there is no need to determine the task type to which the task belongs, and the set idle duty ratio after grouping can be directly obtained, which can save processor resources. The present application can also obtain the task processing order corresponding to all the tasks in each of the task groups, determine the target task processing order for each of the tasks based on the task processing order and the task types corresponding to each of the tasks, and run each of the tasks in accordance with the target task processing order according to the processor running duration and the processor idle duration corresponding to each of the tasks. Therefore, the present application can adjust the arrangement order of each task in the task queue corresponding to the current processor, can arrange tasks with higher importance to the user in the front of the queue, and arrange tasks with lower importance to the user at the back of the queue, which can ensure the priority execution order of tasks with higher importance to the user, thereby ensuring the user experience. Moreover, when the CPU runs each task, it can run the task within the processor running duration and be in an idle state during the processor idle duration, so that when the CPU runs certain tasks, it can be in an idle state. When the CPU temperature rises, the heat generation of the terminal can be alleviated, and it can also ensure that the terminal does not experience lagging situations.
[0119] Please refer to Figure 7 , which is a schematic structural diagram of a task running device provided by an embodiment of the present application. The task running device 700 can be implemented as all or a part of a terminal through software, hardware, or a combination of both. The device 700 includes:
[0120] A first determination module 710, configured to detect the current working temperature of the terminal and determine the idle duty ratio corresponding to at least one task on the processor at the working temperature;
[0121] A second determination module 720, configured to determine the initial running duration corresponding to each of the tasks;
[0122] A third computing module 730, configured to calculate the processor running duration and the processor idle duration corresponding to each of the tasks based on the initial running duration and the idle duty ratio corresponding to each of the tasks;
[0123] A fourth running module 740, configured to run each of the tasks according to the processor running duration and the processor idle duration corresponding to each of the tasks.
[0124] Optionally, the first determination module 710 includes:
[0125] A temperature judgment unit, configured to judge whether the operating temperature is within a reference temperature range;
[0126] A duty ratio determination unit, configured to determine that the operating temperature is within the reference temperature range, and to determine the idle duty ratio corresponding to at least one task on the processor at the operating temperature.
[0127] Optionally, the duty ratio determination unit includes:
[0128] A first duty ratio calculation subunit, configured to determine the task type corresponding to each of at least one task on the processor, and to determine the target temperature range to which the operating temperature belongs;
[0129] A second duty ratio calculation subunit, configured to determine the idle duty ratio corresponding to each of the tasks at the target temperature range based on the correspondence between the task type and the idle duty ratio at different temperature ranges.
[0130] Optionally, the duty ratio determination unit further includes:
[0131] A third duty ratio calculation subunit, configured to perform task grouping processing on each of the tasks based on the task type corresponding to each of the tasks, and to generate at least one task group corresponding to the task type after the grouping processing;
[0132] A fourth duty ratio calculation subunit, configured to determine the idle duty ratio corresponding to each of the task groups at the target temperature range based on the correspondence between the task group and the idle duty ratio at different temperature ranges, and to set the idle duty ratio for all the tasks in the task group.
[0133] Optionally, the fourth running module 740 includes:
[0134] A fifth running unit, configured to obtain the task processing order corresponding to all the tasks in each of the task groups;
[0135] A sixth running unit, configured to determine the target task processing order for each of the tasks based on the task processing order and the task type corresponding to each of the tasks;
[0136] The seventh operation unit is configured to run each of the tasks according to the processor running duration and the processor idle duration corresponding to each task in the target task processing order.
[0137] Optionally, the second determination module 720 includes:
[0138] The running duration determination unit is configured to allocate an initial running duration corresponding to each task based on the task type corresponding to each task, the total number of currently pending tasks, and the estimated total running duration.
[0139] Optionally, the running duration determination unit includes:
[0140] The first duration calculation subunit is configured to divide the estimated total running duration by the total number of currently pending tasks to obtain an average duration, and use the average duration as a reference running duration;
[0141] The second duration calculation subunit is configured to adjust the reference running duration based on the task type corresponding to each task to obtain the initial running duration corresponding to each task.
[0142] Optionally, the third calculation module 730 includes:
[0143] The first calculation unit is configured to calculate the product of the initial running duration corresponding to each task and the idle duty ratio, and use the product as the processor idle duration corresponding to each task;
[0144] The second calculation unit is configured to calculate the difference between the initial running duration corresponding to each task and the processor idle duration, and use the difference as the processor running duration corresponding to each task.
[0145] Optionally, the fourth operation module 740 includes:
[0146] The first operation unit is configured to obtain the running order corresponding to each task;
[0147] The second operation unit is configured to sequentially read each task according to the running order, and run the target task according to the processor running duration and the processor idle duration corresponding to the currently read target task;
[0148] The third operation unit is configured to read the next task of the target task, use the next task as the target task, and execute the step of running the target task according to the processor running duration and the processor idle duration corresponding to the currently read target task;
[0149] The fourth operation unit is configured to continue until all tasks are run to completion.
[0150] When the solution of the embodiment of the present application is executed, the current working temperature of the terminal is detected, the idle duty ratio corresponding to each task to be run currently at the working temperature is determined, the initial running duration corresponding to each task is determined, and based on the initial running duration and the idle duty ratio corresponding to each task, the processor running duration and the processor idle duration corresponding to each task are calculated, and each task is run in sequence according to the processor running duration and the processor idle duration corresponding to each task. The present application can calculate the processor running duration and the processor idle duration corresponding to each task to be run currently at the current working temperature of the terminal, and can make the processor run the corresponding task during the processor running duration and make the processor in an idle state during the processor idle duration, avoiding the situation in the related art that the processor frequency is restricted to achieve the purpose of cooling due to the increase in the terminal temperature, resulting in the terminal becoming stuck, while the present application can relieve the terminal temperature and ensure that the terminal does not get stuck.
[0151] Please refer to Figure 8 , Figure 8 which is a schematic structural diagram of a terminal provided by an embodiment of the present application. As Figure 8 shown, the terminal 1300 may include: at least one processor 1301, at least one network interface 1304, a user interface 1303, a memory 1305, a display screen assembly 1306, and at least one communication bus 1302.
[0152] Among them, the communication bus 1302 is used to realize the connection and communication between these components.
[0153] Among them, the user interface 1303 may include a display screen (Display), a camera (Camera), and optionally the user interface 1303 may further include a standard wired interface and a wireless interface.
[0154] Among them, the network interface 1304 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
[0155] Among them, the processor 1301 may include one or more processing cores. The processor 1301 connects various parts within the entire terminal 1300 through various interfaces and circuits. By running or executing instructions, programs, code sets, or instruction sets stored in the memory 1305, and by calling the data stored in the memory 1305, it performs various functions of the terminal 1300 and processes data. Optionally, the processor 1301 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 1301 may integrate one or a combination of several of a central processing unit (CPU), a graphics processing unit (GPU), and a modem, etc. Among them, the CPU mainly processes the operating system, user interface, application programs, etc.; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 1301 and may be implemented separately by a single chip.
[0156] Among them, the memory 1305 may include random access memory (RAM) and may also include read-only memory. Optionally, the memory 1305 includes a non-transitory computer-readable storage medium. The memory 1305 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 1305 may include a program storage area and a data storage area. Among them, the program storage area may store instructions for implementing the operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store the data involved in the above-mentioned various method embodiments. Optionally, the memory 1305 may also be at least one storage device located far from the aforementioned processor 1301. As Figure 8 shown, the memory 1305, as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a task running program.
[0157] In Figure 8In the terminal 1300 shown, the user interface 1303 is mainly used to provide an interface for the user to input data and obtain the data input by the user; while the processor 1301 can be used to call the task running program stored in the memory 1305 and specifically perform the following operations:
[0158] Detect the current working temperature of the terminal and determine the idle duty cycle corresponding to at least one task on the processor at the working temperature;
[0159] Determine the initial running duration corresponding to each of the tasks;
[0160] Based on the initial running duration and the idle duty cycle corresponding to each of the tasks, calculate the processor running duration and the processor idle duration corresponding to each of the tasks;
[0161] Run each of the tasks according to the processor running duration and the processor idle duration corresponding to each of the tasks.
[0162] In one embodiment, when the processor 1301 executes the step of determining the idle duty cycle corresponding to at least one task on the processor at the working temperature, it specifically executes the following steps:
[0163] Judge whether the working temperature is within the reference temperature range;
[0164] Determine that the working temperature is within the reference temperature range and determine the idle duty cycle corresponding to at least one task on the processor at the working temperature.
[0165] In one embodiment, when the processor 1301 executes the step of determining the idle duty cycle corresponding to at least one task on the processor at the working temperature, it specifically executes the following steps:
[0166] Determine the task type corresponding to each task among at least one task on the processor and determine the target temperature range to which the working temperature belongs;
[0167] Based on the correspondence between the task type and the idle duty cycle at different temperature ranges, determine the idle duty cycle corresponding to each of the tasks at the target temperature range.
[0168] In one embodiment, after the processor 1301 executes the step of determining the task type corresponding to each task among at least one task on the processor, it further executes the following steps:
[0169] Based on the task type corresponding to each of the tasks, perform task grouping processing on each of the tasks to generate at least one task group corresponding to the task type after grouping processing;
[0170] Determining the idle duty cycle corresponding to each of the tasks at the target temperature level based on the corresponding relationship between the task type and the idle duty cycle at different temperature levels includes:
[0171] Based on the corresponding relationship between the task group and the idle duty cycle at different temperature levels, determining the idle duty cycle corresponding to each of the task groups at the target temperature level, and setting the idle duty cycle for all the tasks in the task group.
[0172] In one embodiment, when the processor 1301 executes the step of running each of the tasks according to the processor running duration and the processor idle duration corresponding to each of the tasks, the following steps are specifically executed:
[0173] Obtaining the task processing order corresponding to all the tasks in each of the task groups;
[0174] Based on the task processing order and the task type corresponding to each of the tasks, determining the target task processing order for each of the tasks;
[0175] Running each of the tasks according to the processor running duration and the processor idle duration corresponding to each of the tasks by adopting the target task processing order.
[0176] In one embodiment, when the processor 1301 executes the step of determining the initial running duration corresponding to each of the tasks, the following steps are specifically executed:
[0177] Allocating the initial running duration corresponding to each of the tasks based on the task type corresponding to each of the tasks, the total number of currently pending tasks, and the expected total running duration.
[0178] In one embodiment, when the processor 1301 executes the step of allocating the initial running duration corresponding to each of the tasks based on the task type corresponding to each of the tasks, the total number of currently pending tasks, and the expected total running duration, the following steps are specifically executed:
[0179] Dividing the expected total running duration by the total number of currently pending tasks to obtain an average duration, and using the average duration as a reference running duration;
[0180] Adjusting the reference running duration based on the task type corresponding to each of the tasks to obtain the initial running duration corresponding to each of the tasks.
[0181] In one embodiment, when the processor 1301 executes the step of calculating the processor running duration and the processor idle duration corresponding to each of the tasks based on the initial running duration and the idle duty cycle corresponding to each of the tasks, the following steps are specifically executed:
[0182] Calculate the product of the initial running duration and the idle duty cycle corresponding to each of the tasks, and use the product as the processor idle duration corresponding to each of the tasks;
[0183] Calculate the difference between the initial running duration and the processor idle duration corresponding to each of the tasks, and use the difference as the processor running duration corresponding to each of the tasks.
[0184] In one embodiment, when the processor 1301 executes the step of running each of the tasks in sequence according to the processor running duration and the processor idle duration corresponding to each of the tasks, the following steps are specifically executed:
[0185] Obtain the running order corresponding to each of the tasks;
[0186] Read each of the tasks in sequence according to the running order, and run the target task according to the processor running duration and the processor idle duration corresponding to the currently read target task;
[0187] Read the next task of the target task, use the next task as the target task, and execute the step of running the target task according to the processor running duration and the processor idle duration corresponding to the currently read target task;
[0188] Until all tasks are run to completion.
[0189] In addition, those skilled in the art can understand that the structure of the terminal 1300 shown in the above drawings does not constitute a limitation on the terminal 1300. The user terminal may include more or fewer components than shown in the drawings, or combine certain components, or have different component arrangements. For example, the terminal 1300 also includes components such as a radio frequency circuit, an audio circuit, a WiFi component, a power supply, and a Bluetooth component, which will not be elaborated here.
[0190] The embodiment of the present application also provides a computer-readable storage medium, and the computer storage medium stores at least one instruction, and the at least one instruction is used to be executed by a processor to implement the task running method as described in the above various embodiments.
[0191] The embodiment of the present application also provides a computer program product, and the computer program product stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the task running method as described in the above various embodiments.
[0192] Those skilled in the art should be able to realize that in one or more of the above examples, the functions described in the embodiments of the present application can be implemented by hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. The computer-readable medium includes computer storage media and communication media, where the communication media includes any medium that facilitates the transmission of a computer program from one place to another. The storage media can be any available medium accessible by a general-purpose or special-purpose computer. The above are only alternative embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included within the protection scope of the present application.
Claims
1. A task running method, characterized in that, The method includes: Detecting the current working temperature of the terminal, and determining the idle duty cycle corresponding to at least one task on the processor at the working temperature, where the idle duty cycle includes the percentage of the processor idle duration when the processor is in the idle state to the processor running duration when the processor actually runs the task; Determining the initial running duration corresponding to each of the tasks; Calculating the processor running duration and the processor idle duration corresponding to each of the tasks based on the initial running duration and the idle duty cycle corresponding to each of the tasks; Running each of the tasks according to the processor running duration and the processor idle duration corresponding to each of the tasks; Wherein, the determining the idle duty cycle corresponding to at least one task on the processor at the working temperature includes: judging whether the working temperature is within the reference temperature range, determining that the working temperature is within the reference temperature range, and determining the idle duty cycle corresponding to at least one task on the processor at the working temperature; The determining the idle duty cycle corresponding to at least one task on the processor at the working temperature includes: determining the task type corresponding to each task among at least one task on the processor, and determining the target temperature range to which the working temperature belongs, and determining the idle duty cycle corresponding to each of the tasks at the target temperature range based on the corresponding relationship between the task type and the idle duty cycle at different temperature ranges; 2. The method according to claim 1, characterized in that, The determining the task type corresponding to each task among at least one task on the processor includes: Determining the task type corresponding to each task among at least one task on the processor; Performing task grouping processing on each of the tasks based on the task type corresponding to each of the tasks, and generating at least one task group corresponding to the task type after the grouping processing; The determining the idle duty cycle corresponding to each of the tasks at the target temperature range based on the corresponding relationship between the task type and the idle duty cycle at different temperature ranges includes: Determining the idle duty cycle corresponding to each of the task groups at the target temperature range based on the corresponding relationship between the task group and the idle duty cycle at different temperature ranges, and setting the idle duty cycle for all the tasks in the task group; 3. The method according to claim 2, characterized in that, The running each of the tasks according to the processor running duration and the processor idle duration corresponding to each of the tasks includes: Obtaining the task processing order corresponding to all the tasks in each of the task groups; Determining the target task processing order for each of the tasks based on the task processing order and the task type corresponding to each of the tasks; Running each of the tasks according to the processor running duration and the processor idle duration corresponding to each of the tasks in the target task processing order; 4. The method according to claim 1, characterized in that, The determining the initial running duration corresponding to each of the tasks includes: Allocating the initial running duration corresponding to each of the tasks based on the task type corresponding to each of the tasks, the total number of currently pending tasks, and the expected total running duration; 5. The method according to claim 4, characterized in that, The allocating the initial running duration corresponding to each of the tasks based on the task type corresponding to each of the tasks, the total number of currently pending tasks, and the expected total running duration includes: Divide the expected total running duration by the total number of tasks to be run currently to obtain the average duration, and use the average duration as the reference running duration; Based on the task types corresponding to the tasks, adjust the reference running duration to obtain the initial running durations corresponding to the tasks.
6. The method according to claim 1, characterized in that, The calculating the processor running duration and the processor idle duration corresponding to each task based on the initial running duration and the idle duty ratio corresponding to each task includes: Calculate the product of the initial running duration and the idle duty ratio corresponding to each task, and use the product as the processor idle duration corresponding to each task; Calculate the difference between the initial running duration and the processor idle duration corresponding to each task, and use the difference as the processor running duration corresponding to each task.
7. The method according to claim 1, characterized in that, The running each task according to the processor running duration and the processor idle duration corresponding to each task includes: Obtain the running order corresponding to each task; Read each task in sequence according to the running order, and run the target task according to the processor running duration and the processor idle duration corresponding to the currently read target task; Read the next task of the target task, use the next task as the target task, and execute the step of running the target task according to the processor running duration and the processor idle duration corresponding to the currently read target task; Until all tasks are run to completion.
8. A task running device, characterized in that, The device includes: A first determination module, configured to detect the current working temperature of the terminal and determine the idle duty ratio corresponding to at least one task on the processor at the working temperature, where the idle duty ratio includes the percentage of the processor idle duration when the processor is in the idle state to the processor running duration when the processor actually runs tasks; A second determination module, configured to determine the initial running durations corresponding to the tasks; A third calculation module, configured to calculate the processor running duration and the processor idle duration corresponding to each task based on the initial running duration and the idle duty ratio corresponding to each task; A fourth running module, configured to run each task according to the processor running duration and the processor idle duration corresponding to each task; Wherein, the first determination module is specifically configured to: determine whether the working temperature is within the reference temperature range, determine that the working temperature is within the reference temperature range, and determine the idle duty ratio corresponding to at least one task on the processor at the working temperature; The determining the idle duty ratio corresponding to at least one task on the processor at the working temperature includes: determining the task types corresponding to each task among at least one task on the processor, determining the target temperature range to which the working temperature belongs, and determining the idle duty ratio corresponding to each task at the target temperature range based on the corresponding relationship between the task type and the idle duty ratio at different temperature ranges.
9. A computer storage medium, characterized in that, The computer storage medium stores multiple instructions, and the instructions are suitable for being loaded and executed by a processor to perform the method steps of any one of claims 1 to 7.
10. A terminal, characterized in that, Including: A processor and a memory; wherein, the memory stores a computer program, and the computer program is adapted to be loaded and executed by the processor to perform the method steps of any one of claims 1 to 7.
Citation Information
Patent Citations
Terminal temperature dynamic control method and system, terminal, and storage medium
CN109451155A
Control method of UHF handheld terminal and storage medium
CN111860010A