Task scheduling method, electronic equipment and computer readable storage medium

By dynamically adjusting the thread scheduling configuration according to the operating status of the application, the problem that the CFS scheduling class cannot meet the scheduling needs in a diverse scenario is solved, and more efficient task scheduling is achieved, electronic equipment lags and user experience is improved.

CN119248431AActive Publication Date: 2025-01-03HONOR DEVICE CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202410102870.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-25
Publication Date
2025-01-03
Estimated Expiration
2044-01-25

AI Technical Summary

Technical Problem

Priority scheduling based on CFS scheduling class cannot meet the scheduling needs of important tasks in diversified scenarios, resulting in long response time and causing electronic equipment to stutter.

Method used

By determining the first scheduling configuration based on the current running status of M applications, dynamically adjusting the scheduling parameters of Class N threads to adapt to the needs of different scenarios and avoiding lag.

Benefits of technology

It effectively improves the response speed of electronic devices, reduces lags, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248431A_ABST
    Figure CN119248431A_ABST
Patent Text Reader

Abstract

The invention provides a task scheduling method, electronic equipment and a computer readable storage medium. In the method, the electronic equipment determines first scheduling configuration used for scheduling N types of threads based on current first running states of M application programs, and the first scheduling configuration is used for indicating scheduling parameters of the N types of threads. The first scheduling configuration used for indicating the N types of threads can be adjusted along with the current first running states of the M application programs, so that the first scheduling configuration meets the scheduling requirements of the N types of threads in different scenes, the phenomena of lagging and the like of the electronic equipment can be avoided, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminals, and in particular to a task scheduling method, an electronic device, and a computer-readable storage medium. Background Art

[0002] In Linux systems, task priorities can be differentiated through different scheduling classes, such as real-time (RT) scheduling class, completely fair scheduler (CFS) scheduling class, etc. In some scenarios, priority scheduling based on the CFS scheduling class can give priority to important tasks while ensuring fair scheduling, thereby improving the efficiency of system operation. Therefore, priority scheduling based on the CFS scheduling class has been widely used.

[0003] However, with the diversification of usage scenarios, priority scheduling based on CFS scheduling cannot meet the scheduling needs of important tasks, which can easily cause long task response time and cause electronic equipment to freeze. Summary of the invention

[0004] The present application provides a method for task scheduling, an electronic device, and a computer-readable storage medium. The electronic device determines a first scheduling configuration based on the current running status of M applications, and schedules N types of threads based on the first scheduling configuration, so that the scheduling configuration of the N types of programs will change with the adjustment of the M applications, so that the N types of scheduling configurations can change with the change of the use scenario of the electronic device, thereby meeting the scheduling requirements of various threads in different scenarios, avoiding the phenomenon of freezing of the electronic device, and improving the user experience.

[0005] In a first aspect, the present application provides a task scheduling method, which is applied to an electronic device, and the method includes: the electronic device determines a first scheduling configuration based on a current first running state of M applications, the first scheduling configuration indicates scheduling parameters of N types of threads on the first electronic device, and M and N are positive integers; wherein the first running state belongs to one of multiple running states, the first scheduling configuration belongs to one of multiple scheduling configurations, different running states correspond to different scheduling configurations, and the first running state corresponds to the first scheduling configuration; the electronic device runs the N types of threads based on the first scheduling configuration.

[0006] In the task scheduling method provided in the present application, the electronic device determines a first scheduling configuration for scheduling N types of threads based on the current first running state of M applications. Among them, the first running state belongs to one of multiple running states, the first scheduling configuration belongs to one of multiple scheduling configurations, and different running states correspond to different scheduling configurations. Therefore, when the running states of M applications in the electronic device change, the scheduling configuration for scheduling N types of threads will also be adjusted, which can meet the scheduling requirements of N types of threads in different scenarios, can avoid the phenomenon of freezing of the electronic device, and thus improve the user experience.

[0007] Optionally, the above-mentioned first scheduling configuration indicates scheduling parameters of N types of threads on the first electronic device. It can be understood that the first scheduling configuration includes N groups of scheduling parameters, each group of scheduling parameters is used to schedule a type of thread, and the N groups of scheduling parameters can be used to schedule N types of threads respectively.

[0008] Optionally, the present application does not limit the number and names of the M applications, for example, M=1, 2, 3 or 4, etc. For another example, the M applications can be any M applications loaded on the electronic device. Exemplarily, in the case of M=1, 1 application can be an application that the user focuses on, an application that the user uses heavily, an application that consumes a lot of electronic device operating resources, or an application that can reflect the current usage scenario (for example, an application that is being launched in the foreground). In the case of M>1, the M applications can be multiple applications that the user focuses on, multiple applications that the user uses heavily, multiple applications that consume a lot of electronic device operating resources, or multiple applications that can reflect the current usage scenario (for example, an application that is being interacted with by the user).

[0009] Optionally, the present application does not specifically limit the number and type of N-type threads. For example, N=1, 2, 3 or 4, etc. For another example, the N-type threads may be one or more of the main thread (user interface thread, UI thread), rendering thread, audio thread and animation thread.

[0010] Optionally, the N types of threads shown in the present application also include categories that are customized through a human-computer interaction interface. For example, thread A, thread B, and thread C are referred to as threads of the first category through the human-computer interaction interface.

[0011] Optionally, the current running states of the M applications may also be understood as the current usage scenario of the electronic device.

[0012] In a possible implementation, the electronic device determines a first scheduling configuration based on a current first running state of M applications, including: the electronic device determines the first scheduling configuration based on the current first running state of the M applications and a preset first mapping relationship, and the first mapping relationship indicates the correspondence between the multiple running states and the multiple scheduling configurations.

[0013] In the implementation provided by the present application, the electronic device determines a first scheduling configuration based on the current first operating state of M applications and a preset first mapping relationship, wherein the first mapping relationship indicates the correspondence between multiple operating states and multiple scheduling configurations, and different operating states correspond to different scheduling configurations. For example, the first mapping relationship indicates the correspondence between 10 operating states and 10 scheduling configurations, and the 10 operating states correspond to 10 scheduling configurations respectively. Therefore, when the first operating state of M applications is determined, the first scheduling configuration can be uniquely determined based on the preset first mapping relationship, so that the electronic device can schedule N types of threads based on the first scheduling configuration, thereby meeting the scheduling requirements of various types of threads in different scenarios, avoiding the phenomenon of jamming of the electronic device, and improving the user experience.

[0014] In another possible implementation, the electronic device determines a first scheduling configuration based on the current first running status of the M applications, including: the electronic device determines the first scheduling configuration based on the current first running status of the M applications and a preset machine learning model, the input parameter of the above machine learning model is the running status of the M applications, and the output parameter of the above machine learning model is the scheduling configuration of N types of threads (also called the first scheduling configuration).

[0015] In another possible implementation, the method further includes: receiving a first user operation, the first user operation being used to adjust the running state of one or more of the M applications; the electronic device determining a second scheduling configuration based on the current second running state of the M applications and / or the operation type of the first user operation, the scheduling parameters of the N types of threads indicated by the first scheduling configuration and the second scheduling configuration being partially or completely different; and the electronic device running the N types of threads based on the second scheduling configuration.

[0016] In the implementation manner provided by the present application, an electronic device receives a first user operation, and the first user operation is used to adjust the running state of one or more applications in M ​​applications. The electronic device determines a second scheduling configuration based on the current second running state of the M applications and / or the operation type of the first operation. It can be understood that the current second running state of the M applications refers to the running state of the M applications adjusted based on the first operation. The second scheduling configuration determined based on the second running state and / or the operation type of the first user operation is different from the first scheduling configuration determined based on the first running state, specifically, the scheduling parameters of the N types of threads indicated by the first scheduling configuration and the second scheduling configuration are partially or completely different. For example, the scheduling parameters of the first thread in the N types of threads indicated in the first scheduling configuration and the second scheduling configuration are different. For another example, the scheduling parameters of any type of thread in the N types of threads indicated in the first scheduling configuration and the second scheduling configuration are different. It can be seen that when the running state of the M applications in the electronic device changes, the scheduling parameters used to schedule the N types of threads will also change, which can meet the scheduling requirements of the N types of threads in different scenarios, and can avoid the phenomenon of jamming in the electronic device, thereby improving the user experience.

[0017] Optionally, the operation type of the first operation includes: click, slide, zoom and other operations. The first operation can also be an air gesture, voice control, etc. This application does not limit the specific operation method of the first operation. The first operation can adjust the running status of M applications, which all belong to the protection scope of this application.

[0018] In another possible implementation, the electronic device determines a second scheduling configuration based on the current second running state of the M applications and the operation type of the first user operation, including: the electronic device determines the second scheduling configuration based on the second running state, the operation type of the first user operation and a preset second mapping relationship; the second mapping relationship indicates a correspondence between multiple groups of state types and multiple scheduling configurations, wherein a group of state types includes an running state and an operation type of user operation, and different groups of state types correspond to different scheduling configurations.

[0019] In the implementation manner provided by the present application, the electronic device determines the second scheduling configuration based on the current second running state of M applications, the operation type of the first user operation and the preset second mapping relationship, wherein the second mapping relationship indicates the correspondence between multiple groups of state types and multiple scheduling configurations, and different state types correspond to different scheduling configurations, wherein one group of state types includes one running state and one user operation type. For example, the second mapping relationship indicates the correspondence between 20 groups of state types and 20 scheduling configurations, and the 20 groups of state types correspond to 20 scheduling configurations respectively. For example, the second mapping relationship indicates the correspondence between 20 groups of state types and 20 scheduling configurations, and the 20 state types correspond to 20 scheduling configurations respectively. Therefore, when the second running state of M applications is determined, the second scheduling configuration can be uniquely determined based on the preset second mapping relationship, so that the electronic device can schedule N types of threads based on the second scheduling configuration, thereby meeting the scheduling requirements of various types of threads in different scenarios, avoiding the phenomenon of jamming in the electronic device, and improving the user experience.

[0020] In another possible implementation, the electronic device determines the second scheduling configuration based on the current second operating state of the M applications, including: the electronic device determines the second scheduling configuration based on the second operating state and a preset second mapping relationship; the second mapping relationship indicates the correspondence between multiple operating states and multiple scheduling configurations, and different groups of state types correspond to different scheduling configurations.

[0021] In the implementation provided by the present application, the electronic device determines the second scheduling configuration based on the current second operating state of the M applications and the preset second mapping relationship, wherein the second mapping relationship indicates the correspondence between multiple operating states and multiple scheduling configurations, and different operating states correspond to different scheduling configurations. For example, the second mapping relationship indicates the correspondence between 10 operating states and 10 scheduling configurations, and the 10 operating states correspond to 10 scheduling configurations respectively. Therefore, when the second operating state of the M applications is determined, the second scheduling configuration can be uniquely determined based on the preset second mapping relationship, so that the electronic device can schedule N types of threads based on the second scheduling configuration, thereby meeting the scheduling requirements of various types of threads in different scenarios, avoiding the phenomenon of jamming of the electronic device, and improving the user experience.

[0022] In another possible implementation, the method also includes receiving indication information of a thread request, the indication information being used to indicate the thread requested to run; the electronic device determines a first scheduling configuration based on a current first running state of the M applications, including: when it is determined that the thread requested to run belongs to the N types of threads, the electronic device determines the first scheduling configuration based on the running states of the M applications.

[0023] In the implementation mode provided by the present application, an electronic device (specifically, a kernel layer of an electronic device) receives indication information of a thread request, and the indication information is used to indicate the thread requested to run. The electronic device determines whether the thread requested to run belongs to the above-mentioned N types of threads. If the thread requested to run belongs to the N types of threads, the above-mentioned electronic device determines the first scheduling configuration based on the running status of the M applications. Correspondingly, if the thread requested to run does not belong to the N types of threads, the above-mentioned electronic device maintains the original scheduling configuration.

[0024] In another possible implementation, the method also includes receiving indication information of a thread request, the indication information being used to indicate the thread requested to run; the electronic device determining a second scheduling configuration based on the current second running state of the M applications and / or the operation type of the first user operation, including: when it is determined that the thread requested to run belongs to the N types of threads, the electronic device determining the second scheduling configuration based on the current second running state of the M applications and / or the operation type of the first user operation.

[0025] In the implementation mode provided by the present application, an electronic device (specifically, a kernel layer of an electronic device) receives indication information of a thread request, and the indication information is used to indicate the thread requested to run. The electronic device determines whether the thread used to request to run belongs to the above-mentioned N types of threads. When the thread used to request to run belongs to the N types of threads, the above-mentioned electronic device determines the second scheduling configuration based on the running status of the M applications and / or the operation type of the first operation. Correspondingly, when the thread requested to run does not belong to the N types of threads, the above-mentioned electronic device maintains the original scheduling configuration (for example, the first scheduling configuration).

[0026] In another possible implementation, the first scheduling configuration includes a first scheduling parameter, the N types of threads include a first thread, and the first scheduling parameter is used to schedule the first thread; the method further includes: when the running states of the M applications remain unchanged and the electronic device completes running the first thread based on the first scheduling parameter, the electronic device fairly schedules the first thread.

[0027] In the implementation manner provided in the present application, the first scheduling configuration includes a first scheduling parameter, the N types of threads include a first thread, and the first scheduling parameter is used to schedule the first thread. Among them, the first thread refers to a type of thread, such as an audio thread. When the running states of the above-mentioned M applications remain unchanged, and the electronic device completes the running of the first thread based on the first scheduling parameter, the electronic device fairly schedules the first thread. Among them, the unchanged running states of the M applications refer to the unchanged running state of any one of the M applications. When the electronic device completes the running of the first thread based on the first scheduling parameter, the first thread is fairly scheduled. It can be understood that when the electronic device completes the scheduling of the target task on the first thread based on the first scheduling parameter, the electronic device schedules the target task fairly, and the fair scheduling is achieved, for example, through the CFS scheduling class.

[0028] In another possible implementation, the second scheduling configuration includes a second scheduling parameter, the N types of threads include a second thread, and the second scheduling parameter is used to schedule the second thread; the method further includes: when the running states of the M applications remain unchanged and the electronic device completes running the second thread based on the second scheduling parameter, the electronic device fairly schedules the second thread.

[0029] In the implementation manner provided in the present application, the second thread refers to a type of thread, such as an audio thread. The unchanged running status of the M applications means that the running status of any one of the M applications remains unchanged. When the electronic device completes the running of the second thread based on the second scheduling parameters, the second thread is fairly scheduled. It can be understood that when the electronic device completes the scheduling of the target task on the second thread based on the second scheduling parameters, the electronic device schedules the target task fairly, and the fair scheduling is implemented, for example, through the CFS scheduling class.

[0030] In another possible implementation, the scheduling parameters include one or more of the following: task level, priority running time or core selection tendency; wherein the task level is used to determine the scheduling order of the target task, the priority running time is used to indicate the time to prioritize running the target task, and the core selection tendency is used to indicate the type of processor running the target task and / or the status of the processor.

[0031] In the implementation mode provided in the present application, the scheduling parameters include one or more of the following: task level, priority running time or core selection tendency. Among them, the task level is used to determine the scheduling order of the target task, the priority running time is used to indicate the time to prioritize the running of the target task, and the core selection tendency is used to indicate the type and / or state of the processor running the target task. Exemplarily, on the one hand, the electronic device will add the target task to the scheduling queue based on the task level of the target task, and on the other hand, the electronic device will execute the tasks in the scheduling queue in sequence. For example, the electronic device will determine the processor to run the target task based on the core selection tendency, and the electronic device will also determine the time to run the target task based on the priority running time.

