CN112817428A - Task running method and device, mobile terminal and storage medium - Google Patents
Task running method and device, mobile terminal and storage medium Download PDFInfo
- Publication number
- CN112817428A CN112817428A CN202110097611.2A CN202110097611A CN112817428A CN 112817428 A CN112817428 A CN 112817428A CN 202110097611 A CN202110097611 A CN 202110097611A CN 112817428 A CN112817428 A CN 112817428A
- Authority
- CN
- China
- Prior art keywords
- task
- cores
- core
- executed
- cpu
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/26—Power supply means, e.g. regulation thereof
- G06F1/32—Means for saving power
- G06F1/3203—Power management, i.e. event-based initiation of a power-saving mode
- G06F1/3234—Power saving characterised by the action undertaken
- G06F1/3293—Power saving characterised by the action undertaken by switching to a less power-consuming processor, e.g. sub-CPU
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Power Sources (AREA)
Abstract
The invention relates to the technical field of computers, and provides a task running method, a task running device, a mobile terminal and a storage medium. When the CPU has cores with different computing capacities, dividing all the cores into cores with N computing grades according to the computing capacities; when the task to be executed exists, in the cores of the N operation levels, a target core matched with the priority of the task to be executed is determined, the priority of the task to be executed represents the computing capacity requirement of the task to be executed, and the task to be executed and the target core are bound to realize the running of the task. The computing power requirement of the task is matched with the computing power of the CPU core, the CPU resource is reasonably utilized, and the effects of saving the electric energy consumption of the mobile terminal and improving the cruising ability are achieved.
Description
Technical Field
The invention relates to the technical field of computers, in particular to a task running method, a task running device, a mobile terminal and a storage medium.
Background
With the development of science and technology, mobile terminals are gradually popularized in the lives of people. Many mobile terminals use a Central Processing Unit (CPU) having a plurality of cores to support the operation of a plurality of tasks in an application program, thereby increasing the processing speed.
In the process of supporting task operation, the CPU may use unreasonable resources, which results in a large amount of power being consumed, the mobile terminal usually uses a battery to provide power, and the power that can be provided by the battery is limited, which results in low cruising ability of the mobile terminal.
Disclosure of Invention
In view of the above, the present invention is directed to a task running method, a task running device, a mobile terminal and a storage medium.
In order to achieve the above purpose, the embodiment of the present invention adopts the following technical solutions:
in a first aspect, the present invention provides a task running method, applied to a mobile terminal, where the mobile terminal includes a CPU, and the method includes:
when the CPU has cores with different computing capacities, dividing all the cores into cores with N operation levels according to the computing capacity;
when the task to be executed exists, determining a target core matched with the priority of the task to be executed in the cores of the N operation levels; wherein the priority of the task to be executed characterizes the computing power requirement of the task to be executed; the target core belongs to at least one of the total cores;
and binding the task to be executed to the target core for operation.
In an optional embodiment, when the CPU has cores with different computing capabilities, the step of dividing all cores into cores of N operation levels according to different computing capabilities includes:
acquiring the maximum working frequency of each core in the CPU;
when the maximum working frequency of at least two cores meets the duplicate removal condition, determining the cores with different computing capacities of the CPU; the de-emphasis condition represents that the maximum working frequencies of any two cores are not coincident;
and dividing all cores into cores of N operation levels according to the maximum working frequency of each core.
In an optional embodiment, when the CPU has cores with different computing capabilities, the step of dividing all cores into cores of N operation levels according to different computing capabilities includes:
determining whether the CPU has cores with different computing capabilities according to the type information of the CPU;
if yes, dividing all cores into cores with N operation levels according to different computing capabilities.
In an optional embodiment, the step of determining whether the CPUs have cores with different computing capabilities according to the type information of the CPUs includes:
acquiring a core type corresponding to the type information of the CPU in a pre-stored information table; the core type characterizes the computing power of the core;
when there are at least two core types, it is determined that the CPU has cores with different computing capabilities.
In an optional embodiment, the step of determining, among the cores at the N operation levels, a target core that matches the priority of the task to be executed when there is the task to be executed includes:
when the task to be executed is an interactive task, determining the core with the highest operation level as a target core matched with the priority of the interactive task in the cores with the N operation levels;
when the task to be executed is a low-frequency task, determining a core with the lowest operation level as a target core matched with the priority of the low-frequency task from the cores with the N operation levels; the low-frequency task represents the task with the shortest historical running time in preset time;
when the task to be executed is a low-demand task, determining a core with the lowest operation level as a target core matched with the priority of the low-demand task from the cores with the N operation levels; the low-demand task represents a task with the lowest computing power demand in the currently executed tasks.
In a second aspect, the present invention provides a device for task running, which is applied to a mobile terminal, where the mobile terminal includes a CPU, and the device includes:
the classification module is used for dividing all cores into cores with N operation levels according to the computing power when the CPU has cores with different computing powers;
the determining module is used for determining a target core matched with the priority of the task to be executed in the cores of the N operation levels when the task to be executed exists; wherein the priority of the task to be executed characterizes the computing power requirement of the task to be executed; the target core belongs to at least one of the total cores;
and the binding module is used for binding the task to be executed to the target core for operation.
In an alternative embodiment, the ranking module is further configured to:
acquiring the maximum working frequency of each core in the CPU;
when the maximum working frequency of at least two cores meets the duplicate removal condition, determining the cores with different computing capacities of the CPU; the de-emphasis condition represents that the maximum working frequencies of any two cores are not coincident;
and dividing all cores into cores of N operation levels according to the maximum working frequency of each core.
In an alternative embodiment, the determining module is further configured to:
when the task to be executed is an interactive task, determining the core with the highest operation level as a target core matched with the priority of the interactive task in the cores with the N operation levels;
when the task to be executed is a low-frequency task, determining a core with the lowest operation level as a target core matched with the priority of the low-frequency task from the cores with the N operation levels; the low-frequency task represents the task with the shortest historical running time in preset time;
when the task to be executed is a low-demand task, determining a core with the lowest operation level as a target core matched with the priority of the low-demand task from the cores with the N operation levels; the low-demand task represents a task with the lowest computing power demand in the currently executed tasks.
In a third aspect, the present invention provides a mobile terminal, comprising a processor and a memory, wherein the memory stores a computer program, and the processor implements the method according to any one of the foregoing embodiments when executing the computer program.
In a fourth aspect, the present invention provides a storage medium having stored thereon a computer program which, when executed by a processor, implements the method of any one of the preceding embodiments.
The embodiment of the invention provides a task running method, a task running device, a mobile terminal and a storage medium. When the CPU has cores with different computing capacities, dividing all the cores into cores with N computing grades according to the computing capacities; when the task to be executed exists, in the cores of the N operation levels, a target core matched with the priority of the task to be executed is determined, the priority of the task to be executed represents the computing capacity requirement of the task to be executed, and the task to be executed and the target core are bound to realize the running of the task. The computing power requirement of the task is matched with the computing power of the CPU core, the CPU resource is reasonably utilized, and the effects of saving the electric energy consumption of the mobile terminal and improving the cruising ability are achieved.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a block diagram of a mobile terminal according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating an example of a task execution method provided by an embodiment of the invention;
FIG. 3 is a flowchart illustrating a task execution method according to an embodiment of the present invention;
FIG. 4 is a schematic flow chart illustrating a task execution method according to an embodiment of the present invention;
FIG. 5 is a schematic flow chart illustrating a task execution method according to an embodiment of the present invention;
FIG. 6 is a schematic flow chart illustrating a task execution method according to an embodiment of the present invention;
fig. 7 is a functional block diagram of a task execution device according to an embodiment of the present invention.
Icon: 100-a mobile terminal; 110-a bus; 120-a processor; 130-a memory; 150-I/O module; 170 — a communication interface; 300-a task execution device; 310-a grading module; 330-a determination module; 350-binding module.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
It is noted that relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The mobile terminal provided by the embodiment of the invention can be a smart phone, a personal computer, a tablet computer, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, a Personal Digital Assistant (PDA), and the like. The embodiments of the present invention do not limit this.
Fig. 1 is a block diagram of a mobile terminal 100 according to an embodiment of the present invention. Mobile terminal 100 includes bus 110, processor 120, memory 130, I/O module 150, and communication interface 170. It will be understood by those of ordinary skill in the art that the structure shown in fig. 1 is only an illustration and is not intended to limit the structure of the mobile terminal 100. For example, mobile terminal 100 may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
The processor 120 may receive commands from the above-described other elements (e.g., the memory 130, the I/O module 150, the communication interface 170, etc.) through the bus 110, may interpret the received commands, and may perform calculations or data processing according to the interpreted commands.
The processor 120 may be an integrated circuit chip having signal processing capabilities. The Processor 120 may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components.
The memory 130 may store commands or data received from the processor 120 or other elements (e.g., the I/O module 150, the communication interface 170, etc.) or commands or data generated by the processor 120 or other elements.
The Memory 130 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Read Only Memory (EPROM), an electrically Erasable Read Only Memory (EEPROM), and the like.
The I/O module 150 may receive commands or data input from a user via input-output means (e.g., a sensor, a keyboard, a touch screen, etc.) and may transmit the received commands or data to the processor 120 or the memory 130 through the bus 110. And also for displaying various information (e.g., multimedia data, text data) received, stored, processed from the above-described elements, and may display video, images, data, etc. to a user.
The processor of the mobile terminal provided by the embodiment of the invention is a CPU with a plurality of cores. The core of the CPU is a chip made of single crystal silicon, and is used for processing and calculating data, receiving and storing commands, and the like. The multi-core CPU has two or more cores in one processor, and the CPU has a plurality of cores, so that the computing power is improved, the processing speed is high, and the CPU is widely used nowadays.
According to practical applications, a plurality of cores in the CPU are not necessarily the same, and in order to meet the operation requirements of the mobile terminal under various conditions, the cores may be designed to have different computing capabilities. Referring now to fig. 2, three examples of such a CPU are given in fig. 2.
Fig. 2 (a) is a schematic diagram of a CPU of the smartphone a, which has four cores in total, and has two cores with different computing capabilities. Wherein core A1 and core A2 are cores of a first computing power and core A3 and core A4 are cores of a second computing power.
Fig. 2 (B) is a schematic diagram of the CPU of the smartphone B, which has six cores, and has three cores with different computing capabilities. Wherein core B1 and core B2 are cores of a first computing power, core B3 and core B4 are cores of a second computing power, and core B5 and core B6 are cores of a third computing power.
Fig. 2 (C) is a schematic diagram of the CPU of the smartphone C, which has six cores, and has two cores with different computing capabilities. Wherein core C1, core C2, and core C3 are cores of a first computing power, and core C4, core C5, and core C6 are cores of a second computing power.
In this embodiment, the smartphone with the multi-core CPU is used as an execution main body to execute each step in each method provided by the embodiment of the present invention, and achieve a corresponding technical effect. Referring to fig. 3, a flowchart of a task execution method according to an embodiment of the present invention is shown. The specific flow shown in fig. 3 will be described in detail below.
Step S202, when the CPU has cores with different computing power, dividing all the cores into cores with N computing levels according to the computing power;
it should be noted that, according to the design requirement of the smart phone, the CPU of the smart phone may be a different core or the same core. The performance of a core is related to its computational power and power consumption, the stronger the computational power, the better the performance and, correspondingly, the faster the power consumption.
Optionally, whether the cores have different computing capabilities or not may be obtained according to the performance parameters of the cores or according to the types of the CPUs, and then the cores are divided into a plurality of operation levels, it is understood that the value of N is greater than or equal to 2.
Step S204, when the task to be executed exists, determining a target core matched with the priority of the task to be executed in the cores of the N operation levels;
it should be noted that the application installed in the smartphone includes multiple tasks, and the tasks may be prioritized according to the implemented function, or the running time and the running state.
Wherein the priority of the task to be executed represents the computing power requirement of the task to be executed; this priority may be preset or determined at the start-up and run-time of the task.
Optionally, when there is a task to be executed, the priority of the task to be executed is obtained, and a core matched with the task to be executed can be obtained according to the priority and cores of multiple operation levels, which is a target core, where the target core may be one or multiple.
Step S206, binding the task to be executed to a target core for operation;
optionally, the running of the task needs to be supported by a core of the CPU, and after the task to be executed and the target core are determined, the task to be executed and the target core are bound to support the running of the task to be executed.
Through the steps, when the CPU has cores with different computing capacities, all the cores are divided into cores with N computing grades according to the computing capacities; when the task to be executed exists, in the cores of the N operation levels, a target core matched with the priority of the task to be executed is determined, the priority of the task to be executed represents the computing capacity requirement of the task to be executed, and the task to be executed and the target core are bound to realize the running of the task. Therefore, the computing power requirement of the task is matched with the computing power of the CPU core, the CPU resource is reasonably utilized, and the effects of saving the electric energy consumption of the mobile terminal and improving the cruising ability are achieved.
In practical application, different mobile terminals and systems supporting application program operation are not necessarily the same, and the systems of the mobile terminals are an Android system and an iOS system generally. The implementation of these two different systems will be described separately below.
Referring to fig. 4, when the system of the smart phone is the first system, i.e., the Android system, a possible implementation manner is provided for the step S202, and the step S202 includes the following steps:
step S202A-1, acquiring the maximum working frequency of each core in the CPU;
optionally, the core comb amount of the CPU may be read first by calling a function, and then the maximum operating frequency of each core may be obtained by reading a file in the smart phone.
Step S202A-3, when the maximum working frequency of at least two cores meets the rearrangement condition, determining that the CPU has cores with different computing power;
it is to be noted that the maximum operating frequency of the core represents the processing speed of the core. The greater the maximum operating frequency, the faster the processing speed, i.e. the greater the computing power.
The duplicate removal condition represents that the maximum working frequencies of any two cores are not coincident, and it can be understood that the difference between the two maximum working frequencies is large.
Alternatively, the average power of the maximum operating frequencies of all cores may be calculated, and when there is a core whose maximum operating frequency is not equal to the average power, it is determined that the CPU has cores with different computing capabilities.
Step S202A-5, dividing all cores into cores of N operation levels according to the maximum working frequency of each core;
optionally, the maximum operating frequency of all cores may be re-ordered to obtain a re-ordering parameter, and the number of cores into which all cores are divided is determined according to the value of N obtained by the re-ordering parameter.
The following describes the above steps S202A-1 to S202A-5, taking the smartphone a of the Android system as an example.
The smart phone a is installed with an application program, and a function "sysconf (SC _ nprocesors _ CONF)" is called in a development tool of the application program to obtain that the number of cores of the CPU of the smart phone is 4, and the CPU of the smart phone has 4 cores, namely, a core a1, a core a2, a core A3 and a core a 4.
Reading files/systems/devices/system/cpu/cpu [ X ]/cpu freq/cpu info _ max _ freq, respectively substituting 0 to 4 into [ X ], obtaining that the maximum working frequency of the core A1 and the core A2 is 1.8GHz, the maximum working frequency of the core A3 and the core A4 is 1.4GHz, calculating the average power of all cores to be 1.6GHz, meeting the weight-removing condition, and calculating the weight-removing parameter to be 2;
all cores may be divided into 2 levels of cores, i.e., N is 2, core a1 and core a2, whose maximum operating frequencies are greater than the average power, are cores whose operation levels are one level, and core A3 and core a4, whose maximum operating frequencies are less than the average power, are cores whose operation levels are two levels, one level being the highest level and two levels being the lowest level, as shown in table 1.
TABLE 1
| Core(s) | Maximum operating frequency (/ GHz) | Operation level |
| A1 | 1.8 | First stage |
| A2 | 1.8 | First stage |
| A3 | 1.4 | Second stage |
| A4 | 1.4 | Second stage |
Optionally, the steps are performed on the smartphone B with the Android system, and the smartphone B has 6 cores, namely, core B1, core B2, core B3, core B4, core B5 and core B6; obtaining that the maximum working frequency of the cores B1-B2 is 2.6GHz, the maximum working frequency of the cores B3-B4 is 2.2GHz, the maximum working frequency of the cores B5-B6 is 1.8GHz, calculating the average power of all the cores to be 2.2GHz, meeting the weight removal condition, and calculating the weight removal parameter to be 3; all cores may be divided into 3 operation levels, i.e., N is 3, cores B1 and B2 are cores having an operation level of one level, cores B3 and B4 are cores having an operation level of two levels, cores B5 and B6 are cores having an operation level of three levels, one level is the highest level, and three levels are the lowest levels, as shown in table 2.
TABLE 2
Through the steps, for the mobile terminal of the Android system, the maximum working frequency of each core can be obtained, when the maximum working frequencies of at least two cores meet the duplication elimination condition, namely the maximum working frequencies of any two cores are not coincident, all the cores can be divided into the cores of N operation levels, the cores in the CPU can be reasonably divided according to the calculation capacity, the cores are matched with the Android system, the intrusion to the original system is small, and the stable operation of the mobile terminal is facilitated.
In practical applications, the system of the smartphone may also be a second system, i.e., an iOS system, and it may be determined whether the CPU has a core with different computing capabilities according to the type information of the CPU. Furthermore, the embodiment of the present invention provides a possible implementation manner for the step S202, and please refer to fig. 5, wherein the step S202 will be described in detail below.
Step S202B-1, obtaining a core type corresponding to the type information of the CPU from a pre-stored information table;
the pre-stored information table is pre-stored in an application program development tool. The pre-stored information table comprises the type information of the CPU and the corresponding core type.
Optionally, the core type may be obtained by obtaining the type information of the CPU and pre-storing the information table.
Step S202B-3, when at least two core types exist, determining that the CPU has cores with different computing power;
wherein the core type characterizes the computational power of the core;
alternatively, if the core types are plural, that is, not less than two, the CPU has cores with different computing capabilities.
Step S202B-5, dividing all cores into N operation levels according to different computing capacities;
alternatively, the value of N may be determined according to the number of types of cores, and all cores may be divided into cores of N operation levels.
The above-described step S202B-1 to step S202B-5 will be explained below by taking the smartphone C of the iOS system as an example.
As shown in table 3, a part of the content of a pre-stored information table provided in the embodiment of the present invention is shown.
TABLE 3
| ID | Code_name | Cpu_count | Big | Little |
| 0x67ceee93 | HURRICANE | 4 | 2 | 2 |
| 0x67ceee93 | HURRICANE | 6 | 3 | 3 |
| 0xe81e7ef6 | MONSOON_MISTRAL | 6 | 2 | 4 |
| 0x07d34b9f | VORTEX_TEMPEST | 6 | 2 | 4 |
| 0x07d34b9f | VORTEX_TEMPEST | 8 | 4 | 4 |
| 0x462504d2 | LIGHTNING_THUNDER | 6 | 2 | 4 |
| 0x462504d2 | LIGHTNING_THUNDER | 8 | 4 | 4 |
| 0x1b588bb3 | FIRESTORM_ICESTORM | 6 | 2 | 4 |
| 0x1b588bb3 | FIRESTORM_ICESTORM | 8 | 4 | 4 |
An application program is installed in the smart phone C, and a function ' syscllbyname ' (hw. cpufamily ', & value, & len, NULL,0) is called in a development tool of the application program; ", the ID of the CPU is 0x67ceee93, and the type information of the CPU is HURRICANE; by calling the function "syscllbyname (" hw. ncpu ", & count, & len, NULL, 0); ", the core number of the CPU is 6;
through the pre-stored information table, two types of cores are inquired, namely a Big type and a Little type, N is 2, all the cores can be divided into 2 operation-level cores, the core corresponding to the Big type is the core with the first operation level, the core corresponding to the Little type is the core with the second operation level, the first operation level is the highest operation level, and the second operation level is the lowest operation level. I.e. as shown in table 4.
TABLE 4
| Core(s) | Type of core | Operation level |
| C1 | Big | First stage |
| C2 | Big | First stage |
| C3 | Big | First stage |
| C4 | Little | Second stage |
| C5 | Little | Second stage |
| C6 | Little | Second stage |
Through the steps, the core type can be determined according to the type information of the CPU aiming at the mobile terminal of the iOS system, when at least two core types exist, the CPU has cores with different computing capabilities, all the cores can be divided into cores with N computing levels, the cores in the CPU are reasonably divided according to the computing capabilities, the cores are matched with the iOS system, the invasion to the original system is small, and the stable operation of the mobile terminal is facilitated.
In practical application, the number of tasks of an application program is multiple, the number of cores of a CPU is multiple, the embodiment of the invention prioritizes the tasks, and calculates the grades of the cores, and provides an implementation mode for determining the cores matched with the tasks according to the priorities of the tasks. Referring to fig. 6, the step S204 will be described.
Step S204-1, when the task to be executed is an interactive task, determining the core with the highest operation level as a target core matched with the priority of the interactive task in the cores with the N operation levels;
the interaction task is a task related to user interaction, and can also be understood as a UI thread, which is a thread supporting an application program to interact with a user, and the priority of the task is high.
Optionally, when the task to be executed is an interactive task, a core with the highest operation level is matched with the task.
Step S204-3, when the task to be executed is a low-frequency task, determining the core with the lowest operation level as a target core matched with the priority of the low-frequency task from the cores with the N operation levels;
the low-frequency task represents the task with the shortest historical running time in the preset time, and the priority of the task is low.
Alternatively, the predetermined time may be a second, a minute, a day, and the like, and the embodiment of the present invention is not limited. For example, 1 day, the historical time of running of the task in 1 day is obtained, and when the task to be executed is the task with the shortest historical time, the operation level matched with the task is the core with the lowest level.
Alternatively, it is also possible to determine whether the task to be performed is a low frequency task by using the frequency.
Step S204-5, when the task to be executed is a low-demand task, determining the core with the lowest operation level as a target core matched with the priority of the low-demand task from the cores with the N operation levels;
alternatively, the tasks may be prioritized in advance according to their computing power requirements. The low-demand task represents the task with the lowest computing power demand in the currently executed tasks. The priority of such tasks is low.
Optionally, when the task to be executed is a task with low computational power requirement, the operation level matched with the task is the lowest-level core.
It is understood that during the running process of the task, the running state of the task may be changed, such as from the foreground running to the background running, in which case, the core matched with the task is the core with the lowest operation level.
The method for running the task will be described below by taking the smartphone B as an example.
The smart phone B is provided with an application program, and the application program comprises three tasks: update detection, data statistics and music playing. According to the computing power requirement, the priority of updating detection can be set to be low in advance, the priority of data statistics is set to be medium, and the priority of music playing is set to be high.
When the task to be executed is music playback, the cores that are determined to match the priority of the update detection are the core B1 and the core B2 whose operation levels are one level, that is, the highest level, and the music playback may be bound to either one of the core B1 and the core B2, or both.
When the task to be executed is data statistics, the cores determined to be matched with the priority of the data statistics are the core B3 and the core B4 with the operation level of two, and the data statistics may be bound to either one of the core B3 and the core B4 or both of them.
When the task to be executed is the update detection, the cores determined to match the priority of the update detection are the core B5 and the core B6 having the operation levels of three levels, that is, the lowest level, and the update detection may be bound to any one of the core B5 and the core B6.
After the task runs for a period of time, if an incoming call exists, the application program is switched to the background running, the states of music playing, data statistics and updating detection are changed, and the three tasks are bound with the core B5 and the core B6 with the three operation levels.
The method for running the task will be described below by taking the smartphone C as an example.
The smart phone C is provided with an application program, and the application program comprises an interactive task and a non-interactive task. The priority of the interactive task can be preset to be the highest, and the interactive task is bound with one or two or three of the core C1, the core C2 and the core C3 with the operation level of one level in operation.
When the task to be executed is a non-interactive task such as a data reporting task, the historical running time of the task within a preset time period such as 1 day can be acquired. If the historical run length is longest among all non-interactive tasks, the priority of the task is high and is bound to one, or two or three, of the core C1, the core C2 and the core C3.
If the historical run time is the shortest of all the non-interactive tasks, the priority of the task is low and is bound to one of the core C4, the core C5 and the core C6.
If the historical operating time is not the longest or the shortest among all the non-interactive tasks, the core can be bound according to the computing power requirement of data statistics.
It can be understood that, in the running process of the task, the running time length changes, the priority of the task changes, the core matched with the task changes, and the core matched with the priority of the task can be redetermined according to the preset time and bound with the core.
In order to execute the corresponding steps in the above embodiments and various possible manners, an implementation manner of the task running device is provided below, please refer to fig. 7, and fig. 7 is a functional block diagram of the task running device 300 provided in the present application. It should be noted that the basic principle and the generated technical effect of the task operating device 300 provided in the present application are the same as those of the above embodiments, and for the sake of brief description, no part of this embodiment is mentioned, and no further description is provided herein, and reference may be made to the corresponding contents in the above embodiments. The task execution device 300 includes: a ranking module 310, a determining module 330, and a binding module 350.
The classification module 310 is configured to, when the CPU has cores with different computing capabilities, divide all the cores into cores of N operation levels according to the computing capabilities;
a determining module 330, configured to determine, when there is a task to be executed, a target core that matches the priority of the task to be executed among cores of the N operation levels; wherein the priority of the task to be executed represents the computing power requirement of the task to be executed; the target core belongs to at least one of the total cores;
and a binding module 350, configured to bind the task to be executed to the target core for operation.
Optionally, the ranking module 310 is further configured to: acquiring the maximum working frequency of each core in the CPU; when the maximum working frequency of at least two cores meets the duplicate removal condition, determining the cores with different computing capacities of the CPU; the weight removing condition represents that the maximum working frequencies of any two cores are not coincident; and dividing all cores into cores of N operation levels according to the maximum working frequency of each core.
Optionally, the ranking module 310 is further configured to: determining whether the CPU has cores with different computing capabilities according to the type information of the CPU; if yes, dividing all cores into cores with N operation levels according to different computing capabilities.
Optionally, the ranking module 310 is further configured to: acquiring a core type corresponding to the type information of the CPU in a pre-stored information table; the core type characterizes the computing power of the core; when there are at least two core types, it is determined that the CPU has cores with different computing capabilities.
Optionally, the determining module 330 is further configured to: when the task to be executed is an interactive task, determining the core with the highest operation level as a target core matched with the priority of the interactive task in the cores with the N operation levels;
when the task to be executed is a low-frequency task, determining the core with the lowest operation level as a target core matched with the priority of the low-frequency task from the cores with the N operation levels; the low-frequency task represents the task with the shortest historical running time in preset time;
when the task to be executed is a low-demand task, determining the core with the lowest operation level as a target core matched with the priority of the low-demand task from the cores with the N operation levels; the low-demand task characterizes a task with the lowest computing power requirement among the currently executed tasks.
The present invention further provides a mobile terminal, which includes a processor 120 and a memory 130, where the memory 130 stores a computer program, and when the processor executes the computer program, the method for implementing the task operation disclosed in the foregoing embodiment is implemented.
The embodiment of the present invention further provides a storage medium, on which a computer program is stored, and the computer program, when executed by the processor 120, implements the task execution method disclosed in the embodiment of the present invention.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present invention may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (10)
1. A task running method is applied to a mobile terminal, the mobile terminal comprises a CPU, and the method comprises the following steps:
when the CPU has cores with different computing capacities, dividing all the cores into cores with N operation levels according to the computing capacity; when the task to be executed exists, determining a target core matched with the priority of the task to be executed in the cores of the N operation levels; wherein the priority of the task to be executed characterizes the computing power requirement of the task to be executed; the target core belongs to at least one of the total cores;
and binding the task to be executed to the target core for operation.
2. The method according to claim 1, wherein the step of dividing all cores into cores of N operation levels according to different computation capabilities when the CPUs have cores of different computation capabilities comprises:
acquiring the maximum working frequency of each core in the CPU;
when the maximum working frequency of at least two cores meets the duplicate removal condition, determining the cores with different computing capacities of the CPU; the de-emphasis condition represents that the maximum working frequencies of any two cores are not coincident;
and dividing all cores into cores of N operation levels according to the maximum working frequency of each core.
3. The method according to claim 1, wherein the step of dividing all cores into cores of N operation levels according to different computation capabilities when the CPUs have cores of different computation capabilities comprises:
determining whether the CPU has cores with different computing capabilities according to the type information of the CPU;
if yes, dividing all cores into cores with N operation levels according to different computing capabilities.
4. The method according to claim 3, wherein the step of determining whether the CPUs have cores with different computing capabilities according to the type information of the CPUs comprises:
acquiring a core type corresponding to the type information of the CPU in a pre-stored information table; the core type characterizes the computing power of the core;
when there are at least two core types, it is determined that the CPU has cores with different computing capabilities.
5. The method according to claim 1, wherein the step of determining, among the cores of the N operation levels, a target core matching the priority of the task to be executed when there is the task to be executed, comprises:
when the task to be executed is an interactive task, determining the core with the highest operation level as a target core matched with the priority of the interactive task in the cores with the N operation levels;
when the task to be executed is a low-frequency task, determining a core with the lowest operation level as a target core matched with the priority of the low-frequency task from the cores with the N operation levels; the low-frequency task represents the task with the shortest historical running time in preset time;
when the task to be executed is a low-demand task, determining a core with the lowest operation level as a target core matched with the priority of the low-demand task from the cores with the N operation levels; the low-demand task represents a task with the lowest computing power demand in the currently executed tasks.
6. An apparatus for task execution, applied to a mobile terminal, wherein the mobile terminal includes a CPU, the apparatus comprising:
the classification module is used for dividing all cores into cores with N operation levels according to the computing power when the CPU has cores with different computing powers;
the determining module is used for determining a target core matched with the priority of the task to be executed in the cores of the N operation levels when the task to be executed exists; wherein the priority of the task to be executed characterizes the computing power requirement of the task to be executed; the target core belongs to at least one of the total cores;
and the binding module is used for binding the task to be executed to the target core for operation.
7. The apparatus of claim 6, wherein the ranking module is further configured to:
acquiring the maximum working frequency of each core in the CPU;
when the maximum working frequency of at least two cores meets the duplicate removal condition, determining the cores with different computing capacities of the CPU; the de-emphasis condition represents that the maximum working frequencies of any two cores are not coincident;
and dividing all cores into cores of N operation levels according to the maximum working frequency of each core.
8. The apparatus of claim 6, wherein the determining module is further configured to:
when the task to be executed is an interactive task, determining the core with the highest operation level as a target core matched with the priority of the interactive task in the cores with the N operation levels;
when the task to be executed is a low-frequency task, determining a core with the lowest operation level as a target core matched with the priority of the low-frequency task from the cores with the N operation levels; the low-frequency task represents the task with the shortest historical running time in preset time;
when the task to be executed is a low-demand task, determining a core with the lowest operation level as a target core matched with the priority of the low-demand task from the cores with the N operation levels; the low-demand task represents a task with the lowest computing power demand in the currently executed tasks.
9. A mobile terminal, characterized in that it comprises a processor and a memory, said memory storing a computer program which, when executed by said processor, implements the method of any one of claims 1 to 5.
10. A storage medium, characterized in that the storage medium has stored thereon a computer program which, when executed by a processor, implements the method of any one of claims 1 to 5.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202110097611.2A CN112817428B (en) | 2021-01-25 | 2021-01-25 | Task running method, device, mobile terminal and storage medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202110097611.2A CN112817428B (en) | 2021-01-25 | 2021-01-25 | Task running method, device, mobile terminal and storage medium |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN112817428A true CN112817428A (en) | 2021-05-18 |
| CN112817428B CN112817428B (en) | 2024-10-08 |
Family
ID=75859476
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202110097611.2A Active CN112817428B (en) | 2021-01-25 | 2021-01-25 | Task running method, device, mobile terminal and storage medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN112817428B (en) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113268438A (en) * | 2021-05-19 | 2021-08-17 | 维沃移动通信有限公司 | Memory recovery method and device and electronic equipment |
| CN114416357A (en) * | 2022-01-06 | 2022-04-29 | 北京百度网讯科技有限公司 | Method and device for creating container group, electronic equipment and medium |
| CN115686873A (en) * | 2022-12-30 | 2023-02-03 | 摩尔线程智能科技(北京)有限责任公司 | Core scheduling method and device for multi-core system |
| CN116025929A (en) * | 2021-10-25 | 2023-04-28 | 佛山市顺德区美的洗涤电器制造有限公司 | Operation control method and device for electrical equipment and electrical equipment controller |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107402813A (en) * | 2017-06-21 | 2017-11-28 | 努比亚技术有限公司 | The method and mobile terminal of a kind of resource allocation, computer-readable recording medium |
| CN108334405A (en) * | 2017-01-20 | 2018-07-27 | 阿里巴巴集团控股有限公司 | Frequency isomery CPU, frequency isomery implementation method, device and method for scheduling task |
| CN110647390A (en) * | 2019-09-20 | 2020-01-03 | 西安交通大学 | Parallel task allocation scheduling method based on locality quantization for multi-core system |
| CN110955499A (en) * | 2018-09-26 | 2020-04-03 | Oppo广东移动通信有限公司 | Processor core configuration method, device, terminal and storage medium |
| CN112068960A (en) * | 2020-09-10 | 2020-12-11 | 华云数据控股集团有限公司 | CPU resource allocation method, device, storage medium and equipment |
-
2021
- 2021-01-25 CN CN202110097611.2A patent/CN112817428B/en active Active
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108334405A (en) * | 2017-01-20 | 2018-07-27 | 阿里巴巴集团控股有限公司 | Frequency isomery CPU, frequency isomery implementation method, device and method for scheduling task |
| CN107402813A (en) * | 2017-06-21 | 2017-11-28 | 努比亚技术有限公司 | The method and mobile terminal of a kind of resource allocation, computer-readable recording medium |
| CN110955499A (en) * | 2018-09-26 | 2020-04-03 | Oppo广东移动通信有限公司 | Processor core configuration method, device, terminal and storage medium |
| CN110647390A (en) * | 2019-09-20 | 2020-01-03 | 西安交通大学 | Parallel task allocation scheduling method based on locality quantization for multi-core system |
| CN112068960A (en) * | 2020-09-10 | 2020-12-11 | 华云数据控股集团有限公司 | CPU resource allocation method, device, storage medium and equipment |
Cited By (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113268438A (en) * | 2021-05-19 | 2021-08-17 | 维沃移动通信有限公司 | Memory recovery method and device and electronic equipment |
| WO2022242683A1 (en) * | 2021-05-19 | 2022-11-24 | 维沃移动通信有限公司 | Memory recovery method and apparatus, and electronic device |
| CN113268438B (en) * | 2021-05-19 | 2024-03-08 | 维沃移动通信有限公司 | Memory recycling method, device and electronic device |
| CN116025929A (en) * | 2021-10-25 | 2023-04-28 | 佛山市顺德区美的洗涤电器制造有限公司 | Operation control method and device for electrical equipment and electrical equipment controller |
| CN114416357A (en) * | 2022-01-06 | 2022-04-29 | 北京百度网讯科技有限公司 | Method and device for creating container group, electronic equipment and medium |
| CN115686873A (en) * | 2022-12-30 | 2023-02-03 | 摩尔线程智能科技(北京)有限责任公司 | Core scheduling method and device for multi-core system |
Also Published As
| Publication number | Publication date |
|---|---|
| CN112817428B (en) | 2024-10-08 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN112817428A (en) | Task running method and device, mobile terminal and storage medium | |
| CN110545246A (en) | Token bucket-based current limiting method and device | |
| CN111767142A (en) | Current limiting threshold setting method of service node and server side equipment | |
| CN113986497B (en) | Queue scheduling method, device and system based on multi-tenant technology | |
| CN107943854B (en) | Credit investigation service query method, apparatus and computer readable storage medium | |
| CN114816738A (en) | Method, device and equipment for determining calculation force node and computer readable storage medium | |
| CN109634812B (en) | Process CPU occupancy rate control method of Linux system, terminal device and storage medium | |
| CN114911598A (en) | Task scheduling method, device, equipment and storage medium | |
| CN113867957B (en) | Method and device for realizing cross-cluster container quantity elastic expansion | |
| CN109191287A (en) | A kind of sharding method, device and the electronic equipment of block chain intelligence contract | |
| CN108243032B (en) | Method, device and equipment for acquiring service level information | |
| CN112600761A (en) | Resource allocation method, device and storage medium | |
| CN111192063A (en) | Online customer service queuing processing method and device and electronic equipment | |
| US20210360058A1 (en) | Job allocation support system and method | |
| CN115211092A (en) | Message pulling method and device and computer storage medium | |
| CN117707797B (en) | Task scheduling method, device and related equipment based on distributed cloud platform | |
| CN115237595A (en) | Data processing method, data processing device, distribution server, data processing system, and storage medium | |
| CN107391564A (en) | Data transfer device, device and electronic equipment | |
| CN110716813A (en) | Data stream processing method and device, readable storage medium and processor | |
| CN111580882B (en) | Application program starting method, device, computer system and medium | |
| CN119537040B (en) | Task processing method, device and equipment running on cloud computing platform | |
| CN111290850B (en) | Data storage method, device and equipment | |
| CN109257806B (en) | Carrier aggregation mode setting method for communication terminal, communication terminal and medium | |
| CN115238837B (en) | Data processing method and device, electronic equipment and storage medium | |
| WO2023025033A1 (en) | Intelligent dataset slicing during microservice handshaking |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |