Task scheduling method and electronic device

WO2026056682A1PCT designated stage Publication Date: 2026-03-19HUAWEI TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2025-08-27
Publication Date
2026-03-19

AI Technical Summary

Technical Problem

Electronic devices are prone to frame drops under high load scenarios, and existing technologies struggle to effectively reduce power consumption while optimizing performance.

Method used

When the first running unit meets the migration conditions and the second running unit is in a sleep state, the second running unit is woken up first and task scheduling is performed to migrate the first thread from the first running unit to the second running unit. The performance of the second running unit is better or worse than that of the first running unit.

Benefits of technology

It effectively shortens the thread pause time caused by task scheduling, optimizes system performance, reduces the probability of frame drops, and reduces the power consumption of electronic devices when the load is low.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025117294_19032026_PF_FP_ABST
    Figure CN2025117294_19032026_PF_FP_ABST
Patent Text Reader

Abstract

A task scheduling method and an electronic apparatus. The method comprises: when a first thread running on a first running unit satisfies a migration condition and a second running unit is in a sleep state, performing a wake-up operation on the second running unit, wherein the first running unit and the second running unit have different performance levels, and the migration condition comprises: the load of the first running unit in a first time period being greater than or equal to an expected load; and upon performing the wake-up operation on the second running unit, performing a task scheduling operation, wherein the task scheduling operation is used for scheduling a task of the first thread from the first running unit to the second running unit. The present application can optimize a task scheduling mechanism by balancing performance and power consumption, and reduce the waiting time after the first thread is interrupted, such that a processing unit can not only quickly respond to a system performance requirement, but also effectively reduce the power consumption of the electronic device when the load is low.
Need to check novelty before this filing date? Find Prior Art

Description

Task scheduling method and electronic device

[0001] The present application claims priority to the Chinese patent application No. 202411299871.8, filed on September 14, 2024, and entitled "Task scheduling method and electronic device", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD

[0002] The present application relates to the field of electronic devices, in particular to a task scheduling method and an electronic device. BACKGROUND

[0003] How to reduce the problem of frame loss often encountered by electronic devices in use has always been a difficult point of system performance optimization. Especially in the face of some high-sensitive scenarios, such as click operation in game scenario, drag-and-drop operation in map navigation, sliding operation in shopping platform, etc., the electronic device often causes frame loss due to high load of user interface (UI). SUMMARY

[0004] The present application provides a task scheduling method and an electronic device, which can optimize the mechanism of task scheduling, and balance performance and power consumption, so that the running unit can quickly respond to the performance requirements of the system, avoid frame loss caused by high load of the electronic device, and effectively reduce the power consumption of the electronic device when the load is low.

[0005] In a first aspect, the present application provides a task scheduling method, which is applied to an electronic device and includes: performing a wake-up operation on a second running unit when a first thread running on a first running unit meets a migration condition and the second running unit is in a sleep state, the first running unit and the second running unit having different performances, the migration condition including that a load of the first running unit in a first time period is greater than or equal to an expected load; and performing a task scheduling operation after performing the wake-up operation on the second running unit, the task scheduling operation being used to schedule tasks of the first thread from the first running unit to the second running unit.

[0006] Based on the above technical solution, when the first thread is about to be migrated and the second running unit is in the sleep state, the task scheduling of the first thread is not immediately performed, but the second running unit is preferentially woken up. This makes the tasks of the first thread currently running on the first running unit continue to be executed, prevents the first thread from being paused too early and causing a long waiting time, and further causes the electronic device to be stuck. Therefore, the time length of the pause of the first thread caused by the task scheduling can be effectively shortened, which helps to optimize the system performance and reduce the frame loss probability. At the same time, the second running unit can be kept in the sleep state when it is not needed to run, which helps to reduce the power consumption of the electronic device.

[0007] In some possible implementation manners, the migration condition can be that the task amount of the first running unit in the first time period is greater than or equal to the expected task amount, or the running duration of the first running unit in the first time period is greater than or equal to the preset running duration.

[0008] With reference to the first aspect, in some implementation manners of the first aspect, the task scheduling operation is performed after the wake-up operation is performed on the second running unit, and the task scheduling operation comprises: performing the task scheduling operation in a case where the second running unit is woken up.

[0009] Based on the above technical solution, the task scheduling operation is performed in a case where the second running unit is woken up. Since the second running unit has been woken up in priority, after the task scheduling operation is performed, the task of the first thread can be directly migrated to the second running unit, without waiting for the second running unit to be woken up. Therefore, the duration of the suspension of the first thread caused by the task scheduling is effectively shortened, and only includes the duration of the migration of the first thread from the first running unit to the second running unit. This helps to optimize the system performance and reduce the frame loss probability, thereby improving the user experience.

[0010] With reference to the first aspect, in some implementation manners of the first aspect, the task scheduling operation is performed after the wake-up operation is performed on the second running unit, and the task scheduling operation comprises: performing the task scheduling operation after a first preset duration from when the wake-up operation is performed on the second running unit.

[0011] Based on the above technical solution, the task scheduling of the first thread is triggered after the first preset duration, which can effectively avoid the case where the second running unit is woken up, but the task of the first thread is not migrated from the first running unit to the second running unit. Therefore, based on the method provided in some embodiments of the present application, the case where the first thread is not migrated due to system failure, blocking and waiting, and the like can be effectively avoided, which is conducive to the smooth migration of the first thread.

[0012] With reference to the first aspect, in some implementation manners of the first aspect, the method further comprises: determining the first preset duration according to the sleep state of the second running unit.

[0013] Based on the technical solution, the sleep state of the second running unit helps to set a more reasonable first preset time length. On the one hand, it can effectively prevent the first preset time length from being too short, which makes the second running unit not fully woken up when performing the task scheduling operation, resulting in the first thread being suspended for too long and causing the electronic device to lag. On the other hand, it can also effectively prevent the first preset time length from being too long, which makes the second running unit wake up for a long time but still not perform the task scheduling operation, resulting in power waste. By setting a reasonable first preset time length, the second running unit can be woken up and the first thread can be scheduled in time, which is beneficial to optimize the system performance and reduce the power waste of the second running unit.

[0014] In combination with the first aspect, in some implementations of the first aspect, the wake-up operation on the second running unit comprises: creating a second thread, the second thread being used to wake up the second running unit; and migrating the second thread to the second running unit; the method further comprises: destroying the second thread after waking up the second running unit.

[0015] In combination with the first aspect, in some implementations of the first aspect, the second thread is an empty thread.

[0016] Based on the technical solution, since the empty thread does not need to perform any actual work and can be created and scheduled in a very short time, it can quickly wake up the second running unit. In addition, the empty thread usually only occupies very few system resources when executing on the second running unit, and does not need to allocate a large amount of memory and processing resources, which can improve the overall performance and response speed of the electronic device, and help to migrate the task of the first thread to the second running unit as soon as possible.

[0017] In combination with the first aspect, in some implementations of the first aspect, the wake-up operation on the second running unit comprises: migrating a third thread to the second running unit, the third thread being a resident thread under a system process, and the third thread being used to wake up the second running unit.

[0018] Based on the technical solution, the overhead of frequently creating and destroying threads can be effectively reduced, which saves resources and improves the system's ability to quickly handle sudden events.

[0019] In a second aspect, the present application provides a task scheduling method. The method is applied to an electronic device and includes: running a first thread on a small core, the small core being a running unit of a processor of the electronic device; performing a wake-up operation on a large core when the first thread meets a migration condition and the large core is in a sleep state, the large core being another running unit of the processor, the large core having a performance superior to that of the small core, and the migration condition including that a task amount of the small core in a first time period is greater than or equal to an expected task amount or a running time length of the small core in the first time period is greater than or equal to a preset running time length; and performing a task scheduling operation after the wake-up operation on the large core, the task scheduling operation being used to schedule tasks of the first thread from the small core to the large core.

[0020] Based on the above technical solution, when the first thread is about to be migrated and the large core is in the sleep state, the task scheduling of the first thread is not immediately performed, but the large core is preferentially woken up. This makes the tasks of the first thread currently running on the small core continue to be executed, prevents the first thread from being paused too early and causing a long waiting time length, and further causes the electronic device to be stuck. Therefore, the time length of the pause of the first thread caused by the task scheduling can be effectively shortened, which helps to optimize the system performance and reduce the frame loss probability. Meanwhile, the large core can be kept in the sleep state when the large core does not need to run, which helps to reduce the power consumption of the electronic device.

[0021] In combination with the second aspect, in some implementations of the second aspect, the performing of the task scheduling operation after the wake-up operation on the large core includes: performing the task scheduling operation in a case where the large core is woken up.

[0022] Based on the above technical solution, the task scheduling operation is performed in the case where the large core is woken up. Since the large core has been preferentially woken up, after the task scheduling operation is performed, the tasks of the first thread can be directly migrated to the large core without waiting for the large core to be woken up. Therefore, the time length of the pause of the first thread caused by the task scheduling is effectively shortened, and only includes the time length of the migration of the first thread from the small core to the large core. This helps to optimize the system performance, reduce the frame loss probability, and thus improve the user experience.

[0023] In combination with the second aspect, in some implementations of the second aspect, the performing of the task scheduling operation after the wake-up operation on the large core includes: performing the task scheduling operation after a first preset time length from the wake-up operation on the large core.

[0024] Based on the above technical solution, the task scheduling of the first thread is triggered after the first preset time length, which can effectively avoid the case where the large core is woken up but the first thread is delayed in migrating from the small core to the large core. Therefore, based on the method provided by some embodiments of the present application, the case where the first thread is not migrated due to system failure, blocked waiting, or the like can be effectively avoided, which is beneficial to the smooth migration of the first thread.

[0025] With reference to the second aspect, in some implementations of the second aspect, the method further includes determining the first preset time period according to a sleep state of the big core.

[0026] Based on the above technical solution, determining the first preset time period according to the sleep state of the big core helps to set a more reasonable first preset time period. On the one hand, it can effectively prevent the first preset time period from being too short, which makes the big core not fully wake up when performing the task scheduling operation, resulting in the first thread being suspended for too long and causing the electronic device to freeze. On the other hand, it can also effectively prevent the first preset time period from being too long, which makes the big core wake up for a long time but still not perform the task scheduling operation, resulting in power waste. By setting a reasonable first preset time period, the big core can be timely scheduled for the first thread after waking up, which is conducive to optimizing system performance and reducing power waste of the big core.

[0027] With reference to the second aspect, in some implementations of the second aspect, performing the wake-up operation on the big core includes: creating a second thread, the second thread being used to wake up the big core; and migrating the second thread to the big core; the method further includes: after waking up the big core, destroying the second thread.

[0028] With reference to the second aspect, in some implementations of the second aspect, the second thread is an empty thread.

[0029] Based on the above technical solution, since the empty thread does not need to perform any actual work and can be created and scheduled in a very short time, it can quickly wake up the big core. In addition, the empty thread usually only occupies very few system resources when executed on the big core, and does not need to allocate a large amount of memory and processing resources, which can improve the overall performance and response speed of the electronic device, and help to migrate the task of the first thread to the big core for execution as soon as possible.

[0030] With reference to the second aspect, in some implementations of the second aspect, performing the wake-up operation on the big core includes: migrating a third thread to the big core, the third thread being a resident thread under a system process, the third thread being used to wake up the big core.

[0031] Based on the above technical solution, the overhead of frequently creating and destroying threads can be effectively reduced, which saves resources and is conducive to improving the system's ability to quickly handle sudden events.

[0032] In some implementations based on the first aspect or the second aspect, the migration condition of the method can also be described from the dimension of the scenario. For example, the application corresponding to the first thread is a gallery including a long list interface, a news software, or a shopping software. The long list interface can be a multi-image browsing interface of the gallery, or the long list interface can be a picture-text browsing interface of the news software, or the long list interface can be a card browsing interface of the shopping software, and each card can correspond to a commodity. For example, the migration condition can include that the multi-image browsing interface, the picture-text browsing interface, or the card browsing interface is in a sliding scenario.

[0033] For another example, the application corresponding to the first thread is a map application. The migration condition can include that the map application is in a scenario where a map is zoomed in or zoomed out.

[0034] In a third aspect, the present application provides an electronic device, including one or more processors, one or more memories, and one or more computer programs. The one or more computer programs are stored in the one or more memories, and include instructions which, when executed by the one or more processors, cause the electronic device to perform any of the methods in the first aspect or the second aspect.

[0035] In a fourth aspect, the present application provides an electronic device including units or modules for performing any of the methods in the first aspect or the second aspect.

[0036] In a fifth aspect, the present application provides a chip including circuitry for performing any of the methods in the first aspect or the second aspect.

[0037] In a sixth aspect, the present application provides a readable storage medium having instructions stored therein, and when the instructions are run on an electronic device, the electronic device performs any of the methods in the first aspect or the second aspect.

[0038] In a seventh aspect, the present application provides a program product, and when the program product is run on an electronic device, the electronic device performs any of the methods in the first aspect or the second aspect. BRIEF DESCRIPTION OF DRAWINGS

[0039] FIG. 1 is a structural schematic diagram of an electronic device according to an embodiment of the present application;

[0040] FIG. 2 is a software structure block diagram of an electronic device according to an embodiment of the present application;

[0041] FIG. 3 is a schematic diagram of a big-little heterogeneous processor according to an embodiment of the present application;

[0042] FIG. 4 is a schematic diagram of task scheduling.

[0043] FIG. 5 is a schematic flowchart of a task scheduling method according to an embodiment of the present application;

[0044] FIG. 6 is a schematic flowchart of a wake-up method according to an embodiment of the present application;

[0045] FIG. 7 is a schematic flowchart of a task scheduling method according to an embodiment of the present application;

[0046] FIG. 8 is a schematic diagram of a task scheduling according to an embodiment of the present application;

[0047] FIG. 9 is a schematic diagram of an architecture of a software unit according to an embodiment of the present application;

[0048] FIG. 10 is a schematic diagram of an architecture of a software unit according to an embodiment of the present application;

[0049] FIG. 11 is a schematic diagram of a process of a task scheduling method according to an embodiment of the present application;

[0050] FIG. 12 is a schematic flowchart of a wake-up method according to an embodiment of the present application;

[0051] FIG. 13 is a schematic diagram of a life cycle of a third thread according to an embodiment of the present application;

[0052] FIG. 14 is a schematic diagram of a task scheduling according to an embodiment of the present application;

[0053] FIG. 15 is a schematic diagram of a task scheduling according to an embodiment of the present application;

[0054] FIG. 16 is a schematic flowchart of a task scheduling method according to an embodiment of the present application. DETAILED DESCRIPTION

[0055] The technical solutions in the present application will be described below with reference to the drawings. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments.

[0056] The method in some embodiments of the present application can be applied to electronic devices such as smartphones, tablet computers, notebook computers, personal computers (PCs), ultra-mobile personal computers (UMPCs), netbooks, in-vehicle devices, smart TVs, wearable devices, foldable devices, internet of things (IOT) devices, etc.

[0057] FIG. 1 shows a structural schematic diagram of an electronic device 100. The electronic device 100 can 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 antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone interface 170D, a sensor module 180, a key 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 can include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0058] It can be understood that the structure shown in the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can include more or fewer components than shown, or combine certain components, or split certain components, or different arrangement of components. The components shown can be implemented by hardware, software, or a combination of software and hardware.