[0032] Optionally, the types of processors include large cores, medium cores, and small cores. The types of processors are only used to distinguish the processing performance of the processors, and the processing performance of large cores, medium cores, and small cores decreases in sequence. Exemplarily, if the target task has a large amount of data to be processed, a large core is preferred, and if the target task has a small amount of data to be processed, a small core is preferred. The states of the processors include idle processors and non-idle processors. An idle processor (IDLE-CPU) indicates that there are no tasks running on the processor. A non-idle processor indicates that there are tasks running on the processor. Exemplarily, if the target task has a high requirement for real-time performance, an idle processor can be given priority, and if the target task does not have a high requirement for real-time performance, a non-idle processor can be given priority.

[0033] In another possible implementation, the running state includes a startup state, an interactive state, and a background state.

[0034] In the implementation mode provided in the present application, the startup state can be understood as the state of the application during the startup process, the interaction state can be understood as the state of the application when it is running in the foreground, and the background state can be understood as the state of the application when it is running in the background of the electronic device.

[0035] In another possible implementation, the N types of threads include one or more of the following: a main thread, a rendering thread, an audio thread, a motion effect thread, and a custom thread.

[0036] In the implementation method provided by this application, the N types of threads include one or more of the following: main thread, rendering thread, audio thread, animation thread and custom thread. Among them, the custom thread can be a category customized by the user through the human-computer interaction interface. This application does not limit which threads the user customizes.

[0037] In a second aspect, the present application provides an electronic device, comprising a display screen, a memory, and a processor coupled to the memory; the display screen is used to display an interface, the memory stores a computer program, and when the processor executes the above computer program, the electronic device implements any one of the methods described in the above first aspect.

[0038] In a third aspect, the present application provides a computer-readable storage medium, which stores a computer program or computer instructions, and the aforementioned computer program or computer instructions are executed by a processor to implement any method described in the first aspect above.

[0039] In a fourth aspect, an embodiment of the present application provides a computer program product. When the computer program product is executed by a processor, the method described in any one of the above-mentioned first aspects will be implemented.

[0040] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a memory, wherein the memory is used to store computer programs or computer instructions, and the processor is used to execute the computer programs or computer instructions stored in the memory, so that the chip executes any method described in the first aspect above.

[0041] The solutions provided in the second to fifth aspects are used to implement or cooperate with the corresponding methods provided in the first aspect, and therefore can achieve the same or corresponding beneficial effects as the corresponding methods in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 is a schematic diagram of the hardware structure of an electronic device 100 provided in an embodiment of the present application;

[0043] Figure 2 It is a schematic diagram of a priority scheduling provided by an embodiment of the present application;

[0044] Figure 3A is a schematic diagram of starting an application provided by an embodiment of the present application;

[0045] Figure 3B is a schematic diagram of a user interface provided in an embodiment of the present application;

[0046] Figure 4A is a schematic diagram of another method of starting an application provided in an embodiment of the present application;

[0047] Figure 4B is another user interface schematic diagram provided in an embodiment of the present application;

[0048] Figure 5A is a schematic diagram of using an application provided by an embodiment of the present application;

[0049] Figure 5B is another user interface schematic diagram provided in an embodiment of the present application;

[0050] Fig. 6A is a schematic diagram of a multi-tasking interface provided in an embodiment of the present application;

[0051] Figure 6B is another user interface schematic diagram provided in an embodiment of the present application;

[0052] Figure 7 It is a flowchart of a task scheduling method provided by this application;

[0053] Figure 8 It is a flowchart of another task scheduling method provided by this application. DETAILED DESCRIPTION

[0054] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations to the present application. As used in the specification and appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear indication to the contrary in the context. It should also be understood that the term "and / or" used in the present application refers to and includes any or all possible combinations of one or more listed items.

[0055] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.

[0056] The following first introduces the hardware structure of the electronic device 100 provided in the embodiment of the present application.

[0057] Figure 1 It is a schematic diagram of the structure of the electronic device 100 provided in an embodiment of the present application.

[0058] The following is a detailed description of the embodiment using the electronic device 100 as an example. It should be understood that the electronic device 100 may have more than Figure 1 More or fewer components may be shown, two or more components may be combined, or there may be a different configuration of components. Figure 1 The various components shown in the EMBODIMENTS 2000 may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application specific integrated circuits.

[0059] The electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a camera 193, a display screen 194, etc. The sensor module 180 may include a pressure sensor 180A, a touch sensor 180B, etc.

[0060] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0061] Each CPU can be single-core or multi-core. The CPU is the computing and control core of the electronic device, mainly used to realize information processing and program running. The CPU can include one or more of a large-core CPU (also referred to as a large core), a medium-core CPU (also referred to as a medium core), or a small-core CPU (also referred to as a small core). The large core has the highest processing power and the strongest performance, the medium core has the second-best processing power and performance, and the small core has the lowest processing power and the weakest performance.

[0062] The CPU is part of a system-on-chip (SoC). For example, one or more CPUs can form a cluster. The SoC of an electronic device includes multiple clusters, which facilitates the scheduling of CPUs to achieve a better energy efficiency ratio. Optionally, each cluster includes only large cores, medium cores, or small cores.

[0063] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0064] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0065] The charging management module 140 is used to receive charging input from a charger, where the charger can be a wireless charger or a wired charger.

[0066] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, etc.

[0067] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

[0068] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.

[0069] The camera 193 is used to capture still images or videos. The electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.

[0070] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.

[0071] The video codec is used to compress or decompress digital video. The electronic device 100 may support one or more video codecs. In this way, the electronic device 100 may play or record videos in multiple coding formats.

[0072] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0073] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.

[0074] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. The program storage area may store an operating system, applications required for at least one function (such as face recognition function, fingerprint recognition function, mobile payment function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as face information template data, fingerprint information template, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0075] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0076] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.

[0077] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.

[0078] The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be received by placing the receiver 170B close to the human ear.

[0079] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals.

[0080] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be set on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. A capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure based on the change in capacitance. When a touch operation acts on the display screen 194, the electronic device 100 detects the intensity of the touch operation according to the pressure sensor 180A. The electronic device 100 can also calculate the position of the touch based on the detection signal of the pressure sensor 180A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions.

[0081] The touch sensor 180B is also called a "touch panel". The touch sensor 180B can be arranged on the display screen 194, and the touch sensor 180B and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180B is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180B can also be arranged on the surface of the electronic device 100, which is different from the position of the display screen 194.

[0082] It should be understood that Figure 1The hardware structure of the electronic device 100 shown is only an example. The electronic device 100 of the embodiment disclosed in the present application may have more or fewer components than those shown in the figure, may combine two or more components, or may have a different component configuration. Figure 1 The various components shown in the EMBODIMENTS 2000 may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application specific integrated circuits.

[0083] In addition, it should be understood that the electronic device 100 in the embodiment disclosed in the present application can implement different functions by installing different applications (or simply referred to as "applications"), where the application can be a native application, such as settings, phone, camera, etc., or a third-party application downloaded from an application store, such as "WeChat", etc.

[0084] The operation of each application may start one or more tasks, which are also called threads. Electronic devices use schedulers to allocate resources to each process to support the execution of the process. When scheduling processes, in order to better meet the scheduling requirements of different threads, the kernel implements several scheduling classes with different scheduling strategies, including stop scheduling class, deadline scheduling class, RT scheduling class, CFS scheduling class and IDLE scheduling class, etc. in order of scheduling priority. Furthermore, there are some threads whose importance is between the RT scheduling class and the CFS scheduling class, so priority scheduling based on the CFS scheduling class is derived. Exemplarily, when the electronic device identifies this type of thread, it will first add it to the priority scheduling queue, and perform CFS scheduling on it after completing its priority scheduling. Simply understand that the thread that performs priority scheduling can be called a critical thread, and the thread that performs only CFS scheduling can be called an ordinary thread. Compared with ordinary threads, critical threads will be prioritized for a period of time (priority running time). When the critical thread completes the priority running, it will be regarded as an ordinary thread and scheduled through the CFS scheduling class.

