Task scheduling method and electronic equipment
By prioritizing the task scheduling method of electronic devices, high-performance operating units are awakened and task migration is performed, the frame loss problem caused by high load is solved, system performance is optimized and power consumption is reduced.
Patent Information
- Application Number
- CN202510112296.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2044-09-14
AI Technical Summary
Electronic devices can easily lead to frame loss problems under high load conditions, affecting system performance and user experience.
By prioritizing the task scheduling method, task scheduling operations are performed immediately after it wakes up, the task is migrated from the high-load running unit (small core or first running unit) to the high-performance running unit to avoid task pause and frame drops.
It effectively shortens the thread pause time caused by task scheduling, optimizes system performance, reduces the probability of frame drop, and reduces the power consumption of electronic devices when the load is low.
Smart Images

Figure CN119960944A_ABST
Abstract
Description
[0001] This application is a divisional application. The application number of the original application is 202411299871.8, and the original application date is September 14, 2024. The entire contents of the original application are incorporated into this application by reference. Technical Field
[0002] The present application relates to the field of electronic equipment, and in particular to a task scheduling method and electronic equipment. Background Art
[0003] How to reduce the frame loss problem often encountered by electronic devices during use has always been a difficult point in system performance optimization. Especially in some highly sensitive scenarios, such as click operations in game scenes, drag and drop operations in map navigation, and sliding operations in shopping platforms, electronic devices often cause frame loss due to high load of the user interface (UI). Summary of the invention
[0004] The present application provides a task scheduling method and electronic device, which can optimize the task scheduling mechanism and balance performance and power consumption, so that the operating unit can quickly respond to the performance requirements of the system and avoid frame loss of the electronic device due to high load, and can 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, comprising: 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 includes: the load of the above-mentioned first running unit in a first time period is greater than or equal to the expected load; after performing the wake-up operation on the second running unit, a task scheduling operation is performed, and the task scheduling operation is used to schedule the task 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 migrate and the second operation unit is in a sleep state, the task scheduling of the first thread is not performed immediately, but the second operation unit is woken up first. This allows the task of the first thread currently running on the first operation unit to continue to be executed, preventing the first thread from being suspended too early and causing a long waiting time, which in turn causes the electronic device to freeze. Therefore, the duration of the suspension of the first thread 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 operation unit can be kept in a sleep state when the second operation unit is not needed to run, which helps to reduce the power consumption of the electronic device.
[0007] In some possible implementations, the migration condition may be: the task volume of the first operating unit in the first time period is greater than or equal to the expected task volume, or the operating time of the first operating unit in the first time period is greater than or equal to the preset operating time.
[0008] In combination with the first aspect, in some implementations of the first aspect, the performing of the task scheduling operation after performing the wake-up operation on the second operating unit includes: performing the task scheduling operation when the second operating unit is awakened.
[0009] Based on the above technical solution, when the second operation unit is awakened, the task scheduling operation is performed. Since the second operation unit has been awakened first, after the task scheduling operation is performed, the task of the first thread can be directly migrated to the second operation unit without waiting for the second operation unit to be awakened. Therefore, the duration of the first thread suspension caused by task scheduling is effectively shortened, and only includes the duration of the first thread being migrated from the first operation unit to the second operation unit. This helps to optimize system performance, reduce the probability of frame loss, and thus improve the user experience.
[0010] In combination with the first aspect, in certain implementations of the first aspect, the above-mentioned performing a task scheduling operation after performing a wake-up operation on the second operating unit includes: performing a task scheduling operation after a first preset time period from the time the wake-up operation is performed on the second operating unit.
[0011] Based on the above technical solution, triggering the task scheduling of the first thread after the first preset time period can effectively avoid the situation where the first thread is not migrated from the first running unit to the second running unit after the second running unit is awakened. Therefore, based on the method provided in some embodiments of the present application, it is possible to effectively avoid the situation where the first thread is not migrated due to system failure, blocking waiting, etc., which is conducive to the smooth migration of the first thread.
[0012] In combination with the first aspect, in some implementations of the first aspect, the method further includes: determining a first preset duration according to a sleep state of the second operating unit.
[0013] Based on the above technical solution, it is helpful to set a more reasonable first preset duration according to the sleep state of the second operating unit. On the one hand, it can effectively prevent the first preset duration from being too short, which makes the second operating unit not fully awakened when executing the task scheduling operation, resulting in the first thread being suspended for too long, causing the electronic device to freeze. On the other hand, it can also effectively prevent the first preset duration from being too long, which makes the second operating unit awake for a long time but still not executing the task scheduling operation, resulting in power consumption waste. By setting a reasonable first preset duration, it helps the second operating unit to schedule the first thread in time after waking up, which is beneficial to optimizing system performance and also beneficial to reducing power consumption waste of the second operating unit.
[0014] In combination with the first aspect, in certain implementations of the first aspect, performing a wake-up operation on the second running unit includes: creating a second thread, the second thread being used to wake up the second running unit; migrating the second thread to the second running unit; the method also includes: after waking up the second running unit, destroying the second thread.
[0015] In combination with the first aspect, in some implementations of the first aspect, the second thread is a null thread.
[0016] 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, the second operation unit can be quickly awakened. In addition, when the empty thread is executed on the second operation unit, it usually only occupies very few system resources and does not need to allocate a large amount of memory and processing resources. For electronic devices with limited resources, this can improve the overall performance and response speed of the electronic device and help migrate the tasks of the first thread to the second operation unit as soon as possible.
[0017] In combination with the first aspect, in some implementations of the first aspect, performing a wake-up operation on the second running unit includes: migrating a third thread to the second running unit, the third thread being a resident thread under the system process, and the third thread being used to wake up the second running unit.
[0018] Based on the above technical solution, the overhead of frequently creating and destroying threads can be effectively reduced, which is beneficial to improving the system's ability to quickly handle emergencies while saving resources.
[0019] In a second aspect, the present application provides a task scheduling method, which is applied to an electronic device, including: running a first thread on a small core, where the small core is an operating 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, performing a wake-up operation on the large core, where the large core is another operating unit of the processor, and the performance of the large core is better than that of the small core, and the migration condition includes: the task amount of the above-mentioned small core in a first time period is greater than or equal to the expected task amount, or the running time of the above-mentioned small core in the first time period is greater than or equal to the preset running time; after performing the wake-up operation on the large core, performing a task scheduling operation, where the task scheduling operation is used to schedule the task 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 migrate and the large core is in a sleep state, the task scheduling of the first thread is not performed immediately, but the large core is woken up first. This allows the task of the first thread currently running on the small core to continue to be executed, preventing the first thread from being suspended too early and causing a long waiting time, which in turn causes the electronic device to freeze. Therefore, the duration of the suspension of the first thread 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 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 electronic equipment.
[0021] In combination with the second aspect, in some implementations of the second aspect, the performing of the task scheduling operation after performing the wake-up operation on the large core includes: performing the task scheduling operation when the large core is awakened.
[0022] Based on the above technical solution, when the big core is awakened, the task scheduling operation is performed. Since the big core has been awakened first, after the task scheduling operation is performed, the task of the first thread can be directly migrated to the big core without waiting for the big core to be awakened. Therefore, the duration of the first thread suspension caused by task scheduling is effectively shortened, and only includes the duration of the first thread migrating from the small core to the big core. This helps to optimize system performance, reduce the probability of frame loss, and thus improve the user experience.
[0023] In combination with the second aspect, in some implementations of the second aspect, the above-mentioned performing a task scheduling operation after performing a wake-up operation on the large core includes: performing a task scheduling operation after a first preset time period from the time the wake-up operation is performed 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 has passed, which can effectively avoid the situation where the first thread fails to migrate from the small core to the big core after the big core is awakened. Therefore, based on the method provided in some embodiments of the present application, it is possible to effectively avoid the situation where the first thread fails to migrate due to system failures, blocking waiting, etc., which is conducive to the smooth migration of the first thread.
[0025] In combination with the second aspect, in some implementations of the second aspect, the method further includes: determining a first preset duration according to a sleep state of the large core.
[0026] Based on the above technical solution, it is helpful to set a more reasonable 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 fully awakened when executing the task scheduling operation, causing the first thread to be suspended for too long, causing the electronic device to freeze. 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 power consumption waste. By setting a reasonable first preset duration, it helps the large core to schedule the first thread in time after waking up, which is beneficial to optimizing system performance and reducing power consumption waste of the large core.
[0027] In combination with the second aspect, in certain implementations of the second aspect, performing a wake-up operation on the large core includes: creating a second thread, the second thread being used to wake up the large core; migrating the second thread to the large core; the method also includes: after waking up the large core, destroying the second thread.
[0028] In combination with the second aspect, in some implementations of the second aspect, the second thread is a null 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, the big core can be quickly awakened. In addition, when the empty thread is executed on the big core, it usually only occupies very few system resources and does not need to allocate a large amount of memory and processing resources. For electronic devices with limited resources, this can improve the overall performance and response speed of the electronic device and help migrate the tasks of the first thread to the big core as soon as possible.
[0030] In combination with the second aspect, in some implementations of the second aspect, performing a wake-up operation on the big core includes: migrating a third thread to the big core, the third thread being a resident thread under the system process, and 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 is beneficial to improving the system's ability to quickly handle emergencies while saving resources.
[0032] Based on the first aspect or the second aspect above, in some implementations, the migration conditions of the mentioned method can also be described from the dimension of the scene. For example, the application corresponding to the first thread is a gallery, news software or shopping software including a long list interface. The long list interface can be a multi-image browsing interface of a gallery; or, the long list interface can be a picture and text browsing interface of news software; or, the long list interface can be a card browsing interface of shopping software, and each card can correspond to a product. Exemplarily, the migration conditions can correspondingly include: a scene in which the multi-image browsing interface, the picture and text browsing interface or the card browsing interface is sliding;
[0033] For another example, the application corresponding to the first thread is a map application. The migration condition may include: the map application is in a scene where the map is zoomed or enlarged.
[0034] In a third aspect, the present application 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 include instructions that, when executed by the one or more processors, cause the electronic device to perform any method in the first aspect or the second aspect.
[0035] In a fourth aspect, the present application provides an electronic device, comprising a unit or module for executing any one of the methods in the first aspect or the second aspect.
[0036] In a fifth aspect, the present application provides a chip, comprising a circuit, wherein the circuit is used to execute any one of the methods in the first aspect or the second aspect.
[0037] In a sixth aspect, the present application provides a readable storage medium, in which instructions are stored. When the instructions are executed on an electronic device, the electronic device executes any one of the methods in the first aspect or the second aspect.
[0038] In a seventh aspect, the present application provides a program product, which, when executed on an electronic device, enables the electronic device to execute any one of the methods in the first aspect or the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0040] Figure 2 is a software structure block diagram of the electronic device provided in the embodiment of the present application;
[0041] Figure 3 is a schematic diagram of a large-core and small-core heterogeneous processor provided in an embodiment of the present application;
[0042] Figure 4 It is a schematic diagram of task scheduling;
[0043] Figure 5 is a schematic flow chart of a task scheduling method provided in an embodiment of the present application;
[0044] Figure 6 is a schematic flow chart of a wake-up method provided in an embodiment of the present application;
[0045] Figure 7 is a schematic flow chart of a task scheduling method provided in an embodiment of the present application;
[0046] Figure 8 is a schematic diagram of a task scheduling provided by an embodiment of the present application;
[0047] Fig. 9 It is a schematic diagram of the architecture of a software unit provided in an embodiment of the present application;
[0048] Fig.10 It is a schematic diagram of the architecture of a software unit provided in an embodiment of the present application;
[0049] Fig.11 It is a process diagram of a task scheduling method provided by an embodiment of the present application;
[0050] Fig.12 is a schematic flow chart of a wake-up method provided in an embodiment of the present application;
[0051] Fig.13 is a schematic diagram of the life cycle of a third thread provided in an embodiment of the present application;
[0052] Fig.14 is a schematic diagram of a task scheduling provided by an embodiment of the present application;
[0053] Fig.15 is a schematic diagram of a task scheduling provided by an embodiment of the present application;
[0054] Fig.16 It is a schematic flowchart of a task scheduling method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0055] The technical solution in the present application will be described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments.
[0056] The methods in some embodiments of the present application can be applied to electronic devices such as smart phones, tablet computers, laptops, personal computers (PCs), ultra-mobile personal computers (UMPCs), netbooks, car-mounted devices, smart TVs, wearable devices, foldable devices, and Internet of Things (IOT) devices.
[0057] Figure 11 shows a schematic diagram of the structure of the electronic device 100. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an 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, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air 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 is to be understood that the structure illustrated in the embodiment 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 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented by hardware, software, or a combination of software and hardware.
[0059] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0060] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0061] In some embodiments, the processor 110 may include one or more interfaces. The interface may 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 embodiment of the present application, the processor 110 may include operation units with different performances. Taking the example that the processor 110 includes a first operation unit and a second operation unit, the performance of the second operation unit may be better than the first operation unit. Taking the example that the processor 110 includes a large core and a small core, the performance of the large core may be better than the small core.
[0063] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0064] Figure 2 1 is a software structure diagram of the electronic device 100 of the embodiment of the present application. The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the operating system is divided into four layers, from top to bottom, divided into an application layer, an application framework layer, a system library, and a kernel layer. The application layer may include a series of application packages.
[0065] like Figure 2 As shown, the application package may include applications (application, App) such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, wallet, etc.
[0066] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0067] like Figure 2 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.
[0068] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0069] Content providers can be used to store and retrieve data and make it accessible to applications. The data may include videos, pictures, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0070] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.
[0071] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including connecting, hanging up, etc.).
[0072] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0073] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0074] The application layer and the application framework layer run in a virtual machine. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0075] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
[0076] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.
[0077] In the embodiments of the present application, the "first operating unit" and the "second operating unit" may cover hardware, software, or a combination of the two. In terms of hardware, it includes but is not limited to a processor core, an application-specific integrated circuit (ASIC) or other hardware components, which are responsible for performing specific computing tasks. In terms of software, it includes but is not limited to a process or a service, which is responsible for processing specific data or executing a specific algorithm. In terms of the combination of software and hardware, it includes but is not limited to a module in an embedded system, which includes both hardware circuits and software that controls the hardware.
[0078] In today's electronic device field, users' usage patterns of electronic devices are extremely diverse. Users of these electronic devices may perform various operations at any time, from simple page browsing to complex game operations. The diversity and unpredictability of tasks require the operating system to have highly flexible scheduling capabilities. Therefore, task scheduling in the operating system should adapt to the randomness of user behavior and the volatility of task requirements. In particular, in the face of some highly 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 interactions.
[0079] However, high-sensitivity scenes often cause freezes and frame drops due to high UI load. According to statistics, such problems account for more than 70% of dynamic performance models. Therefore, how to optimize the freezes and frame drops caused by high-sensitivity scenes has become a hot topic in the industry.
[0080] Currently, there are methods to solve the frame loss problem by using processing units of different specifications in the system. Taking the central processing unit (CPU) core as an example, there are currently solutions to solve the frame loss problem in highly sensitive scenarios by using heterogeneous processors with large and small cores. Next, in order to facilitate readers to understand this type of solution, the relevant technical terms are explained:
[0081] 1. The CPU is one of the core components of computer hardware. It is responsible for executing instructions in computer programs, controlling data flow and processing various operations. The CPU can be regarded as the "brain" of the computer, and other hardware of the computer coordinates its work through it.
[0082] 2. The CPU core is the core part of the central processing unit and is responsible for executing computing tasks.
[0083] 3. A multi-core processor is a central processing unit that integrates multiple independent CPU cores. Each CPU core is an independent, complete processor that can execute instructions, manage data, and perform computing tasks. Multi-core processors are designed to improve the overall performance of the processor and accelerate computing by executing multiple tasks in parallel.
[0084] 4. A 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 architectures, clock frequencies, and performance characteristics. The architecture of homogeneous multi-core processors is usually used for tasks that require better parallel processing capabilities.
[0085] 5. A 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 so that the processor can better adapt to different types of tasks.
[0086] 6. Heterogeneous processors with large and small cores: Heterogeneous processors with large and small cores are heterogeneous multi-core processors, generally including two types of CPU cores: performance cores and efficiency cores. Among them, the performance core can also be called a "big core", which is used to provide high-performance CPU cores, has a 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 a "small core", which has relatively low performance and is a low-power CPU core suitable for lightweight tasks. Not every CPU core that is a "performance core" is exactly the same, and similarly, there may be differences between CPU cores that are "efficiency cores". In some cases, the efficiency core can be further divided into "medium cores" and "small cores" according to its processing power to reflect the performance levels of different cores. At present, heterogeneous processors with large and small cores are widely used in the computer field, and performance optimization in highly sensitive scenarios is achieved through high-performance large cores and high-efficiency small cores.
[0087] Figure 3 A schematic diagram of a large-core and small-core heterogeneous processor provided in an embodiment of the present application. Figure 3 As shown in FIG. 1 , the processor includes 2 large cores and 6 small cores. It also includes a last level cache (LLC) processor, a memory controller, and an input / output (I / O) interface. The memory controller can send control instructions to instruct the CPU core and the last level cache processor to exchange data, thereby completing the corresponding task.
[0088] In a large-core and small-core heterogeneous processor, the operating system generally allocates tasks to the large core or the small core based on 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 processor load is low. The small core can be responsible for taking over the above tasks, and the large core is idle; when the electronic device requires a large amount of data processing and analysis, runs high-performance applications, handles multiple complex tasks, or conducts high-traffic network activities, the processor load is high. At this time, the electronic device will assign the above complex tasks to the large core.
[0089] In some power saving scenarios, when the processor load is low, tasks are mainly concentrated on small cores, while large cores are idle for a long time. In order to reduce the power consumption of CPU when large cores are idle, large cores can enter sleep state.
[0090] The sleep state can be achieved by setting different levels of C-state. C-state has multiple states, C0, C1, C2, ... Cn, where 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. The larger the number after C, the deeper the sleep state, consuming less power and generating less heat. Generally, the C1 state and the C2 state are regarded as shallow sleep states: the C1 state may include stopping the main internal clock or reducing the voltage, and the C2 state may 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 respond to external interrupts quickly. The C3 state and above settings can be regarded as deep sleep states: the C3 state may include turning off all internal clocks, external clocks, BIU and APIC, which means that the large core cannot respond to important external requests. The C4 state includes further reducing the voltage based on the C3 state. Therefore, the large core that enters the sleep state needs to be awakened to handle tasks with burst loads. However, since the large core takes a long time to wake up, it may affect the performance of electronic devices.
[0091] Figure 4 A schematic diagram of task scheduling is shown. Figure 4 As shown, when the thread running on the small core meets the migration condition and the large core is in a sleep state, the task scheduling operation of the thread is immediately executed to prepare to migrate the thread from the small core to the large core. At this time, the thread running on the small core is immediately suspended. However, since the large core is in a sleep state, the clocks are almost all 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 resume normal working state before migrating the thread to the large core. The process from executing 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 only after about 800us after being suspended. This long delay will have a negative impact on the overall performance of the system, which is manifested in the following two aspects:
[0092] (1) Performance degradation: Longer wake-up time of large cores will lead to task scheduling delays. That is, the large cores cannot process tasks in a timely manner, which will reduce the response speed and processing power of electronic devices.
[0093] (2) Increased probability of frame loss: In highly sensitive scenarios, longer task scheduling delays may cause the processing speed of the large core to be unable to keep up with the needs of electronic device operation. When the processing time of a frame is too long, the time of some subsequent frames is postponed, resulting in accumulated delays. In order to ensure real-time performance, electronic devices may skip the postponed frames to display the latest frames, which leads to frame loss. Frame loss will seriously affect the user experience.
[0094] In one solution, when a specific usage scenario is identified, the large core can be prevented from entering the C3 state, so that it can be quickly awakened or the thread can be directly migrated when needed. For example, when the electronic device identifies a highly sensitive scenario, the large core can remain in normal working state, thereby avoiding waiting for 800us wake-up time. However, this method still has two defects:
[0095] (1) Missed detection of highly sensitive scenes. With the diversification of application scenarios, it is difficult to fully guarantee the accurate recognition of highly sensitive scenes by electronic devices. If electronic devices fail to recognize highly sensitive scenes, the large core will still enter the C3 state, resulting in performance degradation and increased probability of frame loss.
[0096] (2) Waste of power consumption. The original intention of allowing the large core to enter the C3 state is to reduce the power consumption of the CPU when it is idle. Therefore, if the large core is not allowed to enter the C3 state for a long time and the large core fails to process any tasks, it will cause unnecessary waste of power consumption. According to data, in the scenario of sliding operations on the shopping platform, the large core will increase power consumption by about 3% if it does not enter the C3 state. In the long run, increased power consumption will not only have an adverse effect on battery life, but also cause electronic equipment to generate more heat, resulting in more hardware loss. Power consumption and heat dissipation are both important factors affecting user experience. Under continuous high power consumption, the battery life and comfort of electronic equipment will be affected.
[0097] The embodiments of the present application provide a task scheduling method and an electronic device, which can optimize the task scheduling mechanism while balancing performance and power consumption, so that the operating unit can quickly respond to the performance requirements of the system and avoid frame loss of the electronic device due to high load, and can effectively reduce the power consumption of the electronic device when the load is low.
[0098] Figure 5 is a schematic flow chart of a task scheduling method 500 provided in an embodiment of the present application. The method 500 includes:
[0099] Step S5001, the first thread running on the first running unit meets the migration condition and the second running unit is in a sleep state, and a wake-up operation is performed on the second running unit. The first running unit and the second running unit have different performances. The migration condition includes: the load of the first running unit in the first time period is greater than or equal to the expected load.
[0100] The first thread may refer to a thread currently being executed on a first execution unit, which needs to be scheduled to a second execution unit for further execution due to a scheduling decision.
[0101] It should be noted that there is no particular order in which the first thread is determined to satisfy the migration condition and the second operation unit is determined to be in the sleep state. For example, the first thread may be determined to satisfy the migration condition first, and then the second operation unit may be determined to be in the sleep state. For example, the first thread may be determined to satisfy the migration condition and the second operation unit may be determined to be in the sleep state at the same time.
[0102] Exemplarily, the performance of the first operating unit may be better than the performance of the second operating unit, or the performance of the second operating unit may be better than the performance of the first operating unit.
[0103] The above migration condition may be a predefined condition or a set of conditions. Exemplarily, the migration condition may be: the load of the first operation unit in the first time period is greater than or equal to the expected load. For example, the first time period may be 1 minute long, and within 1 minute, the load of the first operation unit continues to remain above 85%, which is much higher than its expected load of 65%. This indicates that the processing capacity of the first operation unit is no longer sufficient to meet the current task requirements, and the first thread needs to be migrated to the second operation unit for subsequent processing.
[0104] Exemplarily, the migration condition may be: the task amount of the first operating unit in the first time period is greater than or equal to the expected task amount, or the running time of the first operating unit in the first time period is greater than or equal to the preset running time.
[0105] In practical applications, the migration conditions may vary according to different system designs, performance targets, power consumption limits, etc., and this application does not limit the migration conditions. Once the predefined migration conditions are met, the electronic device assumes that the first thread is about to be migrated.
[0106] When the first thread meets the migration condition and the second running unit is in a sleep state, the second running unit is awakened first. The above-mentioned "sleep state" refers to the second running unit being in a low-power working state. Performing a wake-up operation on the second running unit can restore it to a normal working state so that it can execute tasks.
[0107] Optionally, performing a wake-up operation on the second operation unit includes: creating a second thread, the second thread being used to wake up the second operation unit; and migrating the second thread to the second operation unit. Optionally, the method further includes: after waking up the second operation unit, destroying the second thread. Figure 6The schematic flow chart of a wake-up method 600 provided in an embodiment of the present application is shown. 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, an operation of waking up the second running unit is started.
[0110] Step S6003: Migrate the second thread to the second execution 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, the second operation unit can be quickly awakened. In addition, when the idle thread is executed on the second operation unit, it usually only takes up very few 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 for electronic devices with limited resources, and help migrate the tasks of the first thread to the second operation unit as soon as possible.
[0112] Step S6004: After the second thread is successfully migrated, a wake-up feedback message is sent.
[0113] In some examples, the wake-up feedback message is used to indicate that the second operating unit is successfully awakened.
[0114] Step S6005, destroy the second thread. Please refer to Figure 6 , this step is illustrated by the dashed line in the figure.
[0115] Optionally, performing the wake-up operation on the second operation unit includes: migrating a third thread to the second operation unit, the third thread being a resident thread under the system process, and the third thread being used to wake up the second operation unit. Exemplarily, after waking up the second operation unit, the third thread is suspended.
[0116] For example, the third thread may be created when the electronic device is turned 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 system's ability to quickly handle emergencies while saving resources.
[0117] Optionally, the third thread may be a null thread.
[0118] Step S5002: After performing a wake-up operation on the second running unit, performing a task scheduling operation, wherein the task scheduling operation is 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 above task scheduling operation starts to be executed, the first thread running on the first running unit can be immediately suspended to prepare for the next migration work. Specifically, the task scheduling operation steps for the first thread may include:
[0120] (1) Pausing the first thread: Pausing the first thread running on the first execution unit to ensure that no further changes occur during the period when the context of the first thread is saved;
[0121] (2) Saving the context of the first thread: After the first thread is suspended, the context of the first thread is immediately saved, including the contents of registers, program counter, stack pointer, etc.;
[0122] (3) context transfer of the first thread: transferring the saved context of the first thread from the first execution unit to the second execution unit, ensuring that the context of the first thread is fully transferred. In some embodiments, the first execution unit saves the context of the first thread in a shared storage device;
[0123] (4) Cache consistency processing: achieving cache consistency between the first running unit and the second running unit to avoid data errors;
[0124] (5) Resuming the operation of the first thread: resuming the operation of the first thread on the second execution unit, and the first thread continues to execute from the place where it was suspended.
[0125] In one embodiment of step S5002, after performing a wake-up operation on the second running unit, a task scheduling operation is performed, including: when the second running unit is awakened, migrating the first thread from the first running unit to the second running unit. In this example, since the second running unit has been awakened, 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 awakened, that is, the overhead of task scheduling does not include the overhead of waiting for the second running unit to be awakened. Therefore, the duration of the suspension of the first thread caused by task scheduling is effectively shortened, and only includes the duration of the first thread being migrated from the first running unit to the second running unit. This helps to optimize system performance, reduce the probability of frame loss, and thus improve the user experience.
[0126] In another embodiment of step S5002, after performing the wake-up operation on the second operation unit, performing the task scheduling operation includes: performing the task scheduling operation after a first preset time period from performing the wake-up operation on the second operation unit. This can effectively avoid the situation where the first thread fails to migrate from the first operation unit to the second operation unit after the second operation unit is awakened. Therefore, based on the method provided in some embodiments of the present application, it can effectively avoid the situation where the first thread fails to migrate due to system failure, blocking waiting, etc., which is conducive to the smooth migration of the first thread.
[0127] Optionally, before performing the wake-up operation on the second operating unit, the method further includes: determining a first preset duration according to a sleep state of the second operating unit.
[0128] According to the sleep state of the second operating unit, it is helpful to set a more reasonable first preset duration. On the one hand, it can effectively prevent the first preset duration from being too short, which makes the second operating unit not fully awakened when executing the task scheduling operation, causing the first thread to be suspended for too long, causing the electronic device to freeze. On the other hand, it can also effectively prevent the first preset duration from being too long, which makes the second operating unit awake for a long time but still not perform the task scheduling operation, resulting in power consumption waste. By setting a reasonable first preset duration, it helps the second operating unit to schedule the first thread in time after waking up, which is beneficial to optimizing system performance and reducing power consumption waste of the second operating unit.
[0129] In an embodiment of the present application, when the first thread is about to migrate and the second operation unit is in a sleep state, the task scheduling of the first thread is not performed immediately, but the second operation unit is woken up first. This allows the task of the first thread currently running on the first operation unit to continue to be executed, preventing the first thread from being suspended too early and causing a long waiting time, which in turn causes the electronic device to freeze. Therefore, the duration of the suspension of the first thread caused by task scheduling can be effectively shortened, which helps to optimize system performance and also helps to reduce the probability of frame loss. At the same time, the second operation unit can be kept in a sleep state when the second operation unit is not needed to run, which helps to reduce the power consumption of the electronic device.
[0130] Figure 7 700 is a schematic flow chart of a task scheduling method 700 provided in an embodiment of the present application. The method 700 includes:
[0131] Step S7001: The first thread meets a 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: 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 clear that this step confirms the task scheduling operation to be performed on the first thread, rather than immediately executing 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 executed. Exemplarily, the task scheduling operation on the first thread can be performed by an electronic device. Exemplarily, 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] Exemplarily, the first operation unit and the second operation unit may have different performances. For example, the performance of the first operation unit may be better than the performance of the second operation unit, or the performance of the second operation unit may be better than the performance of the first operation unit. In some embodiments, the first operation unit and the second operation unit may be different types of CPU cores in a processor. For example, the first operation unit may be a small core suitable for processing lightweight tasks, while the second operation unit may be a large core with a higher clock frequency and stronger computing power.
[0134] The above migration condition may be a predefined condition or a group of conditions. For example, the migration condition may be: the load of the first operating unit in the first time period is greater than or equal to the expected load.
[0135] Step S7002, determining the state of the second operating unit.
[0136] Exemplarily, if the second operating unit is in a sleep state, step S7003 may be executed; or, if the second operating unit is in a normal working state, step S7004 may be executed. The "state" in step S7002 may be a normal working state or a sleep state. Exemplarily, the sleep state may 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 migrate to the second running unit, it does not immediately perform the task scheduling operation for the first thread, but first confirms the state of the second running unit. If the second running unit is in a sleeping state, step S7003 can be executed. That is, the operation of waking up the second running unit is performed first, and then the subsequent task scheduling operation is performed. This allows the task of the first thread currently running on the first running unit to continue to be executed, preventing the thread from being suspended too early and causing a long waiting time, which in turn causes the electronic device to freeze.
[0138] For example, Figure 8 FIG. 1 shows a schematic diagram of task scheduling provided by an embodiment of the present application. Figure 8 As shown, when the first thread is about to migrate from the first running unit to the second running unit, the task scheduling operation is not performed immediately, but the second running unit is awakened first, so that the task of the first thread currently running on the first running unit can continue to be executed, and there is no need to interrupt the first thread to wait for the awakening of the second running unit. Therefore, in the embodiment of the present application, the duration of the suspension of the first thread caused by task scheduling can be effectively shortened, which helps to reduce the performance impact caused by suspending the first thread during the process of waking up the second running unit.
[0139] Step S7003, start waking up the second operating unit.
[0140] Exemplarily, in step S7003, the system software unit starts to wake up the second operating unit. Exemplarily, the system software unit may include a first module and a second module, such as Fig. 9 The first module and the second module may be software modules with specific functions, wherein the first module may be used to determine the load of the first operation unit and perform task scheduling operations on the first thread; and the second module may be used to wake up the second operation unit.
[0141] In addition, illustratively, the first module may be a part of the system software unit, and the second module may exist independently of the system software unit, such as Fig.10 shown.
[0142] Exemplarily, the wake-up method of step S7003 may include: the first module sends a wake-up instruction to the second module, and the second module performs the wake-up operation. Fig.11 A process diagram of a task scheduling method provided by an embodiment of the present application is shown. Fig.11 As shown, when the system software unit decides to wake up the second operating unit, the first module sends a wake-up instruction to the second module, and after receiving the wake-up instruction, the second module executes an operation to wake up the second operating unit.
[0143] After receiving the wake-up instruction, the second module starts to execute the operation of waking up the second operation unit. Exemplarily, the operation may be: waking up the second operation unit by writing a node.
[0144] Exemplarily, the operation of the second module waking up the second operating unit may also be: the second module interacts with the hardware through an API or system call provided by the operating system, thereby controlling the state of the second operating unit. For example, the second module establishes a connection with a power management unit (PMU) through an API, and sends an instruction through the API of the power management unit to convert the state of the second operating unit from a sleep state to a normal working state.
[0145] Exemplarily, the operation of the second module waking up the second running unit may also be: the second module migrates the second thread to the second running unit, thereby triggering the awakening of the second running unit. The second thread is created in real time, and the second thread is used to wake up the second running unit in a sleeping 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 operation unit can be quickly awakened. In addition, when the empty thread is executed on the second operation unit, it usually takes up very few system resources and does not need to allocate a large amount of memory and processing resources. For electronic devices with limited resources, this can improve the overall performance and response speed of the electronic device and help migrate the tasks of the first thread to the second operation unit as soon as possible.
[0147] Exemplarily, the operation of the second module waking up the second running unit may also be: the second module migrates the third thread to the second running unit, the third thread is a resident thread under the system process, and the third thread is used to wake up the second running unit. Exemplarily, after waking up the second running unit, the third thread is suspended.
[0148] Exemplarily, the third thread may be created when the electronic device is turned 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 system's ability to quickly handle emergencies while saving resources.
[0149] For example, Fig.12 1 is a schematic flow chart of a wake-up method 1200 provided in an embodiment of the present application. The method 1200 includes:
[0150] Step S1201: when the first thread meets the migration condition and the second running unit is in the sleep state, start the operation of waking up the second running unit.
[0151] Exemplarily, the first module determines that the first thread meets the migration condition and the second operating unit is in a sleep state, and the first module sends a wake-up instruction to the second module. After receiving the wake-up instruction, the second module prepares to schedule the third thread to wake up the second operating unit.
[0152] Step S1202: Migrate the third thread to the second execution unit.
[0153] Exemplarily, the third thread may be migrated to the second execution unit by the second module.
[0154] Step S1203, waiting for the second operating unit to wake up.
[0155] Exemplarily, step S1204 may include: one or more of: restoring the normal power supply of the second operation unit, restarting the clock signal of the second operation unit, and restoring the cache state of the second operation unit. Then, the third thread will be executed on the second operation unit. Exemplarily, the third thread is immediately paused after successful execution so that the second operation unit can be used by the first thread.
[0156] Step S1204: After the third thread is successfully migrated, a wake-up feedback message is sent.
[0157] In some examples, the wake-up feedback message is used to indicate that the second operating unit is successfully awakened.
[0158] Step S1205: suspend the third thread. Fig.12 , this step is illustrated by the dashed line in the figure.
[0159] Optionally, the third thread may be an empty thread. Exemplarily, the third thread may 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 demand of waking up the second running unit, reduces the overhead of frequently creating and destroying threads, and is conducive to improving the system's ability to quickly handle emergencies while saving resources.
[0160] For example, Fig.13 A schematic diagram of the life cycle of the third thread provided in an embodiment of the present application is shown. After the third thread is established from the time the electronic device is turned on, it exists in the memory for a long time and is in a ready state, that is, the third thread does not have any actual work in the low-load operation state of the first operation unit. When the first operation unit enters a high-load operation state, the first thread running on the first operation unit meets the migration condition and the second operation unit is in a sleep state, and a wake-up operation is performed on the second operation unit. At this time, the third thread can be scheduled to the second operation unit. Exemplarily, the third thread can be scheduled to the second operation unit by the second module. After the third thread successfully runs on the second operation unit, it will pause, continue to return to the memory and be in a ready state, waiting to execute the next wake-up operation.
[0161] Step S7004, executing task scheduling operation.
[0162] Exemplarily, the above task scheduling operation is used to migrate the first thread from the first execution unit to the second execution unit.
[0163] It should be noted that when the above task scheduling operation starts to be executed, the task of the first thread running on the first running unit can be immediately suspended to prepare for the next migration work.
[0164] Optionally, executing the task scheduling operation includes: executing the task scheduling operation when the second operating unit is awakened.
[0165] Exemplarily, the time from executing the wake-up operation on the second operating unit to the second operating unit being awakened is t. t is related to the sleep state of the second operating unit and the settings of the electronic device. Generally, the deeper the sleep state, the more operations are required to wake up the second operating unit, and the longer the wake-up waiting time. For example, the CPU core of an electronic device has four states: C0, C1, C2 and C3. Among them, the time for the CPU core to be awakened when it is in the C1 state and the C2 state is shorter, only tens of microseconds. When the CPU core is in the C3 state, the time for it to be awakened is longer, generally in the hundreds of microseconds or even milliseconds. Exemplarily, the average wake-up time in different states is recorded as n is a positive integer. They correspond to the three sleep states C1, C2 and C3. For example, 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 above average wake-up time It can be determined based on testing and evaluation of the performance of the electronic device. In some cases, t can be equal to the average wake-up time in the current state. In other cases, due to load changes, network delays, hardware status, etc., the actual duration t of waking up the second operating unit is different from the average wake-up duration in the current state. There are differences.
[0166] For example, in some embodiments of step S7004, executing the task scheduling operation may include: when the second module determines that the second operating unit is awakened, notifying the first module to perform task scheduling. Fig.11 As shown, in step ③, when sub-step A is adopted, the second module sends a wake-up feedback message to the first module after the second running unit is awakened, and the wake-up feedback message is used to indicate that the second running unit is successfully awakened. 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 a task scheduling operation on the first thread.
[0167] Exemplarily, for a second operation unit in the C3 state, the duration t from starting the wake-up operation of the second operation unit to the second operation unit being awakened is 750us. Within the 750us, the second operation unit is gradually awakened from the sleep state. After the second operation unit is awakened, the second module sends a wake-up feedback message to the first module. After receiving the message, the first module performs a task scheduling operation on the first thread, and migrates the first thread from the first operation unit to the second operation unit, wherein the migration overhead is 50us.
[0168] If the task scheduling operation is performed first, and then the first operation unit is awakened, the first thread can be re-run after about 800us after being suspended, including 750us waiting for the second operation unit to wake up and 50us waiting for thread migration. In the embodiment of the present application, since the second operation unit has been awakened first, after the task scheduling operation is executed, the duration of the suspension of the first thread only includes the duration of the first thread migrating from the first operation unit to the second operation unit. The embodiment of the present application shortens the suspension duration of the first thread by 750us, which helps to optimize system performance, reduce the probability of frame loss, and thus improve the user experience.
[0169] Optionally, executing the task scheduling operation includes: executing the task scheduling operation after a first preset time period from executing the wake-up operation on the second operation unit, that is, executing the task scheduling operation on the first thread after the first preset time period has passed since executing the wake-up operation on the second operation unit.
[0170] Exemplarily, after a first preset time period has elapsed since the wake-up operation was performed on the second operation unit, the task scheduling operation is performed, including: while the wake-up operation is performed on the second operation unit, a timer is started. Fig.11 As shown, in step ③, when sub-step B is adopted, a timer can be started when the first module sends a wake-up instruction to the second module. That is, when the first module sends a wake-up instruction to the second module, a timer is set to trigger the task scheduling operation for the first thread. The set duration of the timer is the first preset duration, recorded as T. After the timer times out, the first module can be triggered to perform the task scheduling operation for the first thread.
[0171] Optionally, before performing the wake-up operation on the second operating unit, the method further includes: determining a first preset duration according to the sleep state of the second operating unit. Exemplarily, the first preset duration T can be the average duration of the second operating unit being awakened. Determine, n is a positive integer. Exemplarily, the first preset duration T can be the average duration of the second operation unit being awakened. For example, the second operation unit has four states: C0, C1, C2 and C3. The second operation units in different states require different average wake-up times. Where n is 1, 2, or 3. For example, for a second operating unit in the C3 state, based on the test and evaluation of the performance of the electronic device, the average duration of waking up the second operating unit from the C3 state is determined. =750us. Then, while performing the wake-up operation on the second operation unit, a timer of T=750us can be set. The timeout of the timer triggers the task scheduling operation for the first thread. In this way, the waiting time caused by the suspension of the first thread can be shortened, which helps to optimize system performance and reduce the probability of frame loss. Taking the actual duration t of waking up the second operation unit as 750us as an example, the waiting time caused by the thread suspension is shortened by 750us in this example.
[0172] For another example, for a second operating unit in the C2 state, the average duration of being awakened from the C2 state is determined. Then a timer T=50us can be set. Taking the actual duration t of waking up the second operation unit as 50us as an example, in this example, the waiting duration caused by pausing the thread is shortened by 50us.
[0173] Exemplarily, the first preset duration T may be equal to the average duration of the second operation unit being awakened. Not equal.
[0174] For example, Fig.14 The task scheduling diagram provided by the embodiment of the present application is shown. For a second operating unit in the C3 state, based on the test and evaluation of the performance of the electronic device, the average duration of the second operating unit being awakened from the C3 state is determined. Then, while performing the wake-up operation on the second operation unit, a timer of T=650us can be set. Within 650us of the timer timing, the second operation unit is gradually activated from the sleep state. That is, when the timer times out, the second execution unit may not be fully awakened, and the timer triggers the task scheduling operation for the first thread. Fig.14 As shown, a timer of T=650us is set while performing the wake-up operation, and the timer triggers the task scheduling operation for the first thread after 650us. Taking the actual duration t of 750us for waking up the second operating unit as an example, since the second operating unit has not yet resumed normal working state when the timer has passed 650us, after triggering the task scheduling operation for the first thread, it is necessary to wait for a wake-up time of 100us before the migration of the first thread. In addition, the first thread requires 50us during the migration process. Therefore, in this example, the duration of executing the task scheduling operation on the first thread is 150us, which can shorten the waiting time caused by thread suspension by 650us, which helps to optimize system performance and reduce the probability of frame loss.
[0175] For example, Fig.15 FIG. 1 shows a schematic diagram of task scheduling provided by an embodiment of the present application. Fig.15As shown, for a second operating unit in the C3 state, based on the test and evaluation of the performance of the electronic device, the average duration of the second operating unit being awakened from the C3 state is determined. Then, while performing the wake-up operation on the second operation unit, a timer of T=800us can be set. In this example, That is, the second operation unit may have been awakened before the timer times out. Therefore, taking the actual duration t of waking up the second operation unit as 750us as an example, 50us after the second operation unit is awakened, the timer triggers the task scheduling operation for the first thread. When the task scheduling operation for the first thread is triggered, the second operation unit has been successfully awakened, and the first thread needs 50us in the migration process. Therefore, the duration of executing the task scheduling operation on the first thread is 50us, which can shorten the waiting time caused by thread suspension by 750us, which helps to optimize system performance and reduce the probability of frame loss.
[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. Exemplarily, 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 may not be able to determine that the second operation unit is awakened, so that the task scheduling instruction of the first thread will not be issued, so the first thread continues to execute on the first operation unit, resulting in the high-load operation of the first operation unit, the system processing speed slows down, and further causes performance loss. At the same time, the awakened second operation unit does not perform the task in time, which also causes unnecessary power consumption waste. The method using the embodiment of the present application can effectively avoid the above problems. It can effectively prevent the situation where the first thread has not been migrated after the second unit is awakened. Therefore, based on the method provided in some embodiments of the present application, the situation where the first thread has not been migrated due to system failure, blocking waiting, etc. can be effectively reduced, which is conducive to the smooth migration of the first thread.
[0177] In an embodiment of the present application, when the first thread is about to migrate and the second operation unit is in a sleep state, the task scheduling of the first thread is not performed immediately, but the second operation unit is woken up first. This allows the task of the first thread currently running on the first operation unit to continue to be executed, preventing the first thread from being suspended too early and causing a long waiting time, which in turn causes the electronic device to freeze. Therefore, the duration of the suspension of the first thread caused by task scheduling can be effectively shortened, which helps to optimize system performance and also helps to reduce the probability of frame loss. At the same time, the second operation unit can be kept in a sleep state when the second operation unit 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, frame loss problems caused by high UI load account for more than 70%, among which some problems are caused by scenarios based on mobile cross-platform development solutions.
[0179] The mobile cross-platform development solution can realize efficient development and dynamic update of different platforms (such as Android, IOS, Web, web pages, etc.), with high code reuse, low development cost, good user experience, and can cover a wider market and complete a more efficient release process. Therefore, the mobile cross-platform development solution has become a more popular choice for many Internet manufacturers. The current mobile cross-platform solution can be divided into three types: the first is to use the native built-in browser to load HTML5 Hybrid technology, which uses Cordova, Ionic, etc.; the second is to use JavaScript development and then use native components for rendering. The main solutions using this solution are React Native (RN), DinamicX, etc.; the third is to use the built-in rendering engine and the built-in native components to achieve cross-platform development. The main solution using this solution is Flutter. In this application, the second solution is referred to as the RN-like solution. According to statistics, in the dynamic performance model, the problem of jamming and frame loss in the RN-like scenario accounts for about 4%. It can be seen that optimizing the frame loss problem in the RN-like scenario is a specific optimization direction to improve user experience and system performance.
[0180] On e-commerce shopping platforms, RN-like solutions are often used to build applications. However, RN-like solutions usually have defects because RN-like frameworks need to interact frequently with the application's server, such as downloading data. At the same time, RN-like frameworks also need an intermediate layer to bridge with native code, which adds additional overhead. Especially in the face of some highly sensitive scenarios, that is, when dealing with complex animations or high-frequency interactions, performance loss may occur.
[0181] For example, e-commerce applications usually have the need to frequently update the interface. For example, in the promotion day of a large e-commerce, the style and content of the product display module are updated. In this process, the e-commerce application will download configuration files from the cloud server. These configuration files include resource information such as product display templates and image content during the promotion. 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 card for product display. For example, in some e-commerce shopping mobile platforms, the cards for sliding product display often have the typical characteristics of long single frame time and unbalanced load. Specifically, the previously displayed cards do not need to be updated and displayed again. At this time, the system load is low and the user's sliding operation is smoother. When sliding to a new card, the system needs to layout and draw the new card. These operations will cause a sudden increase in load, and then a sudden large frame phenomenon will occur. This will seriously affect the user experience.
[0182] Fig.16 This is a schematic flow chart of a task scheduling method 1600 provided in an embodiment of the present application, which can significantly optimize the frame loss problem caused by high UI load for the sliding use of applications built with RN-like solutions. The method 1600 includes:
[0183] Step S1601, running a first thread on a small core, where the small core is an operation unit of a processor of an electronic device;
[0184] Step S1602, when the first thread meets the migration condition and the large core is in a sleep state, a wake-up operation is performed on the large core, the large core is another operating unit of the above-mentioned processor, and the performance of the large core is better than that of the small core. The above-mentioned migration conditions include: the task volume of the above-mentioned small core in the first time period is greater than or equal to the expected task volume, or the running time of the above-mentioned small core in the first time period is greater than or equal to the preset running time.
[0185] It should be noted that there is no particular order for determining that the first thread meets the migration condition and determining that the large core is in the sleep state. For example, it can be determined that the first thread meets the migration condition first, and then the large core is in the sleep state. For example, it can also be determined that the first thread meets the migration condition and the large core is in the sleep state at the same time.
[0186] The performance of the above-mentioned large core is better than that of the small core. Specifically, in a large-core and large-core heterogeneous processor, 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, suitable for lightweight tasks.
[0187] The above migration condition may be a predefined condition or a set of conditions. Exemplarily, the migration condition may be: the load of the above small core in the first period is greater than or equal to the expected load. For example, in the sliding use scenario of an e-commerce application, when the user slides to a brand new card, the system needs to perform a series of processing operations on the new card, including drawing, arranging, etc., and the small core takes the lead in undertaking these tasks. However, due to the low operating performance of the small core, a high load occurs when processing these tasks. For example, the duration of the first period may be 1 minute, and within 1 minute, the load of the small core continues to remain above 85%, which is much higher than its expected load of 65%. This indicates that the processing capacity of the small core is no longer sufficient to meet the current task requirements, and the first thread needs to be migrated to the large core for subsequent processing. In actual applications, the migration conditions may vary according to different system designs, performance targets, power consumption limits and other factors, and this application does not limit the migration conditions. Once the predefined migration conditions are met, the electronic device defaults that the first thread is about to be migrated.
[0188] When the first thread meets the migration conditions and the large core is in a sleep state, the large core is awakened first. The above-mentioned "sleep state" refers to the large core being in a low-power working state. For example, in the sliding usage scenario of an e-commerce application, when the user browses the content of a card that has been displayed before, the processor load is low, and the small core takes over all tasks, while the large core is idle. In order to save power consumption, the large core enters a sleep state. Therefore, performing a wake-up operation on the large core can restore it to a normal working state so that it can perform tasks.
[0189] Optionally, performing a wake-up operation on the large core includes: creating a second thread, and migrating the second thread to the large core. The resident thread may be created when the electronic device is turned on. For example, the resident thread can effectively reduce the overhead of frequently creating and destroying threads, saving resources while helping to improve the system's ability to quickly handle emergencies.
[0190] Optionally, the second thread can be an empty thread. Empty threads can be created and scheduled quickly, so that the big core can be quickly awakened. In addition, when the empty thread is executed on the big core, it usually only takes up very few system resources and does not need to allocate a large amount of memory and processing resources. For electronic devices with limited resources, this can improve the overall performance and response speed of the electronic device and help migrate the tasks of the first thread to the big core as soon as possible.
[0191] Step S1603, after performing the wake-up operation on the big core, performing a task scheduling operation, wherein the task scheduling operation is used to schedule the task of the first thread from the small core to the big core.
[0192] It should be noted that when the above task scheduling operation starts to be executed, the task of the first thread running on the small core can be immediately suspended to prepare for the next migration work.
[0193] In one embodiment of step S1603, after performing a wake-up operation on the large core, migrating the first thread from the small core to the large core includes: when the large core is awakened, migrating the first thread from the small core to the large core. In this example, since the large core has been awakened first, 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 awakened, that is, the overhead of task scheduling does not include the overhead of waiting for the large core to be awakened. Therefore, the duration of the suspension of the first thread caused by task scheduling is effectively shortened, and only includes the duration of the migration of the first thread from the small core to the large core. This helps to optimize system performance, reduce the probability of frame loss, and thus improve the user experience.
[0194] In another embodiment of step S1603, after performing a wake-up operation 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 time has passed since the wake-up operation was performed on the large core. This can effectively avoid the situation where the first thread has not yet migrated from the small core to the large core after the large core is awakened. Therefore, based on the method provided in some embodiments of the present application, the situation where the first thread has not migrated due to system failure, blocking waiting, etc. can be effectively avoided, which is conducive to the smooth migration of the first thread.
[0195] Optionally, before performing the wake-up operation on the large core, the method also includes: determining a 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 fully awakened when performing the task scheduling operation, causing the first thread to be suspended for too long, causing the electronic device to freeze. 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 power consumption waste. By setting a reasonable first preset duration, it helps the large core to schedule the first thread in time after waking up, which is beneficial to optimizing system performance and reducing power consumption waste of the large core.
[0196] In an embodiment of the present application, when the first thread is about to migrate and the large core is in a sleep state, the task scheduling of the first thread is not performed immediately, but the large core is awakened first. This allows the task of the first thread currently running on the small core to continue to be executed, preventing the first thread from being suspended too early and resulting in a long waiting time, which in turn causes the electronic device to freeze. Therefore, the duration of the suspension of the first thread 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 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 shopping applications in RN-like scenarios, the phenomenon of frame loss can be effectively reduced in sliding usage scenarios.
[0197] Of course, the embodiments of the present application can be used for RN-like scenarios, or for other high-load caused frame loss scenarios. For example, for the frame loss scenario of iOS native applications, certain benefits can also be generated. The scheme described in the embodiments of the present application does not specifically limit the applicable scenarios.
[0198] An embodiment of the present application also provides an electronic device, including: 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 include instructions, which, when executed by the one or more processors, enable the electronic device to perform the task scheduling method in the above embodiment.
[0199] An embodiment of the present application also provides an electronic device, which includes a unit or module for executing the task scheduling method in the above embodiment.
[0200] An embodiment of the present application also provides a chip, which includes a circuit, and the circuit is used to execute the task scheduling method in the above embodiment.
[0201] An embodiment of the present application also provides a readable storage medium, in which instructions are stored. When the instructions are executed on an electronic device, the electronic device executes the above-mentioned related method steps to implement the task scheduling method in the above-mentioned embodiment.
[0202] The embodiment of the present application also provides a program product. When the program product is run on an electronic device, the electronic device executes the above-mentioned related steps to implement the task scheduling method in the above-mentioned embodiment.
[0203] Among them, the equipment, readable storage medium, program product or device provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.
[0204] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0205] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0206] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods 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 there may be other division methods in actual implementation, such as multiple 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 may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0208] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0209] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk or an optical disk.
[0210] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technology in the field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.
Claims
1. A task scheduling method, characterized in that: The method is applied to an electronic device, comprising: The first thread running on the small core meets the migration condition, waking up the large core in the sleeping state, wherein the migration condition includes: the load of the small core in the first time period is greater than or equal to the expected load; After performing a wake-up operation on the large core, a task scheduling operation is performed, where the task scheduling operation is used to schedule the task of the first thread from the small core to the large core.
2. The task scheduling method according to claim 1, characterized in that: After performing the wake-up operation on the large core, performing the task scheduling operation includes: When the large core is awakened, the task scheduling operation is performed.
3. The task scheduling method according to claim 1, characterized in that: After performing the wake-up operation on the large core, performing the task scheduling operation includes: The task scheduling operation is performed after a first preset time period from the time when the wake-up operation is performed on the large core.
4. The task scheduling method according to claim 3, characterized in that: The method further comprises: The first preset duration is determined according to the sleep state of the large core.
5. The task scheduling method according to any one of claims 1 to 4, characterized in that: The performing a wake-up operation on the large core includes: Creating a second thread, where the second thread is used to wake up the large core; Migrating the second thread to the large core; The method further comprises: After waking up the large core, destroying the second thread.
6. The task scheduling method according to claim 5, characterized in that: The second thread is a null thread.
7. The task scheduling method according to any one of claims 1 to 4, characterized in that: The performing a wake-up operation on the large core includes: A third thread is migrated to the large core, the third thread is a resident thread under the system process, and the third thread is used to wake up the large core.
8. A task scheduling method, characterized in that: The method is applied to an electronic device, comprising: Running a first thread on the small core of the electronic device; When the first thread meets a migration condition, waking up a large core in a sleeping state in the electronic device, the migration condition including: the task amount of the small core in the first time period is greater than or equal to the expected task amount, or the running time of the small core in the first time period is greater than or equal to the preset running time; After performing a wake-up operation on the large core, a task scheduling operation is performed, where the task scheduling operation is used to schedule the task of the first thread from the small core to the large core.
9. The task scheduling method according to claim 8, characterized in that: After performing the wake-up operation on the large core, performing the task scheduling operation includes: The task scheduling operation is performed after a first preset time period from the time when the wake-up operation is performed on the large core.
10. The task scheduling method according to claim 9, characterized in that: The method further comprises: The first preset duration is determined according to the sleep state of the large core.
11. The task scheduling method according to any one of claims 8 to 10, characterized in that: The performing a wake-up operation on the large core includes: Creating a second thread, where the second thread is used to wake up the big core; Migrating the second thread to the large core; The method further comprises: After waking up the large core, destroying the second thread.
12. The task scheduling method according to claim 11, characterized in that: The second thread is a null thread.
13. The task scheduling method according to any one of claims 8 to 10, characterized in that: The wake-up operation is performed on the large core to migrate a third thread to the large core, the third thread is a resident thread under the system process, and the third thread is used to wake up the large core.
14. An electronic device, characterized in that: include: 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 include instructions, which, when executed by the one or more processors, cause the electronic device to perform the method as described in any one of claims 1 to 13.
15. A chip, characterized in that: The chip comprises a circuit for executing the method according to any one of claims 1 to 13.
Citation Information
Patent Citations
Multicore equipment energy consumption management method and device
CN103037109A
Microprocessor and method for saving power by using same
CN109240481A
Multicore microprocessor and reconfiguring method thereof, and computer readable storage medium
CN110046126A
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
Cited By
Multi-core real-time operating system, task scheduling method thereof and electronic equipment
CN120821546A
Task scheduling method and electronic device
WO2026056682A1