[0059] The processor 110 can include one or more processing units, for example: the processor 110 can include an application processor (AP), a modem processor, a graphics processing unit (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 can be independent devices, or can be integrated in one or more processors.

[0060] The processor 110 can also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory can hold instructions or data that the processor 110 has just used or is using in a loop. If the processor 110 needs to use the instructions or data again, it can be called directly from the memory. This avoids repeated access and reduces the waiting time of the processor 110, thus improving the efficiency of the system.

[0061] In some embodiments, the processor 110 can include one or more interfaces. The interfaces can include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus interface, etc.

[0062] In the embodiments of the present application, the processor 110 can include running units with different performance. For example, the processor 110 includes a first running unit and a second running unit, and the performance of the second running unit is better than that of the first running unit. For example, the processor 110 includes a large core and a small core, and the performance of the large core is better than that of the small core.

[0063] It can be understood that the interface connection relationship between the modules shown in the embodiments of the present application is only illustrative and does not constitute a structural limitation of the electronic device 100. In other embodiments of the present application, the electronic device 100 can also use different interface connection methods or a combination of multiple interface connection methods in the above embodiments.

[0064] FIG. 2 is a software structure diagram of the electronic device 100 according to an embodiment of the present application. The layered architecture divides the software into several layers, each layer has a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the operating system is divided into four layers, from top to bottom, into an application layer, an application framework layer, a system library, and a kernel layer. The application layer can include a series of application packages.

[0065] As shown in FIG. 2, the application package can include applications (Apps) such as a camera, a gallery, a calendar, a call, a map, a navigation, a WLAN, a Bluetooth, music, a video, a short message, a wallet, etc.

[0066] The application framework layer provides an application programming interface (API) and a programming framework for the applications of the application layer. The application framework layer includes some predefined functions.

[0067] As shown in FIG. 2, the application framework layer can include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, etc.

[0068] The window manager is used to manage window programs. The window manager can acquire a display screen size, determine whether there is a status bar, lock a screen, and capture a screen, etc.

[0069] The content provider can be used to store and acquire data, and make the data accessible by the applications. The data can include videos, pictures, audios, dialed and received calls, browsing history and bookmarks, a phonebook, etc.

[0070] The view system includes visual controls, such as a control for displaying text, a control for displaying pictures, etc. The view system can be used to build an application. A display interface can be composed of one or more views. For example, a display interface including a short message notification icon can include a view for displaying text and a view for displaying pictures.

[0071] The phone manager is used to provide a communication function of the electronic device 100. For example, management of a call state (including call connection, call hang-up, etc.).

[0072] The resource manager provides various resources for the applications, such as localized strings, icons, pictures, layout files, video files, etc.

[0073] The notification manager makes the applications display notification information in a status bar, which can be used to convey a message of the notification type, which can automatically disappear after a short stay without user interaction. For example, the notification manager is used to notify a download completion, a message reminder, etc. The notification manager can also be a notification appearing in a system top status bar in a form of a graph or a scroll bar text, for example, a notification of an application running in the background, and can also be a notification appearing on a screen in a form of a dialogue window. For example, a text information is prompted in a status bar, a prompt sound is emitted, the electronic device is vibrated, a light flashes, etc.

[0074] The application program layer and the application framework layer run in the virtual machine. The virtual machine is used to perform functions such as management of the object life cycle, stack management, thread management, management of security and exceptions, and garbage collection.

[0075] The kernel layer is a layer between hardware and software. The kernel layer at least includes display drivers, camera drivers, audio drivers, and sensor drivers.

[0076] Hereinafter, the terms "first" and "second" are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with "first" and "second" can explicitly or implicitly include one or more of the features. In the description of the embodiments, unless otherwise specified, the meaning of "a plurality of" is two or more.

[0077] In the embodiments of the present application, the "first running unit" and the "second running unit" can cover hardware, software, or a combination of both. In terms of hardware, it includes but is not limited to a processor core, an application-specific integrated circuit (ASIC), or other hardware components responsible for performing specific computing tasks. In terms of software, it includes but is not limited to a process or a service responsible for processing specific data or executing specific algorithms. In terms of the combination of software and hardware, it includes but is not limited to a module in an embedded system, which contains both hardware circuits and software that controls the hardware.

[0078] In today's electronic device field, users show great diversity in the use mode of electronic devices. Users of these electronic devices can perform various operations at any time point, from simple page browsing to complex game operations, and the diversity and unpredictability of tasks require the operating system to have highly flexible scheduling capabilities. Therefore, the task scheduling in the operating system should adapt to the randomness of user behavior and the volatility of task demand. Especially in some high-sensitive scenarios, such as click operations in game scenarios, drag-and-drop operations in real-time navigation, and sliding operations in shopping platforms, these scenarios often require high response speed of interaction.

[0079] However, high-sensitive scenarios often lead to the problem of stuttering and frame loss due to high UI load. According to statistics, the proportion of such problems in dynamic performance models is more than 70%. Therefore, how to optimize the stuttering and frame loss problem caused by high-sensitive scenarios has become a hot spot in the industry.

[0080] Currently, there are methods that use different specifications of processing units in the system to solve the problem of frame loss. Taking the central processing unit (CPU) core as an example, there is a solution to the frame loss problem in high-sensitivity scenarios using a large-core heterogeneous processor. Next, to facilitate the reader's understanding of such solutions, related technical terms are explained:

[0081] 1. CPU is one of the core components of computer hardware, responsible for executing instructions in computer programs, controlling data flow, and handling various calculations. CPU can be regarded as the "brain" of the computer, and other hardware of the computer works through it to coordinate work.

[0082] 2. CPU core is the core part of the central processing unit, responsible for executing computing tasks.

[0083] 3. Multi-core processor is a central processing unit that integrates multiple independent CPU cores, each of which is an independent and complete processor that can execute instructions, manage data, and perform computing tasks. The design of multi-core processors aims to improve the overall performance of the processor by executing multiple tasks in parallel to speed up calculations.

[0084] 4. Homogeneous multi-core processor is a multi-core processor that integrates the same type of CPU cores on the same chip. These CPU cores can have similar architecture, clock frequency, and performance characteristics. The architecture of homogeneous multi-core processors is often used for tasks that require better parallel processing capabilities.

[0085] 5. Heterogeneous multi-core processor is a multi-core processor that integrates different types of CPU cores on the same chip. These CPU cores can have different architectures, clock frequencies, and performance characteristics. The design goal of this heterogeneous multi-core processor is to combine different types of CPU cores together to make the processor better adapt to different types of tasks.

[0086] 6. Big-little heterogeneous processor: A big-little heterogeneous processor is a kind of heterogeneous multi-core processor, which generally includes two types of CPU cores: performance cores and efficiency cores. Among them, the performance core can also be called "big core", which is used to provide high-performance CPU cores with higher clock frequency and stronger computing power, and is suitable for processing tasks that require high computing power. The efficiency core can also be called "little core", which has relatively low performance and is a low-power CPU core, suitable for lightweight tasks. As "performance cores", not every CPU core is exactly the same, and similarly, as "efficiency cores", there can be differences between them. In some cases, efficiency cores can be further divided into "medium cores" and "small cores" according to their processing power to reflect the performance levels of different cores. At present, big-little heterogeneous processors are widely used in the field of computers, and through high-performance big cores and high-efficiency small cores, performance optimization in high-sensitivity scenarios is achieved.

[0087] Figure 3 is a schematic diagram of a big-little heterogeneous processor provided by an embodiment of the present application. As shown in Figure 3, the processor includes 2 big cores and 6 small cores. It also includes a last level cache (LLC) processor, a memory controller, and an input / output (I / O) interface. Among them, the memory controller can send control instructions to indicate the CPU core and the last level cache processor to exchange data, and then complete the corresponding task.

[0088] In a big-little heterogeneous processor, the operating system generally allocates tasks to big cores or small cores according to the following information: information provided by the application, observation of the application workload, or observation of the entire electronic device system. For example, when the electronic device runs background tasks or performs lightweight tasks on a daily basis, the load of the processor is low. The small core can take over the above-mentioned tasks, and the big core is in an idle state; when the electronic device needs a large amount of data processing and analysis, runs high-performance applications, processes multiple complex tasks, or performs high-traffic network activities, the load of the processor is high. At this time, the electronic device will allocate the above-mentioned complex tasks to the big core.

[0089] In some power-saving scenarios, since the processor load is low, tasks are mainly concentrated on small cores, and big cores are idle for a long time. In order to reduce the power consumption of the CPU when the big core is idle, the big core can enter a sleep state.

[0090] The sleep state can be achieved by setting different levels of C-state. The C-state has C0, C1, C2, … Cn states, and n is a positive integer greater than 2. Among them, the C0 state represents the normal working state of the running unit. The remaining states correspond to different sleep states, and the larger the number after C, the deeper the sleep state, the less power consumption, and the less heat generated. Generally, the C1 state and the C2 state are regarded as shallow sleep states: the C1 state can include stopping the main internal clock or reducing the voltage, and the C2 state can include stopping the main internal clock, stopping the external clock, or reducing the voltage. The C1 state and the C2 state can keep the bus interface unit (BIU) and the advanced programmable interrupt controller (APIC) running at full speed, so that the large core can quickly respond to external interrupts. The C3 state and the settings above it can be regarded as deep sleep states: the C3 state can include turning off all internal clocks, external clocks, BIUs, and APICs, which means that the large core cannot respond to external important requests. The C4 state includes further reducing the voltage on the basis of the C3 state. Therefore, the large core entering the sleep state needs to be awakened to handle the task of sudden load. However, due to the long time of the large core to wake up, it may affect the performance of the electronic device.

[0091] FIG. 4 shows a schematic diagram of task scheduling. As shown in FIG. 4, when the thread running on the small core meets the migration condition and the large core is in the sleep state, the task scheduling operation of the thread is immediately performed, preparing to migrate the thread from the small core to the large core. At this time, the thread running on the small core is immediately paused. However, since the large core is in the sleep state, the clock is almost completely turned off, and the voltage is greatly reduced. Therefore, the task scheduling operation of the thread needs to wait for the large core to restart and recover to the normal working state before migrating the thread to the large core. The process from performing the task scheduling operation to the successful migration of the thread generally takes a long time. In a specific embodiment, the time for the CPU core in the electronic device to recover from the C3 state to the C0 state is about 750us, and the time for the thread to migrate from the small core to the large core is about 50us. Therefore, the first thread can continue to run about 800us after being paused. This long delay time will have a negative impact on the overall performance of the system, which can be manifested in the following two aspects:

[0092] (1) Performance degradation: the long wake-up time of the large core will cause task scheduling delay. That is, the large core cannot handle tasks in time, which will reduce the response speed and processing capacity of the electronic device.

[0093] (2) Frame loss probability increases: In a high-sensitivity scenario, a longer task scheduling delay can cause the big core to fail to keep up with the demand of the electronic device. When the processing time of a frame is too long, the time of some frames after it is delayed, causing delay accumulation. In order to ensure real-time performance, the electronic device can skip the delayed frame to display the latest frame, which leads to frame loss. Frame loss can seriously affect the user experience.

[0094] In one solution, the big core can be prevented from entering the C3 state when a specific use scenario is identified, so that it can be quickly awakened or directly migrated when needed. For example, when the electronic device identifies a high-sensitivity scenario, the big core can remain in a normal working state, thereby avoiding a 800us wake-up time. However, this method still has two defects:

[0095] (1) High-sensitivity scenario misjudgment. With the diversification of application scenarios, it is difficult to completely guarantee the accurate identification of high-sensitivity scenarios by the electronic device. If the electronic device fails to identify a high-sensitivity scenario, the big core will still enter the C3 state, leading to performance degradation and increased frame loss probability.

[0096] (2) Power waste. The original intention of allowing the big core to enter the C3 state is to reduce the power consumption of the CPU when it is idle. Therefore, if the big core is not allowed to enter the C3 state for a long time and fails to process any tasks, unnecessary power waste will occur. According to data, in the scenario of sliding operation on a shopping platform, the big core not entering the C3 state will increase the power consumption by about 3%. In the long run, increased power consumption not only adversely affects battery life, but also causes the electronic device to generate more heat, leading to more hardware wear and tear. Both power consumption and heat dissipation are important factors affecting user experience. In a continuous high-power consumption state, the endurance and comfort of the electronic device will be affected.

[0097] Embodiments of the present application provide a task scheduling method and an electronic device, which can optimize the mechanism of task scheduling, and balance performance and power consumption, so that the running unit can quickly respond to the performance requirements of the system and avoid frame loss caused by high load of the electronic device, and can effectively reduce the power consumption of the electronic device when the load is low.

[0098] FIG. 5 is a schematic flowchart of a task scheduling method 500 provided by an embodiment of the present application. The method 500 includes:

[0099] Step S5001, when a first thread running on a first running unit meets a migration condition and a second running unit is in a sleep state, performing a wake-up operation on the second running unit, the first running unit and the second running unit having different performance, the migration condition including: the load of the first running unit in a first time period being greater than or equal to an expected load.

[0100] The first thread can refer to a thread that is currently being executed on the first running unit and is to be scheduled to continue execution on the second running unit due to a scheduling decision.

[0101] It should be noted that determining that the first thread meets the migration condition and determining that the second running unit is in the sleep state are not in a specific order. For example, the first thread can be determined to meet the migration condition first, and then the second running unit is determined to be in the sleep state. Alternatively, the first thread can be determined to meet the migration condition and the second running unit can be determined to be in the sleep state at the same time.

[0102] For example, the performance of the first running unit can be better than the performance of the second running unit, or the performance of the second running unit can be better than the performance of the first running unit.

[0103] The migration condition can be a predefined condition or a set of conditions. For example, the migration condition can be that the load of the first running unit in a first time period is greater than or equal to an expected load. For example, the length of the first time period can be 1 minute, and the load of the first running unit is maintained at more than 85% for 1 minute, which is much higher than the expected load of 65%. This indicates that the processing capacity of the first running unit is insufficient to meet the current task demand, and the first thread needs to be migrated to the second running unit for subsequent processing.

[0104] For example, the migration condition can be that the amount of tasks of the first running unit in the first time period is greater than or equal to an expected amount of tasks, or the running time of the first running unit in the first time period is greater than or equal to a preset running time.

[0105] In actual applications, the migration condition can be different according to different system designs, performance targets, power consumption limits, and the like. The migration condition is not limited in the present application. Once the predefined migration condition is met, the electronic device defaults that the first thread is to be migrated.

[0106] When the first thread meets the migration condition and the second running unit is in the sleep state, the second running unit is preferentially woken up. The sleep state refers to a low-power working state of the second running unit. The wake-up operation performed on the second running unit can make it return to a normal working state so that it can execute tasks.

[0107] Optionally, the wake-up operation performed on the second running unit includes: creating a second thread, the second thread being used to wake up the second running unit; and migrating the second thread to the second running unit. Optionally, the method further includes: destroying the second thread after the second running unit is woken up. As shown in FIG. 6, an exemplary flowchart of a wake-up method 600 provided by an embodiment of the present application. The method 600 includes:

[0108] Step S6001, creating a second thread.

[0109] Step S6002, when the first thread meets the migration condition and the second running unit is in a sleep state, starting an operation of waking up the second running unit.

[0110] Step S6003, migrating the second thread to the second running unit.

[0111] Optionally, the second thread can be an idle thread. Since the idle thread does not need to perform any actual work and can be created and scheduled in a very short time, it can achieve fast wake-up of the second running unit. In addition, the idle thread usually only occupies very few system resources when executing on the second running unit, and does not need to allocate a large amount of memory and processing resources, which can improve the overall performance and response speed of the electronic device, and help to migrate the task of the first thread to the second running unit as soon as possible.

[0112] Step S6004, after the second thread is successfully migrated, sending a wake-up feedback message.

[0113] In some examples, the wake-up feedback message is used to indicate that the second running unit is successfully woken up.

[0114] Step S6005, destroying the second thread. Please refer to FIG. 6, this step is exemplified by a dashed line in the figure.

[0115] Optionally, the wake-up operation performed on the second running unit includes: migrating a third thread to the second running unit, the third thread being a resident thread under a system process, the third thread being used to wake up the second running unit. For example, after waking up the second running unit, the third thread is paused.

[0116] For example, the third thread can be created when the electronic device is powered on. Based on the method provided by some embodiments of the present application, the overhead of frequently creating and destroying threads can be effectively reduced, which is beneficial to improving the rapid processing capability of the system to sudden events while saving resources.

[0117] Optionally, the third thread can be an idle thread.

[0118] Step S5002, after performing the wake-up operation on the second running unit, performing a task scheduling operation, the task scheduling operation being used to schedule the task of the first thread from the first running unit to the second running unit.

[0119] It should be noted that when the task scheduling operation starts to be executed, the first thread running on the first running unit can be immediately paused, preparing for the following migration work. Specifically, the task scheduling operation step on the first thread can include:

[0120] (1) pause the first thread: pause the first thread running on the first running unit, to ensure that no changes occur during saving the context of the first thread;

[0121] (2) save the context of the first thread: immediately save the context of the first thread after the first thread is paused, including the content of the register, the program counter, the stack pointer, etc.;

[0122] (3) context transmission of the first thread: transmit the saved context of the first thread from the first running unit to the second running unit, to ensure that the context of the first thread is completely transmitted. In some embodiments, the first running unit saves the context of the first thread in a shared storage device;

[0123] (4) cache consistency processing: achieve cache consistency of the first running unit and the second running unit, to avoid data errors;

[0124] (5) resume the running of the first thread: resume the running of the first thread on the second running unit, and the first thread continues to execute from the paused place.

[0125] In an embodiment of step S5002, after the wake-up operation is performed on the second running unit, the task scheduling operation is performed, including: migrating the first thread from the first running unit to the second running unit in the case that the second running unit is woken up. In this example, since the second running unit has been woken up, after the task scheduling operation is performed, the task of the first thread can be directly migrated to the second running unit, without waiting for the second running unit to be woken up again, that is, the overhead of the task scheduling does not include the overhead of waiting for the second running unit to be woken up. Therefore, the duration of the pause of the first thread caused by the task scheduling is effectively shortened, and only includes the duration of migrating the first thread from the first running unit to the second running unit. This helps to optimize the system performance and reduce the frame loss probability, thereby improving the user experience.

[0126] In another embodiment of step S5002, after the wake-up operation is performed on the second running unit, the task scheduling operation is performed, including: performing the task scheduling operation after a first preset duration from performing the wake-up operation on the second running unit. This can effectively avoid the case that the second running unit is woken up, but the first thread is still delayed in migrating from the first running unit to the second running unit. Therefore, based on the method provided in some embodiments of the present application, the case that the first thread is not migrated due to system failure, blocking and waiting, etc. can be effectively avoided, which is conducive to the smooth migration of the first thread.

[0127] Optionally, before performing the wake-up operation on the second running unit, the method further includes: determining the first preset time length according to the sleep state of the second running unit.

[0128] The sleep state of the second running unit helps to set a more reasonable first preset time length. On the one hand, it can effectively prevent the first preset time length from being too short, which makes the second running unit not fully woken up when performing the task scheduling operation, resulting in the first thread being paused for too long and causing the electronic device to freeze. On the other hand, it can also effectively prevent the first preset time length from being too long, which makes the second running unit wake up for a long time but still not perform the task scheduling operation, resulting in power waste. By setting a reasonable first preset time length, the second running unit can be woken up in time for the scheduling of the first thread, which helps to optimize system performance and reduce power waste of the second running unit.

[0129] In the embodiment of the application, when the first thread is about to be migrated and the second running unit is in a sleep state, the task scheduling of the first thread is not immediately performed, but the second running unit is woken up first. This allows the task of the first thread currently running on the first running unit to continue to be executed, preventing the first thread from being paused too early and resulting in a long waiting time, which in turn causes the electronic device to freeze. Therefore, the time length of the first thread pause caused by task scheduling can be effectively shortened, which helps to optimize system performance and reduce the probability of frame loss. At the same time, the second running unit can be kept in a sleep state when it is not needed to run, which helps to reduce the power consumption of the electronic device.

[0130] FIG. 7 is a schematic flowchart of a task scheduling method 700 provided by an embodiment of the application. The method 700 includes:

[0131] In step S7001, the first thread meets the migration condition, and it is determined to migrate the first thread from the first running unit to the second running unit. The migration condition includes that the load of the first running unit in the first time period is greater than or equal to the expected load.

[0132] It should be noted that this step confirms the task scheduling operation to be performed on the first thread, rather than immediately performing the task scheduling operation on the first thread. In other words, when the first thread meets the migration condition, the task scheduling operation of the first thread has not actually started to be performed. Illustratively, the task scheduling operation of the first thread can be performed by the electronic device. Illustratively, the task scheduling of the first thread can also be performed by a system software unit, which can be a software component in the electronic device responsible for managing hardware resources, scheduling tasks, and performing system-level operations.

[0133] For example, the first running unit and the second running unit can have different performance. For example, the performance of the first running unit can be better than the performance of the second running unit, or the performance of the second running unit can be better than the performance of the first running unit. In some embodiments, the first running unit and the second running unit can be different types of CPU cores in a processor. For example, the first running unit can be a small core suitable for processing light tasks, and the second running unit can be a large core with a higher clock frequency and stronger computing power.

[0134] The migration condition can be a certain predefined condition or a set of conditions. For example, the migration condition can be that the load of the first running unit in the first time period is greater than or equal to the expected load.

[0135] In step S7002, the state of the second running unit is determined.

[0136] For example, if the second running unit is in a sleep state, step S7003 can be performed, or if the second running unit is in a normal working state, step S7004 can be performed. The state in step S7002 can be a normal working state or a sleep state. For example, the sleep state can also be divided into a deep sleep state and a shallow sleep state.

[0137] In step S7002, when the system software unit learns that the first thread is about to be migrated to the second running unit, the task scheduling operation on the first thread is not immediately performed, but the state of the second running unit is first confirmed. If the second running unit is in a sleep state, step S7003 can be performed. That is, the operation of waking up the second running unit is performed first, and then the subsequent task scheduling operation is performed. This makes the task of the first thread currently running on the first running unit continue to be executed, prevents the thread from being paused too early and causes a long waiting time, and further causes the electronic device to be stuck.

[0138] For example, FIG. 8 shows a schematic diagram of task scheduling provided by an embodiment of the present application. As shown in FIG. 8, when the first thread is about to be migrated from the first running unit to the second running unit, the task scheduling operation is not immediately performed, but the second running unit is preferentially woken up, so that the task of the first thread currently running on the first running unit can continue to be executed, without interrupting the first thread to wait for the second running unit to wake up. Therefore, in the embodiment of the present application, the duration of the pause of the first thread caused by the task scheduling can be effectively shortened, which helps to reduce the performance impact caused by pausing the first thread during the process of waking up the second running unit.

[0139] In step S7003, the second running unit is woken up.

[0140] Exemplarily, in step S7003, the system software unit starts to wake up the second running unit. Exemplarily, the system software unit can include a first module and a second module, as shown in FIG. 9. The first module and the second module can be software modules with specific functions, wherein the first module can be used to judge the load condition of the first running unit and perform task scheduling operation on the first thread; and the second module can be used to wake up the second running unit.

[0141] In addition, exemplarily, the first module can be a part of the system software unit, and the second module can exist independently of the system software unit, as shown in FIG. 10.

[0142] Exemplarily, the wake-up method of step S7003 can include that the first module sends a wake-up instruction to the second module, and the second module performs the wake-up operation. FIG. 11 shows a process schematic diagram of a task scheduling method provided by an embodiment of the present application. As shown in FIG. 11, when the system software unit decides to wake up the second running unit, the first module sends a wake-up instruction to the second module, and the second module performs the operation of waking up the second running unit after receiving the wake-up instruction.

[0143] The second module starts to perform the operation of waking up the second running unit after receiving the wake-up instruction. Exemplarily, the operation can be: waking up the second running unit by writing a node.

[0144] Exemplarily, the operation of waking up the second running unit by the second module can also be: the second module interacts with the hardware through an API or a system call provided by the operating system, so as to control the state of the second running unit. For example, the second module establishes contact with a power management unit (PMU) through the API, sends an instruction through the API of the power management unit, and converts the state of the second running unit from the sleep state to the normal working state.

[0145] Exemplarily, the operation of waking up the second running unit by the second module can also be: the second module migrates a second thread to the second running unit, so as to trigger the wake-up of the second running unit. The second thread is created on the spot, and is used to wake up the second running unit in the sleep state. Optionally, the method further includes: after waking up the second running unit, destroying the second thread.

[0146] Optionally, the second thread can be an empty thread. Since the empty thread does not need to perform any actual work and can be quickly created and scheduled, the second running unit can be quickly woken up. In addition, the empty thread usually only occupies very few system resources when executed on the second running unit, and does not need to be allocated with a large amount of memory and processing resources. This can improve the overall performance and response speed of the electronic device, and help to quickly migrate the task of the first thread to the second running unit, for the electronic device which is short of resources.

[0147] For example, the operation of the second module to wake up the second running unit can also be that the second module migrates a third thread to the second running unit, the third thread being a resident thread under a system process and being used to wake up the second running unit. For example, after waking up the second running unit, the third thread is suspended.

[0148] For example, the third thread can be created when the electronic device is powered on. Based on the method provided in some embodiments of the present application, the overhead of frequently creating and destroying threads can be effectively reduced, which is beneficial to improving the quick processing capability of the system to a burst event while saving resources.

[0149] For example, FIG. 12 is a schematic flowchart of a wake-up method 1200 provided by an embodiment of the present application. The method 1200 includes:

[0150] In step S1201, when the first thread meets the migration condition and the second running unit is in a sleep state, an operation of waking up the second running unit is started.

[0151] For example, when the first module determines that the first thread meets the migration condition and the second running unit is in a sleep state, the first module sends a wake-up instruction to the second module. After receiving the wake-up instruction, the second module prepares to schedule a third thread to wake up the second running unit.

[0152] In step S1202, the third thread is migrated to the second running unit.

[0153] For example, the third thread can be migrated to the second running unit by the second module.

[0154] In step S1203, the wake-up of the second running unit is waited for.

[0155] For example, step S1204 can include one or more of the following: resuming the normal power supply of the second running unit, restarting the clock signal of the second running unit, and resuming the cache state of the second running unit. Then, the third thread will be executed on the second running unit. For example, the third thread is suspended immediately after the execution is successful, so as to provide the second running unit for the first thread.

[0156] Step S1204, after the third thread is migrated successfully, a wake-up feedback message is sent.

[0157] In some examples, the wake-up feedback message is used to indicate that the second running unit is successfully woken up.

[0158] Step S1205, the third thread is suspended. Please refer to FIG. 12, this step is exemplified by a dashed line in the figure.

[0159] Optionally, the third thread can be an empty thread. Exemplarily, the third thread can be a resident empty thread, which does not occupy too much memory and processing resources in a normal running state, can quickly respond to the requirement of waking up the second running unit, reduces the overhead of frequently creating and destroying threads, and is beneficial to improving the quick processing capability of the system to a burst event while saving resources.

[0160] Exemplarily, FIG. 13 shows a life cycle diagram of the third thread provided by the embodiment of the application. The third thread is established after the electronic device is powered on, and exists in the memory for a long time and is in a ready state, that is, the third thread has no actual work in the low-load running state of the first running unit. When the first running unit enters a high-load running state, the first thread running on the first running unit meets the migration condition and the second running unit is in a sleep state, a wake-up operation is performed on the second running unit. At this time, the third thread can be scheduled to the second running unit. Exemplarily, the second module can schedule the third thread to the second running unit. After the third thread runs successfully on the second running unit, it is suspended, continues to return to the memory and is in a ready state, and waits for the next wake-up operation.

[0161] Step S7004, a task scheduling operation is performed.

[0162] Exemplarily, the task scheduling operation is used to migrate the first thread from the first running unit to the second running unit.

[0163] It should be noted that when the task scheduling operation starts to be performed, the task of the first thread running on the first running unit can be immediately suspended, preparing for the next migration work.

[0164] Optionally, performing the task scheduling operation includes: performing the task scheduling operation in the case that the second running unit is woken up.

[0165] Exemplarily, from the start of the wake-up operation on the second running unit to the second running unit being woken up, a time duration t is experienced. The time duration t is related to the sleep state of the second running unit and the setting of the electronic device. Generally, the deeper the sleep state, the more operations required to wake up the second running unit, and the longer the waiting time for wake-up. For example, a CPU core of an electronic device has four states C0, C1, C2 and C3, wherein the time duration for the CPU core to be woken up from the C1 state and the C2 state is relatively short, only tens of microseconds. The time duration for the CPU core to be woken up from the C3 state is relatively long, generally in the order of hundreds of microseconds or even milliseconds. Exemplarily, the average wake-up time duration in different states is denoted as n is a positive integer. When n is 1, 2 or 3, respectively correspond to the C1 state, the C2 state and the C3 state. Exemplarily, when the CPU core enters the C1 state, when the CPU core enters the C2 state, when the CPU core enters the C3 state, the average wake-up time duration t is which can be determined based on the test and evaluation of the performance of the electronic device. In some cases, t can be equal to the average wake-up time duration in the current state In other cases, due to the influence of load changes, network delays, hardware states and the like, the actual time duration t experienced by the second running unit in the wake-up process is different from the average wake-up time duration in the current state .

[0166] Exemplarily, in some embodiments of step S7004, performing the task scheduling operation can include: notifying the first module to perform task scheduling when it is determined that the second running unit is woken up. As shown in FIG. 11, when sub-step A is adopted in step ③, the second module sends a wake-up feedback message to the first module after the second running unit is woken up, and the wake-up feedback message is used to indicate that the second running unit is successfully woken up. After receiving the wake-up feedback message, the first module confirms that the second running unit is in a normal working state, and the first module performs the task scheduling operation on the first thread.

[0167] Exemplarily, for a second running unit in the C3 state, from the start of the wake-up operation on the second running unit to the second running unit being woken up, a time duration t of 750us is experienced. Within the 750us, the second running unit is gradually woken up from the sleep state. After the second running unit is woken up, the second module sends a wake-up feedback message to the first module, and the first module performs the task scheduling operation on the first thread after receiving the wake-up feedback message, and migrates the first thread from the first running unit to the second running unit, wherein the migration overhead is 50us.

[0168] If the task scheduling operation is performed first and then the first running unit is woken up, the first thread can be re-run only after the first thread is paused for about 800us, including 750us of waiting for the second running unit to wake up and 50us of waiting for thread migration. In the embodiment of the present application, since the second running unit has been woken up in priority, after the task scheduling operation is performed, the duration of the pause of the first thread only includes the duration of the migration of the first thread from the first running unit to the second running unit. The embodiment of the present application shortens the 750us of the first thread pause duration, which helps to optimize the system performance, reduce the frame loss probability, and thus improve the user experience.

[0169] Optionally, the task scheduling operation is performed after a first preset duration from the wake-up operation on the second running unit. That is, after the wake-up operation on the second running unit, the first preset duration elapses, and the task scheduling operation on the first thread is performed.

[0170] For example, the task scheduling operation is performed after the first preset duration from the wake-up operation on the second running unit, including: starting a timer at the same time as the wake-up operation on the second running unit. For example, as shown in FIG. 11, when sub-step B is used in step ③, the timer can be started when the first module sends the wake-up instruction to the second module. That is, when the first module sends the wake-up instruction to the second module, a timer is set to trigger the task scheduling operation on the first thread. The duration of the timer is the first preset duration, denoted as T. After the timer expires, the first module can perform the task scheduling operation on the first thread.

[0171] Optionally, before the wake-up operation on the second running unit, the method further includes: determining the first preset duration according to the sleep state of the second running unit. For example, the first preset duration T can be equal to the average duration of the wake-up of the second running unit For example, the first preset duration T can be equal to the average duration of the wake-up of the second running unit For example, the second running unit has C0, C1, C2 and C3 states, and the second running unit in different states needs different average wake-up durations For example, the second running unit has C0, C1, C2 and C3 states, and the second running unit in different states needs different average wake-up durations For example, the second running unit has C0, C1, C2 and C3 states, and the second running unit in different states needs different average wake-up durations 750us. Then, a timer with T=750us can be set while the wake-up operation is performed on the second running unit. The expiration of the timer triggers the task scheduling operation on the first thread. In this way, the waiting time caused by the suspension of the first thread is shortened, which helps to optimize the system performance and reduce the frame loss probability. Taking the time t actually experienced by the second running unit in the wake-up operation as 750us for example, the waiting time caused by the suspension of the thread is shortened by 750us in this example.

[0172] For example, for a second running unit in the C2 state, it is determined that the average time t actually experienced by the second running unit in the wake-up operation is 50us. Then, a timer with T=50us can be set. Taking the time t actually experienced by the second running unit in the wake-up operation as 50us for example, the waiting time caused by the suspension of the thread is shortened by 50us in this example.

[0173] For example, the first preset time T can be equal to the average time t actually experienced by the second running unit in the wake-up operation. Not equal.

[0174] For example, FIG. 14 shows a task scheduling diagram provided by an embodiment of the present application. For a second running unit in the C3 state, based on the test and evaluation of the performance of the electronic device, it is determined that the average time t actually experienced by the second running unit in the wake-up operation is 650us. Then, a timer with T=650us can be set while the wake-up operation is performed on the second running unit. Within 650us counted by the timer, the second running unit is gradually activated from the sleep state. In this example, That is, the second running unit can not have been completely woken up when the timer expires, and at this time the timer triggers the task scheduling operation on the first thread. As shown in FIG. 14, a timer with T=650us is set while the wake-up operation is performed, and the timer triggers the task scheduling operation on the first thread after 650us. Taking the time t actually experienced by the second running unit in the wake-up operation as 750us for example, since the second running unit has not returned to the normal working state when the timer expires, the migration of the first thread needs to wait for a wake-up time of 100us after the task scheduling operation on the first thread is triggered. In addition, the first thread needs a time of 50us in the migration process. Therefore, the time for performing the task scheduling operation on the first thread is 150us in this example, and the waiting time caused by the suspension of the thread is shortened by 650us, which helps to optimize the system performance and reduce the frame loss probability.

[0175] For example, FIG. 15 shows a task scheduling diagram provided by an embodiment of the present application. As shown in FIG. 15, for a second running unit in a C3 state, based on the test and evaluation of the performance of the electronic device, it is determined that the average time length for the second running unit to be woken up from the C3 state is T = 800 us Then, while the wake-up operation is being performed on the second running unit, a timer with T = 800 us can be set. That is, the second running unit can have been woken up before the timer expires. Therefore, taking the time length t = 750 us actually experienced by the second running unit to be woken up as an example, the task scheduling operation on the first thread is triggered by the timer 50 us after the second running unit is woken up. When the task scheduling operation on the first thread is triggered, the second running unit has been successfully woken up, and the first thread needs a time length of 50 us in the migration process. Therefore, the time length for performing the task scheduling operation on the first thread is 50 us, and the waiting time length caused by suspending the thread is shortened by 750 us, which helps to optimize the system performance and reduce the frame loss probability.

[0176] The above timer can be managed by the system kernel of the electronic device, and the timer can run independently of other software modules. For example, even if the first module or the second module fails, the timer can still work normally. In other words, if the system of the electronic device fails, the first module can not determine that the second running unit is woken up, and thus the task scheduling instruction of the first thread is not issued, so the first thread continues to be executed on the first running unit, causing the first running unit to run at a high load, the system processing speed becomes slow, and the performance is further consumed. At the same time, the woken-up second running unit does not execute the task in time, which also causes unnecessary power waste. The method provided by the embodiments of the present application can effectively avoid the above problems. It can effectively prevent the situation that the first thread is not migrated after the second unit is woken up. Therefore, based on the method provided by some embodiments of the present application, the situation that the first thread is not migrated due to system failure, blocking, and waiting can be effectively reduced, which is beneficial to the smooth migration of the first thread.

[0177] In the embodiments of the present application, when the first thread is about to be migrated and the second running unit is in a sleep state, the task scheduling on the first thread is not immediately performed, but the second running unit is woken up first. This makes the task of the first thread currently running on the first running unit continue to be executed, prevents the first thread from being suspended for a long time, and further prevents the electronic device from being stuck. Therefore, the time length for suspending the first thread caused by the task scheduling can be effectively shortened, which helps to optimize the system performance and reduce the frame loss probability. At the same time, the second running unit can be kept in a sleep state when it is not needed to run, which helps to reduce the power consumption of the electronic device.

[0178] As mentioned above, in the dynamic performance model, the frame loss problem caused by UI high load accounts for more than 70%, and part of the problem is generated based on the scene of mobile cross-platform development scheme.

[0179] The mobile cross-platform development scheme can realize efficient development and dynamic update of different platforms (such as Android, IOS, Web, webpage, etc.), has the characteristics of high code reuse, low development cost and good user experience, can cover a wider market and complete a more efficient release process. Therefore, the mobile cross-platform development scheme becomes the preferred choice of many Internet vendors. The current mobile cross-platform scheme can be divided into three types: the first type is to use the Hybrid technology of loading HTML5 using the built-in browser, and Cordova, Ionic, etc. adopt this technology; the second type is to use JavaScipt development and then use native components for rendering, and React Native (RN), DinamicX, etc. adopt this scheme; the third type is to use the rendering engine and native components provided to realize cross-platform development, and Flutter mainly adopts this scheme. In this application, the second scheme is referred to as RN-like scheme. According to statistics, in the dynamic performance model, the frame loss and lag problems in the RN-like scene account for about 4%. It can be seen that optimizing the frame loss problem in the RN-like scene is a specific optimization direction to improve user experience and system performance.

[0180] In e-commerce shopping platforms, the application is usually constructed by using the RN-like scheme. However, the RN-like scheme usually has defects, because the RN-like framework needs to interact frequently with the server of the application, such as downloading data. At the same time, the RN-like framework also needs an intermediate layer to bridge with the native code, which increases the additional overhead. Especially in the face of some high-sensitive scenes, that is, processing complex animations or high-frequency interactions, it may cause performance loss.

[0181] For example, e-commerce applications often have the need to frequently update the interface. For example, updating the style and content of the product display module during large e-commerce promotion days. In this process, the e-commerce application downloads configuration files from the cloud server, which include product display templates, image content, and other resource information during the promotion period. After downloading the configuration file, it can be matched with the existing product information, and then the configuration file is parsed to apply the new template and image to the product display card. For example, in some e-commerce shopping platforms, the sliding product display card often has the typical characteristics of long single-frame time and uneven load, which is manifested as follows: the previously displayed card does not need to be updated and displayed again, at which time the system load is low and the user's sliding operation is smooth, but when a new card is slid, the system needs to perform layout and drawing operations on the new card, which will cause a sudden increase in load and thus a burst of large frames. This will seriously affect the user's experience.

[0182] FIG. 16 is a schematic flowchart of a task scheduling method 1600 provided by an embodiment of the present application, which can significantly optimize the frame loss problem caused by UI high load for the sliding use of the application of the RN scheme. The method 1600 includes:

[0183] Step S1601, running a first thread on a small core, the small core being a running unit of a processor of an electronic device;

[0184] Step S1602, when the first thread meets a migration condition and a large core is in a sleep state, performing a wake-up operation on the large core, the large core being another running unit of the processor, the performance of the large core being superior to that of the small core, and the migration condition including that a task amount of the small core in a first time period is greater than or equal to an expected task amount, or a running time length of the small core in the first time period is greater than or equal to a preset running time length.

[0185] It should be noted that the determination of whether the first thread meets the migration condition and the determination of whether the large core is in the sleep state do not have a sequence. For example, the first thread can be determined to meet the migration condition first, and then the large core can be determined to be in the sleep state. Alternatively, the first thread can be determined to meet the migration condition and the large core can be determined to be in the sleep state at the same time.

[0186] The performance of the large core is superior to that of the small core. Specifically, in a heterogeneous processor with large and small cores, the large core has a higher clock frequency and stronger computing power, and is suitable for processing tasks that require high computing power. The small core is a low-power CPU core, and is suitable for lightweight tasks.

[0187] The migration condition can be a predefined condition or a set of conditions. For example, the migration condition can be that the load of the small core in the first time period is greater than or equal to the expected load. For example, in the sliding use scenario of the e-commerce application, when the user slides to a completely new card, the system needs to perform a series of processing operations on the new card, including drawing and arranging, and the small core takes the lead in undertaking these tasks. However, due to the low performance of the small core, high load occurs when processing these tasks. For example, the length of the first time period can be 1 minute, and the load of the small core is maintained at more than 85% in 1 minute, which is much higher than the expected load of 65%. This indicates that the processing capacity of the small core is insufficient to meet the current task demand, and the first thread needs to be migrated to the large core for subsequent processing. In actual applications, the migration condition can be different according to different system designs, performance targets, power consumption limits, and the like. The present application does not limit the migration condition. Once the predefined migration condition is met, the electronic device defaults that the first thread will be migrated.

[0188] When the first thread meets the migration condition and the large core is in a sleep state, the large core is preferentially woken up. The sleep state refers to that the large core is in a low-power working state. For example, in the sliding use scenario of the e-commerce application, when the user browses the card content that has been displayed before, the load of the processor is low, and the small core takes over all tasks, and the large core is in an idle state. In order to save power, the large core enters the sleep state. Therefore, performing the wake-up operation on the large core can make it return to the normal working state, so that it can perform tasks.

[0189] Optionally, performing the wake-up operation on the large core includes creating a second thread and migrating the second thread to the large core. The resident thread can be created when the electronic device is powered on. For example, the resident thread can effectively reduce the overhead of frequently creating and destroying threads, save resources, and improve the rapid processing capability of the system for sudden events.

[0190] Optionally, the second thread can be an empty thread. The empty thread can be quickly created and scheduled, so that the large core can be quickly woken up. In addition, when the empty thread is executed on the large core, it usually only occupies a small amount of system resources, and does not need to allocate a large amount of memory and processing resources. This can improve the overall performance and response speed of the electronic device, and help to quickly migrate the tasks of the first thread to the large core for execution.

[0191] At step S1603, after performing the wake-up operation on the large core, a task scheduling operation is performed, and the task scheduling operation is used to schedule the tasks of the first thread from the small core to the large core.

[0192] It should be noted that when the task scheduling operation starts to be executed, the task of the first thread running on the small core can be immediately paused, preparing for the subsequent migration work.

[0193] In an embodiment of the step S1603, after the wake-up operation is performed on the large core, migrating the first thread from the small core to the large core includes: migrating the first thread from the small core to the large core in a case that the large core is woken up. In this example, since the large core has been woken up in priority, after the task scheduling operation is executed, the task of the first thread can be directly migrated to the large core, without waiting for the large core to be woken up, that is, the overhead of the task scheduling does not include the overhead of waiting for the large core to be woken up. Therefore, the duration of the suspension of the first thread caused by the task scheduling is effectively shortened, and only includes the duration of migrating the first thread from the small core to the large core. This helps to optimize the system performance and reduce the frame loss probability, thereby improving the user experience.

[0194] In another embodiment of the step S1603, after the wake-up operation is performed on the large core, migrating the first thread from the small core to the large core includes: migrating the first thread from the small core to the large core after a first preset duration from performing the wake-up operation on the large core. This can effectively avoid the case that the large core is woken up, but the first thread is still delayed in migrating from the small core to the large core. Therefore, based on the method provided by some embodiments of the present application, the case that the first thread is not migrated due to system failure, blocking and waiting, etc. can be effectively avoided, which is conducive to the smooth migration of the first thread.

[0195] Optionally, before the wake-up operation is performed on the large core, the method further includes: determining the first preset duration according to the sleep state of the large core. On the one hand, it can effectively prevent the first preset duration from being too short, which makes the large core not completely woken up when the task scheduling operation is performed, resulting in that the first thread is suspended for too long time and causing the electronic device to be stuck. On the other hand, it can also effectively prevent the first preset duration from being too long, which makes the large core wake up for a long time but still not perform the task scheduling operation, resulting in waste of power consumption. By setting a reasonable first preset duration, it is helpful for the large core to timely perform the scheduling of the first thread after being woken up, which is conducive to optimizing the system performance and reducing the waste of power consumption of the large core.

[0196] In the embodiment of the present application, when the first thread is about to be migrated and the large core is in a sleep state, the task scheduling of the first thread is not immediately performed, but the large core is preferentially woken up. This makes the task of the first thread currently running on the small core continue to be executed, prevents the first thread from being paused too early to cause a long waiting time, and further causes the electronic device to be stuck. Therefore, the time length of the pause of the first thread caused by the task scheduling can be effectively shortened, which helps to optimize the system performance and also helps to reduce the frame loss probability. At the same time, the large core can be kept in a sleep state when the large core is not needed to run, which helps to reduce the power consumption of the electronic device. For example, for a shopping application in an RN-like scenario, the phenomenon of frame loss can be effectively reduced in a sliding use scenario.

[0197] Of course, the embodiment of the present application can be for an RN-like scenario, and can also be for other high-load caused frame loss scenarios. For example, for the frame loss scenario of an IOS native application, certain benefits can also be generated. The scheme described in the embodiment of the present application does not specifically limit the applicable scenarios.

[0198] The embodiment of the present application also provides an electronic device, comprising: one or more processors; one or more memories; and one or more computer programs, wherein the one or more computer programs are stored in the one or more memories, and the one or more computer programs comprise instructions, which, when executed by the one or more processors, cause the electronic device to perform the task scheduling method in the above-described embodiments.

[0199] The embodiment of the present application also provides an electronic device, comprising units or modules for performing the task scheduling method in the above-described embodiments.

[0200] The embodiment of the present application also provides a chip, comprising a circuit for performing the task scheduling method in the above-described embodiments.

[0201] The embodiment of the present application also provides a readable storage medium, which stores instructions, and when the instructions run on an electronic device, the electronic device performs the related method steps to implement the task scheduling method in the above-described embodiments.

[0202] The embodiment of the present application also provides a program product, which, when running on an electronic device, causes the electronic device to perform the related steps to implement the task scheduling method in the above-described embodiments.

[0203] The device, readable storage medium, program product or apparatus provided by the embodiment can be used to perform the corresponding method provided above, and thus the beneficial effects achieved thereby can refer to the beneficial effects of the corresponding method provided above, which will not be described herein again.

[0204] Those skilled in the art can clearly understand that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0205] Those skilled in the art can clearly understand that, for the convenience and brevity of the description, the specific working processes of the above-described system, device and unit can refer to the corresponding processes in the foregoing method embodiments, which will not be repeated here.