[0085] Next, several conditions for being judged as critical threads are introduced as examples.

[0086] Condition 1: When the application is running in the foreground of the electronic device, the key threads in the threads executed by the application include one or more of the following: main thread, rendering thread, animation thread and audio thread.

[0087] Condition 2: When the application is running in the background of the electronic device, the key threads in the threads executed by the application include one or more of the following: audio thread, monitoring thread (including video monitoring, infrared monitoring, audio monitoring), etc.

[0088] Condition 3: Threads associated with applications of a specified type, such as threads associated with gaming applications and applications associated with video applications. The "applications of a specified type" and "threads associated with applications of a specified type" are described in detail below and will not be described in detail here.

[0089] See also Figure 2 , Figure 2 This is a schematic diagram of a priority scheduling provided in an embodiment of the present application. Priority scheduling has a higher priority than CFS scheduling, and when the first thread is identified as a critical thread, it will be added to the queue maintained by the priority scheduling. For ease of description, the scheduler used to perform priority scheduling will be referred to as a priority scheduler, and the scheduler used to indicate CFS scheduling will be referred to as a CFS scheduler. Exemplarily, when the first thread is identified as a critical thread, the priority scheduler will assign scheduling parameters to the first thread based on a preset scheduling configuration, including scheduling level, priority running time, and core selection tendency, etc., and then the priority scheduler will add the first thread to the queue maintained by the priority scheduling based on its scheduling level. Figure 2 As shown, the scheduling queue maintained by the priority scheduler includes thread A, thread B, thread C, etc., and their scheduling levels are 250, 200, and 100 respectively (the larger the value of the scheduling level, the higher the priority, and the corresponding thread will be scheduled with priority, that is, the priority scheduler will schedule thread A, thread B, and thread C in sequence). If the scheduling level of the first thread is 300, the priority scheduler will add the first thread to the head of the queue and schedule the first thread. Of course, it can also be stipulated that the smaller the value of the scheduling level, the higher the priority, and the corresponding thread will be scheduled with priority, and this application does not limit this.

[0090] Optionally, the above scheduling level is used to determine the order in which threads are prioritized for scheduling. Generally, the higher the scheduling level of a thread, the more important the thread is, and the thread will be scheduled earlier by the priority scheduler. The running status of applications in electronic devices is different (which can also be understood as different usage scenarios of electronic devices), and the importance of the same type of key threads may be different. Therefore, adjusting the scheduling level of key threads according to the running status of applications in electronic devices can effectively meet the scheduling needs of key threads, reduce the phenomenon of electronic devices being stuck, and improve user experience.

[0091] The above-mentioned priority running time indicates the length of time that the thread is preferentially run when the thread is scheduled by the priority scheduler. For example, if the priority running time of the thread is 20ms, the thread will run for 20ms when it is scheduled by the priority scheduler. It can be understood that the running state of the application in the electronic device is different (it can also be understood as the different usage scenarios of the electronic device), and the running resources allocated to the key thread will also be different. For example, when the application is in the startup state, since the electronic device needs to load a large amount of resources and execute a large number of threads accordingly, the continuous running time of the main thread will be longer. When the application is in normal use, the continuous running time of the main thread will be shortened. For another example, if a large number of background applications are opened in the background of the electronic device, the continuous running time of the main thread will be longer accordingly. When the electronic device has sufficient running resources, the continuous running time of the main thread will also be shortened. Therefore, according to the running state of the application in the electronic device, adjusting the priority running time of the key thread can effectively meet the scheduling requirements of the key thread, reduce the phenomenon of jamming of the electronic device, and improve the user experience.

[0092] The above core selection tendency indicates the processor model and processor state for selecting the processor to execute the critical thread, wherein the processor models include large core, medium core and small core. Different processor models represent different processing capabilities, for example, the processing capabilities of large core, medium core and small core decrease in sequence. The processor state may include IDLE-CPU and non-IDLE-CPU, wherein IDLE-CPU refers to a processor that has no running threads, or a processor that runs IDLE threads. Since IDLE-CPU has no running threads, the IDLE-CPU has a lower processing delay when running critical threads. Correspondingly, a certain delay is required for non-IDLE-CPU to run critical threads.

[0093] The priority scheduler schedules the first thread based on the scheduling parameters assigned to it. For example, the priority scheduler selects the processor that runs the first thread based on the core selection preference in the scheduling parameters, and the priority scheduler determines the time to run the first thread based on the priority running time. It is understandable that when the priority scheduler completes the scheduling of the first thread based on the priority running time, the priority scheduler will then schedule thread A in the scheduling queue, and the first thread will be added to the scheduling queue maintained by the CFS scheduler.

[0094] The CFS scheduler sets a virtual run time for each thread. If the thread is executed, its virtual run time will continue to increase. If the thread is not executed, its virtual run time will remain unchanged. The CFS scheduler will give priority to executing the thread with the smallest virtual run time, thereby ensuring fairness and efficiency of scheduling. Figure 2As shown, the scheduling queue maintained by the CFS scheduler adopts a red-black tree data structure ( Figure 2 In the example above, the black background represents black nodes, and the white background represents red nodes), the thread with the shortest virtual running time is placed in the lower left corner of the red-black tree (i.e., thread 1), and the thread in the lower left corner of the red-black tree is selected to run. In the case that the virtual running time of the threads in the scheduling queue changes, the CFS scheduler will update the red-black tree based on the virtual running time of each thread, and run the thread in the lower left corner of the red-black tree again, and so on, until the thread's task is completed and exits the scheduling queue maintained by the CFS scheduler. It should be noted that the virtual running time is a unit of measurement for measuring running resources set by the CFS scheduler according to certain rules. In some possible implementations, the weights corresponding to the virtual running times of different threads are different, which will result in different running resources being allocated to different threads under the same virtual running time. This application does not limit how to set the virtual time.

[0095] Combined with the above Figure 2 From the description, we can know that compared with ordinary threads (threads directly scheduled by CFS), key threads will be given priority to run for a period of time (priority running time), which can meet the running requirements of key threads, thereby reducing the lag of electronic devices and improving user experience.

[0096] However, according to the current mechanism, regardless of the usage scenario of the electronic device, the key threads will be assigned the same scheduling parameters, which will cause some problems.

[0097] A typical problem is that application A can use the UI thread as a key thread during both the startup phase and the normal operation phase, and configure the same scheduling parameters for the UI thread, such as priority 250, priority run time 20ms, and core selection preference for large cores (IDLE-CPU is preferred). However, application A will load a large amount of resources or run a large number of tasks during the application startup phase, which may cause the continuous running time of the UI thread to increase. If the same scheduling parameters are configured for the UI thread, the priority running time will not meet the running requirements of the UI thread.

[0098] In view of this, the present application provides a task scheduling method, which obtains the running status of M applications on an electronic device and determines a scheduling configuration that is adapted to the current state of the electronic device. The scheduling configuration is used to indicate the scheduling parameters of N types of threads, thereby meeting the scheduling requirements of different types of programs, thereby reducing the lag phenomenon of the electronic device and improving the user experience.

[0099] The task scheduling method disclosed in the present application will be described in detail below with reference to specific implementations.

[0100] The task scheduling method provided in the present application determines a first scheduling configuration according to the current first running state of M applications on the electronic device. The first scheduling configuration indicates scheduling parameters of N types of threads on the first electronic device, where M and N are both positive integers.