[0206] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0207] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, i.e., they can be located in one place or distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.

[0208] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically, or two or more units can be integrated into one unit.

[0209] If the functions are realized in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application or the parts of the technical solutions that essentially contribute to the prior art can be embodied in the form of software products, which are stored in a storage medium and include a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk or an optical disk, and various storage medium that can store program codes.

[0210] The above merely provides the specific implementation of the present application, but the protection scope of the present application is not limited to this. Any person skilled in the art can easily think of the changes or replacements within the technical range disclosed by the present application, which should be covered in the protection scope of the present application.

Claims

1. A task scheduling method, characterized by, The method is applied to an electronic device, and comprises: a first thread running on a first running unit meets a migration condition and a second running unit is in a sleep state, a wake-up operation is performed on the second running unit, the first running unit and the second running unit have different performances, and the migration condition comprises that a load of the first running unit in a first time period is greater than or equal to an expected load; after the wake-up operation is performed on the second running unit, a task scheduling operation is performed, and the task scheduling operation is used to schedule a task of the first thread from the first running unit to the second running unit.

2. The task scheduling method of claim 1, wherein, The method comprises: in a case where the second running unit is woken up, the task scheduling operation is performed.

3. The task scheduling method of claim 1, wherein, The method comprises: after a first preset time length from when the wake-up operation is performed on the second running unit, the task scheduling operation is performed.

4. The task scheduling method of claim 3, wherein, The method further comprises: the first preset time length is determined according to a sleep state of the second running unit.

5. The task scheduling method according to any one of claims 1 to 4, characterized in that, The method comprises: a second thread is created, and the second thread is used to wake up the second running unit; the second thread is migrated to the second running unit; and The method further comprises: after the second running unit is woken up, the second thread is destroyed.

6. The task scheduling method of claim 5, wherein, The second thread is an empty thread.

7. The task scheduling method according to any one of claims 1 to 4, characterized in that, The method comprises: a third thread is migrated to the second running unit, the third thread is a resident thread under a system process, and the third thread is used to wake up the second running unit.

8. A task scheduling method characterized by comprising: The method is applied to an electronic device, and comprises: a first thread runs on a small core, the small core is a running unit of a processor of the electronic device; when the first thread meets a migration condition and a large core is in a sleep state, a wake-up operation is performed on the large core, the large core is another running unit of the processor, a performance of the large core is better than that of the small core, and the migration condition comprises that a task amount of the small core in a first time period is greater than or equal to an expected task amount or a running time length of the small core in the first time period is greater than or equal to a preset running time length; after the wake-up operation is performed on the large core, a task scheduling operation is performed, and the task scheduling operation is used to schedule a task of the first thread from the small core to the large core.