[0101] The present application does not limit M, for example, M=1, or M>1, etc. The present application does not limit the M application programs, for example, the M application programs may be screened according to a preset rule, or may be preset.

[0102] In a possible implementation, the M applications may be all or part of the applications running on the electronic device. Where the M applications are part of the applications running on the electronic device, the M applications may be screened out from the applications running on the electronic device based on conditions such as the importance of the applications, the frequency of use, and the size of the running resources occupied. For example, the applications with the top M frequency of use may be screened out from the applications running on the electronic device in the order of the frequency of use of the applications as the M applications.

[0103] In another possible implementation, the M applications may be M preset applications. For example, the M applications are pre-set, and the M applications may include applications that are running on the electronic device, and may also include applications that are not running on the electronic device. Applications that are not running on the electronic device include applications that are loaded on the electronic device but not started or applications that are not loaded on the electronic device.

[0104] In another possible implementation, the M applications include preset M1 applications and M2 applications selected according to preset rules, and M1+M2=M. The specific implementation can refer to the above description, which will not be repeated here.

[0105] The current first running state of the M applications includes a non-running state, a startup state, an interactive state, and a background state, etc. Among them, the non-running state includes an application that is on the electronic device but not started or an application that is not loaded on the electronic device. The startup state may be a state in the application startup phase. The interactive state may refer to a state that is running in the foreground and interacting with the user. The background state may refer to a state that is running in the background. Therefore, the current first running state of the above-mentioned M applications is a general term for the current running states of the M applications.

[0106] Several possible situations of the first operating state are introduced below as examples.

[0107] Case 1: The M applications include an application in the startup state.

[0108] Among them, the application in the startup state refers to the application in the startup process, and the startup process is performed in the foreground of the electronic device. In some scenarios, the startup process of the application can be performed in the background, and this application refers to this situation as the background state.

[0109] For example, Figure 3A As shown, in response to the user operating the icon 101 of the "communication" application in the main screen interface of the electronic device (such as the user clicking the icon 101), the electronic device displays the following Figure 3B The interface 102 is shown. The interface 102 is the interface after the "communication" application is started. Figure 3A The interface shown switches to Figure 3B The process shown in interface 102, called "communication" application is in the activated state.

[0110] It is understandable that when an application is in the startup state, the application needs to load a large amount of data and start a large number of threads, which will lead to the phenomenon of tight operating resources of the electronic device, thereby causing the continuous running time of certain key threads to increase, such as UI threads and rendering threads. Therefore, the priority running time of such key threads can be appropriately increased to ensure that such threads can complete a continuous run within the priority running time. Optionally, the core selection tendency of such threads can also be determined as large cores and IDLE-CPU.

[0111] In a possible implementation, the M applications may include multiple applications in the startup state. Exemplarily, when the electronic device is in a split screen state, an application may be started in each split screen.

[0112] For example, Figure 4A As shown, the electronic device is in a split-screen state. In response to the user operating the icon 103 of the "communication" application (such as the user clicking the icon 103) and the icon 104 of the "memo" application (such as the user clicking the icon 104) in the two split-screens of the electronic device, the electronic device displays the following Figure 4B Interface 105 and interface 106 are shown. Interface 105 is the interface after the "communication" application is started, and interface 106 is the interface after the "memorandum" application is started. Figure 4A The interface shown switches to Figure 4B The process of the interface shown is called that the "communication" application and the "memorandum" application are in the activated state. It should be noted that in this case, it is necessary to ensure that there is a small time interval between clicking the icon 103 and the icon 104, so that the "communication" application and the "memorandum" application are both in the activated state at a certain moment.

[0113] Case 2: The M applications include applications in an interactive state.

[0114] The application in an interactive state refers to an application in the process of interacting with a user, and the interaction process is performed in the foreground of the electronic device.

[0115] Exemplarily, the electronic device responds to the user in Figure 5A The operation of the interface 107 (such as the user clicking "User n") causes the electronic device to display the following Figure 5B The interface 108 shown. The electronic device from Figure 5A The interface 107 shown switches to Figure 5B The process of interface 108 is shown as being in an interactive state with a "communication" application.

[0116] It is understandable that when the application is in an interactive state, the application does not need to load a large amount of data, which can shorten the continuous running time of key threads, such as UI threads and rendering threads. Therefore, the priority running time of such key threads can be appropriately reduced, thereby saving the operating resources of the electronic device. Optionally, the core selection tendency of such threads can also be determined as medium core and non-IDLE-CPU.

[0117] In a possible implementation, the M applications may include multiple applications in an interactive state. For example, when the electronic device is in a split screen state, the applications in each split screen may be in an interactive state. Figure 4B For example, the “communication” application shown in interface 105 and the “memo” application shown in interface 106 may both be in an interactive state.

[0118] Case 3: When multiple applications are running in the foreground of the electronic device, the user focuses on the use of a certain application, and the M applications include the application focused by the user.

[0119] Among them, the user focuses on a certain application, which can be understood as the application that the user interacted with last. Figure 4B For example, a user can interact with the "Memo" application and can also interact with the "Communication" application. The application that the user interacted with last time can be called the application focused by the user. It should be noted that this application does not limit how to define the application focused by the user. For example, the application focused by the user can also be determined by counting the running resources occupied by two applications in an interactive state. For example, the application that occupies more running resources is called the application focused by the user.

[0120] It is understandable that the application focused by the user may need to interact with the user frequently. In order to avoid the phenomenon of freezing of such application during the interaction with the user, the priority of the thread associated with the application can be appropriately increased so that the priority scheduler can run the thread associated with such application in a timely manner, thereby avoiding the phenomenon of freezing of such application during the interaction with the user. Correspondingly, since the application not focused by the user may not need to interact with the user frequently, the priority of the thread associated with the application can be appropriately lowered, thereby freeing up more running resources for the application focused by the user, thereby reducing the phenomenon of freezing of the application focused by the user.

[0121] Case 4: The M applications include an application running in the foreground of the electronic device, and the application running in the foreground of the electronic device includes an application belonging to a specific category.

[0122] It should be noted that different categories of applications have their associated threads. For example, game applications will be associated with game-related threads, communication applications will be associated with communication-related threads, and video applications will be associated with video-related threads. The threads associated with different categories of applications will also have different levels of importance in different usage scenarios of the application. Taking game applications as an example, when the game application is in an interactive state or the game application is focused by the user, the priority of the thread associated with the game should be appropriately increased to ensure the normal operation of the game application.

[0123] Case 5: The M applications include applications running in the background of the electronic device, and the applications running in the background of the electronic device include applications belonging to a specific category.

[0124] It should be noted that an application may be associated with multiple threads, but the importance of multiple threads associated with the application may also be different when the application is in different usage scenarios (running states). Taking a video application as an example, when the video application is running in the foreground of an electronic device, its associated video thread and audio thread will be set to a higher priority to ensure the normal operation of the video application. When the video application is placed in the background of an electronic device, since the user can only hear the audio at this time and cannot see the video screen played by the video application, the priority of the video thread can be appropriately reduced, and the priority of the audio thread can be kept unchanged, so as to ensure that the user can "listen to the video" normally. Taking an audio application as an example, when the audio application is running in the foreground of an electronic device, its associated UI thread and audio thread will be set to a higher priority to ensure that the user can interact normally with the audio application (searching audio, playing audio, switching audio, etc.), and ensure that the audio application plays sound normally. When the audio application is placed in the background of an electronic device, since the user can only hear the audio at this time and cannot interact with the audio application, the priority of the UI thread can be appropriately reduced, and the priority of the audio thread can be kept unchanged, so as to ensure that the audio application can play sound normally.

[0125] This application does not limit the classification of applications, threads associated with different types of applications, and how to classify them. For example, applications can be classified by a preset method or by a human-computer interface, or they can be classified according to their characteristics, or threads associated with applications can be determined according to the importance of threads relative to the applications.

[0126] The above shows a variety of situations that the first running state may include, and the value of M may be different in different situations. For example, in situation one, situation two, situation four and situation five, M can be an integer greater than or equal to 1. For another example, in situation three, M can be an integer greater than 1. In addition, the various situations shown above can also be combined with each other. Taking the combination of situation one and situation two as an example, the M applications include applications in the startup state and applications in the interactive state. Taking the combination of situation one and situation five as an example, the M applications include applications in the startup state and applications running in the background (the applications belong to a specific category). Furthermore, the above-mentioned multiple situations (greater than 2) can also be combined with each other. For example, situation one, situation two and situation three are combined, and the M applications include applications in the startup state, applications in the interactive state and applications focused by the user.

[0127] Optionally, a combination of one or more of the above situations may also be referred to as a usage scenario of the electronic device.

[0128] In a possible implementation, the electronic device determines a first scheduling configuration based on a current first running state of the M applications.

[0129] Exemplarily, when the first running state includes one or more of the above situations, the first scheduling configuration can be determined based on the impact of each situation on the thread scheduling configuration. The impact of each situation on the thread scheduling configuration can refer to the above description of each situation, for example, the impact of "situation one" on the thread includes appropriately increasing the priority running time of the key thread. For another example, the impact of "situation two" on the thread includes appropriately reducing the priority running time of the key thread.

[0130] Exemplarily, the first scheduling configuration may be determined based on the usage scenario of the electronic device. Specific implementations may refer to the above-mentioned first operation state including one or more of the above-mentioned situations, and determine the specific implementation of the first scheduling configuration based on the impact of each situation on the thread scheduling configuration.

[0131] The above-mentioned first scheduling configuration indicates the scheduling parameters of N types of threads on the first electronic device, where N is a positive integer. Among them, the N types of threads include all key threads, and the N types of threads can be stored in the electronic device in a pre-set manner, or can be customized to be added and deleted through a human-computer interface, and this application does not limit this. Combined with the above-mentioned related introductions, the N types of threads may include: main thread, rendering thread, animation thread, sound thread, and game-related threads, etc. In addition, users can also set certain threads that need to be focused on as one of the N types of threads in a customized manner. Therefore, the above-mentioned first scheduling configuration includes N groups of scheduling parameters, which are used to indicate N types of threads respectively, as shown in Table 1.

[0132] Table 1

[0133] Critical Threads Priority Priority run time Nuclear selection tendency Audio Thread 300 20ms Small core (non-IDLE-CPU) Rendering Thread 299 30ms Big core (non-IDLE-CPU) Main Thread 298 60ms Big core (IDLE-CPU) Animation Thread 297 40ms Big core (non-IDLE-CPU)

[0134] The N (N=4) types of threads shown in Table 1 include audio threads, rendering threads, main threads, and animation threads. Table 1 shows a possible implementation of the scheduling parameters of the N types of threads. Table 1 can be combined with the above descriptions of "priority", "priority running time" and "core selection tendency" to understand, and no further introduction is given here.

[0135] The above-mentioned first running state is one of multiple running states, and the above-mentioned first scheduling configuration is one of multiple scheduling configurations. Different running states correspond to different scheduling configurations, and the above-mentioned first running state corresponds to the above-mentioned first scheduling configuration. That is, the running states of the M applications can be multiple, and there are also multiple scheduling configurations. Different running states correspond to different scheduling configurations. When the M applications are in different running states, the electronic device can schedule key threads based on different scheduling configurations, thereby meeting the scheduling requirements of key threads, avoiding the phenomenon of electronic devices being stuck, and improving user experience. For information about electronic devices scheduling key threads based on scheduling configurations, please refer to the above Figure 2 The description is not repeated here.

[0136] Exemplarily, the electronic device determines a first scheduling configuration based on the current first running states of the M applications and a preset first mapping relationship, wherein the first mapping relationship indicates a correspondence between multiple running states and multiple scheduling configurations, see Table 2 and Table 3.

[0137] Table 2

[0138]

[0139] Table 3

[0140] M applications First operating state First Application Startup Status Second Application Background Status

[0141] As shown in Table 2, the first mapping relationship is a correspondence relationship between multiple running states and multiple scheduling configurations, wherein any one of the multiple running states uniquely corresponds to one of the multiple scheduling configurations, for example, the first running state corresponds to the first scheduling configuration, the second running state corresponds to the second scheduling configuration, and so on. As shown in Table 3, the current first running state of M applications (referred to as "first running state") refers to the general term for the running state of each application in the M applications. Taking M=2 as an example, the running state of the first application is the startup state, and the running state of the second application is the background state. Therefore, the first running state means that the first application is in the startup state and the second application is in the background state.

[0142] The first scheduling configuration in Table 2 can refer to the above Table 1, which will not be repeated here. Similarly, the second operating state, the third operating state, the fourth operating state, the fifth operating state, the second scheduling configuration, the third scheduling configuration, the fourth scheduling configuration, the fifth scheduling configuration, etc. in Table 2 will not be described one by one, and specific reference can be made to the above Table 1 or Table 3.

[0143] It should be noted that the various operating states and scheduling configurations in the first mapping table can be preset and stored in the electronic device. Exemplarily, all possible operating states of M applications in the electronic device can be obtained by traversal and stored in the electronic device. Then, the scheduling requirements of the key threads in each operating state are analyzed, and the scheduling configuration corresponding to each operating state is determined according to the scheduling requirements. Then, the first mapping relationship is generated in combination with the obtained multiple operating states and multiple scheduling configurations.

[0144] Exemplarily, the electronic device determines a first scheduling configuration based on the current first running state of the M applications and the AI ​​model. The AI ​​model can be a pre-trained model, or a model that is continuously updated as the electronic device is used. The AI ​​model can analyze the input first running state and output a first scheduling configuration that can meet the scheduling requirements of N types of threads in the first running state.

[0145] In some scenarios, when the running states of M applications on an electronic device change, the scheduling configuration will be adjusted accordingly to meet the scheduling requirements of N types of threads.

[0146] Exemplarily, the electronic device receives a first user operation, where the first user operation is used to adjust the running state of one or more of the M applications. Figure 3A As shown, the first user operation may be clicking icon 101. Before the user clicks icon 101, the "communication" application is not running. After the user clicks icon 101, the "communication" application is started. Fig. 6A As shown, the first user operation may also be clicking on the delete control 109. Before the user clicks on the delete control 109, multiple applications may be in an interactive state or a background state in the electronic device. After the user clicks on the delete control 109, the electronic device will allow one or more applications to enter the non-running carousel and display the following information: Figure 6B User interface 110 is shown.

[0147] After the electronic device executes the first user operation, the current running state of the M applications may be referred to as a second running state, as shown in Table 4.

[0148] Table 4

[0149] M applications Second operating state First Application Not running Second Application Background Status

[0150] The difference between the above Table 4 and Table 3 is that the first application in Table 3 is in the startup state, while the first application in Table 4 is in the background state.

[0151] A possible implementation manner is to determine the second scheduling configuration based on the current second running states of the M applications.

[0152] The second operating state and the second scheduling configuration may refer to the description of the first operating state and the first scheduling configuration, which will not be repeated here.

[0153] Table 5

[0154] Critical Threads Priority Priority run time Nuclear selection tendency Audio Thread 300 20ms Small core (non-IDLE-CPU) Rendering Thread 299 30ms Big core (non-IDLE-CPU) Main Thread 298 20ms Big core (non-IDLE-CPU) Animation Thread 297 40ms Big core (non-IDLE-CPU)