9. The task scheduling method of claim 8, wherein, The method comprises: after a first preset time length from when the wake-up operation is performed on the large core, the task scheduling operation is performed.

10. The task scheduling method of claim 9, wherein, The method further comprises: the first preset time length is determined according to a sleep state of the large core.

11. The task scheduling method according to any one of claims 8 to 10, characterized in that, The method comprises: a second thread is created, and the second thread is used to wake up the large core; the second thread is migrated to the large core; and The method further comprises: after the large core is woken up, the second thread is destroyed.

12. The task scheduling method of claim 11, wherein, The second thread is an empty thread.

13. The task scheduling method according to any one of claims 8 to 10, characterized in that, The method comprises: migrating a third thread to the big core, the third thread being a resident thread under a system process, the third thread being used to wake up the big core.

14. An electronic device, comprising: Comprising: one or more processors; one or more memories; and one or more computer programs, wherein the one or more computer programs are stored in the one or more memories, the one or more computer programs including instructions that, when executed by the one or more processors, cause the electronic device to perform the method of any one of claims 1-13.

15. A chip, characterized by The chip comprises a circuit for performing the method of any one of claims 1-13.

16. A computer-readable storage medium, characterized in that, The computer readable storage medium has stored therein instructions which, when executed on an electronic device, cause the electronic device to perform the method of any one of claims 1-13.

17. A computer program product, characterised in that, The program product, when executed on an electronic device, causes the electronic device to perform the method of any one of claims 1-13.

Citation Information

Patent Citations

  • Method and device for testing scheduling delay time, electronic equipment and storage medium

    CN115509914A

  • Multi-core processor task migration and power consumption adjustment method and architecture based on performance monitoring mechanism

    CN115576664A

  • Thread scheduling method and electronic equipment

    CN118363719A

  • Task scheduling method and electronic equipment

    CN119960944A

  • Portable electronic device and core swapping method thereof

    US20150309560A1