[0155] Table 1 above exemplifies possible implementations of the first scheduling configuration, and the N types of threads shown in Table 5 also include audio threads, rendering threads, main threads, and animation threads. Table 5 can be understood in conjunction with the descriptions of "priority", "priority running time", and "core selection tendency" above, so no further introduction is given here.

[0156] Since the first application is not running and the second application is in the background in the second running state shown in Table 4, the priority running time of the main thread can be appropriately reduced, which can save the running resources of the electronic device and improve the utilization rate of the running resources of the electronic device while meeting the scheduling requirements of the main thread. Therefore, the priority running time of the main thread in Table 5 is reduced relative to that in Table 1 (the priority running time of the main thread in Table 1 is 60ms, and the priority running time of the main thread in Table 5 is 20ms).

[0157] Exemplarily, the electronic device may determine the second scheduling configuration based on the current second operating state of the M applications and the first mapping table. The first mapping table is, for example, the first mapping table shown in Table 2. For the specific implementation of the electronic device determining the second scheduling configuration based on the second operating state and the first mapping table, reference may be made to the relevant description of the electronic device determining the first scheduling configuration based on the first operating state and the first mapping table, which will not be repeated here.

[0158] Exemplarily, the electronic device may also determine the second scheduling configuration based on the current second running states of the M applications, the operation type of the first operation, and the second mapping table.

[0159] Among them, the operation type of the first operation includes operations such as clicking, sliding, and zooming. In some scenarios, the operation type of the user operation may affect different threads. For example, the user's click operation can be used to indicate the launch of an application, enter a certain page, or indicate confirmation information. The user's sliding operation can be used to indicate adjusting the volume, starting multitasking, or exiting an application. Therefore, the configuration parameters of the thread can also be adjusted according to the operation type of the user operation. For example, when the operation type of the user operation is a "click" operation, the priority running time of the UI thread can be increased. For another example, when the operation type of the user operation is a "slide" operation, the priority of the animation thread can be increased so that the animation will not be stuck during the multitasking process. For another example, when the user's operation type is a "zoom" operation, the priority of the rendering thread can also be increased so that the image displayed by the user interface does not freeze during the zooming process.

[0160] Among them, the scheduling parameters of the N types of threads indicated by the second scheduling configuration are completely or partially different from those indicated by the first scheduling configuration. As shown in Tables 1 and 5, the situation where the scheduling parameters of the N types of threads indicated by the second scheduling configuration are partially different from those indicated by the first scheduling configuration is shown. Regarding the situation where the scheduling parameters of the N types of threads indicated by the second scheduling configuration are completely different from those indicated by the first scheduling configuration, it can be understood in combination with the impact of the above-mentioned running state on the scheduling configuration, and no examples are given here.

[0161] Next, a specific implementation of the second mapping relationship is exemplified, as shown in Table 6.

[0162] Table 6

[0163]

[0164] As shown in Table 6, the second mapping relationship is used to indicate the correspondence between multiple groups of state types and multiple scheduling configurations, wherein a group of state types consists of an operating state and an operation type of a user operation. For example, the first operating state and the operation type of "click" can be called a group of state types. For another example, the first operating state and the operation type of "slide" can also be called a group of state types. For another example, the second operating state and the operation type of "click" can also be called a group of state types.

[0165] Therefore, when determining the second operating state and the operation type of the first user operation, the second scheduling configuration can be uniquely determined from the multiple scheduling configurations based on the second mapping relationship. Exemplarily, depending on the operation type of the first user operation, the second scheduling configuration can be scheduling configuration 4, scheduling configuration 5, or scheduling configuration 6.

[0166] Exemplarily, the electronic device determines the second scheduling configuration based on the current second running state of the M applications, the operation type of the first operation, and the AI ​​model. The AI ​​model can be a pre-trained model, or a model that is continuously updated as the electronic device is used. The AI ​​model can analyze the input first running state and the operation type of the first operation, and output a second scheduling configuration that can meet the scheduling requirements of N types of threads in the second running state and the current operation type of the first operation.

[0167] Exemplarily, the electronic device determines the second scheduling configuration based on the current second running state of the M applications and the AI ​​model. The specific implementation process can refer to the above-mentioned description of the electronic device determining the first scheduling configuration based on the current first running state of the M applications and the AI ​​model, which will not be repeated here.

[0168] See also Figure 7 , Figure 7 It is a flowchart of a task scheduling method provided by the present application, including but not limited to S701-S708, as shown below:

[0169] S701. The electronic device determines a first scheduling configuration based on a first current running state of M applications.

[0170] Exemplarily, the kernel layer of the electronic device may determine the first scheduling configuration based on the current first running state of the M applications. Specifically, the priority scheduler of the kernel layer of the electronic device may determine the first scheduling configuration based on the current first running state of the M applications. The specific determination process can be referred to the above description, which will not be repeated here.

[0171] S702: The electronic device runs N types of threads based on a first scheduling configuration.

[0172] Exemplarily, the kernel layer of the electronic device may run the N-type threads based on the first scheduling configuration. Specifically, the priority scheduler of the kernel layer of the electronic device may run the N-type threads based on the first scheduling configuration.

[0173] For specific implementation, please refer to the above Figure 2 The description of related contents will not be repeated here.

[0174] S703, the electronic device receives a first user operation. The first user operation can be described in the above corresponding content, which will not be repeated here. After the electronic device performs the first user operation, the running state of the M applications is adjusted to the second running state, as shown in Table 4 above.

[0175] S704: The electronic device determines a second scheduling configuration based on the current second running states of the M applications.

[0176] Exemplarily, the kernel layer of the electronic device may determine the second scheduling configuration based on the current second running state of the M applications. Specifically, the priority scheduler of the kernel layer of the electronic device may determine the second scheduling configuration based on the current second running state of the M applications. The specific determination process can be referred to the above description, which will not be repeated here.

[0177] S705: The electronic device receives indication information requested by the target thread.

[0178] Specifically, when the target thread needs to be run, the target thread sends the requested indication information to the kernel layer of the electronic device, and provides the name, task type and other parameters of the target thread to the kernel layer of the electronic device.

[0179] S706: The electronic device determines whether the target thread is a critical thread.

[0180] When the electronic device receives the indication information of the target thread request, it determines whether the target thread belongs to the critical thread. Specifically, when the kernel layer of the kernel layer receives the indication information of the target thread request, it sends the relevant information of the target thread to the priority scheduler, and the priority scheduler determines whether the target thread belongs to the critical thread. For example, when one or more of the following judgment conditions are met, the target thread belongs to the critical thread.

[0181] Judgment method 1: The application executing the target thread is running in the foreground of the electronic device, and the target thread belongs to one of the following threads: main thread, rendering thread, animation thread, audio thread and customized key thread. For example, the user can customize the key thread through the human-computer interface.

[0182] Judgment method 2: The application executing the target thread is running in the background of the electronic device, and the target thread belongs to one of the following threads: audio thread, monitoring thread (including video monitoring, infrared monitoring, audio monitoring) and customized key thread. For example, the user can customize the key thread through the human-computer interface.

[0183] Judgment method three: the target thread belongs to a thread associated with an application of a specified type, for example, a thread associated with a game application or an application associated with a video application.

[0184] S707: When the target thread is a critical thread, the electronic device schedules the target thread with priority.

[0185] Exemplarily, the target thread may be preferentially scheduled by the kernel layer of the electronic device. Specifically, the target thread may be preferentially scheduled by the priority scheduler of the kernel layer of the electronic device. The implementation of the priority scheduling may refer to the above Figure 2 The implementation of the priority scheduling can also refer to the above S701-S702 or S703-S704.

[0186] When the electronic device completes the priority scheduling of the target thread, it will add the target thread to the queue maintained by the CFS scheduler and perform fair scheduling on the target thread. The specific implementation of fair scheduling can refer to the above Figure 2 The relevant description will not be repeated here.

[0187] S708: When the target thread is not a critical thread, the electronic device may perform fair scheduling on the target thread.

[0188] The specific implementation of fair scheduling can refer to the above Figure 2 The relevant description will not be repeated here.

[0189] Of course, when the target thread is not a critical thread, the target thread may also be idle scheduled according to the type of the target thread, and this application does not limit this.

[0190] In a possible implementation manner, the scheduling method provided in this application is not limited to the above Figure 7 For example, the execution steps are S705, S706, S707, S701, S702, S703, S704, and S708 in sequence.

[0191] In another possible implementation, during the process of scheduling the critical thread using the first scheduling parameter, if the running status of the M applications changes and the critical thread needs to be scheduled using the second scheduling parameter, the critical thread is scheduled using the second scheduling parameter.

[0192] For example, taking the main thread as an example, the first scheduling parameter determined based on the current first running state of the M applications indicates that the priority running time of the main thread is 20ms. During the process of the main thread being in priority running, the running state of the M applications changes (becomes the second running state), and the second scheduling parameter determined based on the second running state indicates that the priority running time of the main thread is 60ms, then the priority running time of the main thread of 60ms shall prevail.

[0193] See also Figure 8 , Figure 8 It is a flowchart of another task scheduling method provided by this application.

[0194] When the target thread is identified as a critical thread, the priority scheduler obtains the current usage scenario of the electronic device through the scenario recognition module, and then determines the scheduling configuration under the current usage scenario in combination with the preset N scheduling configurations, for example, scheduling configuration 1. Further, the priority scheduler schedules the target thread based on the scheduling parameters provided in scheduling configuration 1 for indicating the target thread.

[0195] The specific implementation of how the target thread is identified as a key thread may refer to the related description of S706 above, which will not be repeated here.

[0196] This application does not limit how the scene recognition module obtains the current usage scenario of the electronic device. For example, the current usage scenario of the electronic device can be determined by analyzing the current running status of M applications in the electronic device and / or the operation type of the user operation. Specifically, when the user operation instructs to start application A, the relevant thread responsible for application startup sends a first indication message that application A starts to start to the scene recognition module. When application A completes startup, the relevant thread responsible for application startup sends a second indication message that application A completes startup to the scene recognition module. Based on the first indication information and the second indication information, the scene recognition module can determine the time period when application A is in the startup state, and can refer to the usage scenario of the electronic device during this time period as an application startup scenario.

[0197] Scheduling configuration 1, scheduling configuration 2, ..., scheduling configuration N can be preset, and the priority scheduler can determine the scheduling configuration of the usage scenario based on the usage scenario identified by the scenario recognition module. For example, the usage scenario and the scheduling configuration can be mapped in a mapping table, and the scheduling configuration can be determined by querying the mapping table when the usage scenario is determined. The specific implementation can refer to the first mapping relationship and the second mapping relationship mentioned above, which will not be repeated here. Figure 8 The scheduling configuration shown in is also used to indicate the scheduling parameters of N types of threads, as shown in Table 1.

[0198] The priority scheduler then obtains the scheduling parameters corresponding to the target thread from the determined scheduling configuration in conjunction with the target thread, and performs priority scheduling on the target thread based on the scheduling parameters.

[0199] Figure 8 The task scheduling method shown can identify the current usage scenario of the electronic device, obtain the appropriate scheduling configuration under the usage scenario, and schedule the key threads based on the scheduling configuration, thereby meeting the scheduling requirements of the key threads in different usage scenarios, avoiding the lag of the electronic device, and providing user experience.

[0200] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

[0201] As used in the above embodiments, the term "when..." may be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...", depending on the context. Similarly, the phrases "upon determining..." or "if (the stated condition or event) is detected" may be interpreted to mean "if determining..." or "in response to determining..." or "upon detecting (the stated condition or event)" or "in response to detecting (the stated condition or event)", depending on the context.

[0202] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media integration. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc.

[0203] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.

Claims

1. A task scheduling method, the method being applied to an electronic device, characterized in that: include: The electronic device determines a first scheduling configuration based on the current first running states of the M applications, the first scheduling configuration indicating scheduling parameters of N types of threads on the first electronic device, M and N being positive integers; wherein the first running state belongs to one of multiple running states, the first scheduling configuration belongs to one of multiple scheduling configurations, different running states correspond to different scheduling configurations, and the first running state corresponds to the first scheduling configuration; The electronic device runs the N type of threads based on the first scheduling configuration.

2. The method according to claim 1, characterized in that The electronic device determines a first scheduling configuration based on the current first running states of the M applications, including: The electronic device determines the first scheduling configuration based on the first current running states of the M applications and a preset first mapping relationship, where the first mapping relationship indicates a correspondence between the multiple running states and the multiple scheduling configurations.

3. The method according to claim 1 or 2, characterized in that: The method further comprises: receiving a first user operation, where the first user operation is used to adjust the running state of one or more of the M applications; The electronic device determines a second scheduling configuration based on the second current running state of the M applications and / or the operation type of the first user operation, wherein the scheduling parameters of the N types of threads indicated by the first scheduling configuration and the second scheduling configuration are partially or completely different; The electronic device runs the N type of threads based on the second scheduling configuration.

4. The method according to claim 3, characterized in that The electronic device determines a second scheduling configuration based on the current second running states of the M applications and the operation type of the first user operation, including: The electronic device determines the second scheduling configuration based on the second operating state, the operation type of the first user operation and a preset second mapping relationship; the second mapping relationship indicates the correspondence between multiple groups of state types and multiple scheduling configurations, wherein one group of state types includes an operating state and an operation type of user operation, and different groups of state types correspond to different scheduling configurations.

5. The method according to any one of claims 1 to 4, characterized in that: The method further includes receiving indication information of a thread request, the indication information being used to indicate the thread requested to run; The electronic device determines a first scheduling configuration based on the current first running states of the M applications, including: When it is determined that the thread requested to be run belongs to the N types of threads, the electronic device determines the first scheduling configuration based on the running states of the M application programs.

6. The method according to any one of claims 1 to 5, characterized in that: The first scheduling configuration includes a first scheduling parameter, the N types of threads include a first thread, and the first scheduling parameter is used to schedule the first thread; the method further includes: When the running states of the M applications remain unchanged and the electronic device completes running the first thread based on the first scheduling parameter, the electronic device performs fair scheduling on the first thread.

7. The method according to any one of claims 1 to 6, characterized in that: The scheduling parameters include one or more of the following: task level, priority running time or core selection tendency; Among them, the task level is used to determine the scheduling order of the target task, the priority running time is used to indicate the time to prioritize the running of the target task, and the core selection tendency is used to indicate the type of processor running the target task and / or the status of the processor.

8. The method according to any one of claims 1 to 7, characterized in that: The running state includes a non-running state, a starting state, an interactive state and a background state.

9. The method according to any one of claims 1 to 8, characterized in that: The N types of threads include one or more of the following: a main thread, a rendering thread, an audio thread, a motion effect thread, and a custom thread.

10. An electronic device, characterized in that: The electronic device comprises: a display screen, a memory, and a processor coupled to the memory; the display screen is used to display an interface, the memory stores a computer program, and when the processor executes the computer program, the electronic device implements the method as described in any one of claims 1 to 9.

11. A computer-readable storage medium comprising computer instructions, characterized in that: When the computer instructions are executed on an electronic device, the electronic device is caused to execute the method as claimed in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Process creation method for mobile communication terminal and mobile communication terminal

    CN106020957A

  • Resource allocation method, mobile terminal and computer readable storage medium

    CN107402813A

  • Task scheduling method and device, storage medium and electronic equipment

    CN113495780A

  • Task scheduling method and device and electronic equipment

    CN113535340A

  • Application program process control method and device, computer equipment and storage medium

    CN114116405A