Thread scheduling method and electronic device
Patent Information
- Application Number
- CN202210790819.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-06
- Publication Date
- 2026-09-04
- Estimated Expiration
- 2042-07-06
AI Technical Summary
[0003]随着电子设备中安装的应用或者存储的文件越来越多,应用运行时可能出现卡顿,降低应用的流畅性,导致应用卡顿,影响使用体验
Smart Images

Figure CN117407127B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of terminal technology, and in particular to thread scheduling methods and electronic devices. Background Technology
[0002] Currently, with the widespread use of mobile phones and other electronic devices, users have increasingly higher demands for the smoothness of applications.
[0003] As electronic devices accumulate more and more applications and stored files, application performance may become sluggish, reducing smoothness and impacting user experience. Therefore, there is an urgent need to develop an effective method to improve the performance of electronic devices. Summary of the Invention
[0004] To address the aforementioned technical problems, embodiments of this application provide a thread scheduling method and an electronic device. The technical solution provided by these embodiments can dynamically migrate tasks in the synthesis thread or display thread that affect the performance of the electronic device, thereby reducing the probability of related tasks being blocked and improving the performance of the electronic device.
[0005] To achieve the above-mentioned technical objectives, the embodiments of this application provide the following technical solutions:
[0006] Firstly, a thread scheduling method is provided, applied to an electronic device or a component capable of implementing the functions of the electronic device, such as a chip system. The method includes: the electronic device receiving a first operation; detecting that a first thread is in a ready state on a first processing unit, and that a second thread is running on the first processing unit; and migrating a first task of the first thread to the second processing unit, so that the first thread executes a first task associated with the first operation on the second processing unit, the first task including a layer compositing task or a display task. The first thread includes a compositing thread or a display thread; the priority of the first thread is lower than the priority of the second thread.
[0007] In this embodiment of the application, in order to minimize the probability of electronic devices experiencing lag, a synthesis thread or a display thread related to the performance indicators such as the smoothness and response speed of the electronic device can be determined, and the tasks of the synthesis thread or the display thread can be dynamically migrated between different processing units. In this way, the probability of the synthesis task or the display task being delayed can be reduced, thereby improving the smoothness and other performance of the electronic device.
[0008] In one possible design, the electronic device migrates the first task of the first thread to the second processing unit, including: the electronic device detects that the duration of the first thread in the ready state exceeds a threshold, and migrates the first task of the first thread to the second processing unit.
[0009] Taking the first thread as the compositing thread as an example, it can be understood that if the compositing thread's ready state time has not reached the threshold, it means that the compositing task of the compositing thread has not been significantly affected, or the impact on the smoothness or other performance aspects of the electronic device is minimal. In this case, we can wait for the compositing thread's ready state time to exceed the threshold before migrating the compositing thread's task. This reduces the probability of erroneous task migration and the frequency of task migration, thereby reducing the resulting device power consumption and improving the performance of the electronic device.
[0010] In one possible design, a third thread runs on the second processing unit, the third thread having a lower priority than the first thread; the first thread executes a first task associated with the first operation on the second processing unit, including: the first thread preempting the third thread and executing the first task on the second processing unit.
[0011] Taking the first thread as the synthesis thread as an example, it means that if the synthesis thread cannot run on the first processing unit, the synthesis thread can preempt the low-priority thread on the second processing unit to ensure that the synthesis task of the synthesis thread is executed on the second processing unit first, thereby improving the smoothness of the electronic device as much as possible.
[0012] In one possible design, the first operation includes launching a first application, and the first task is a layer compositing task; the first thread executes the first task associated with the first operation on the second processing unit, including: the first thread compositing the launch animation of the first application on the second processing unit; the method further includes: displaying the launch animation on a display screen.
[0013] In other words, in the scenario where a user launches the first application, during the process of compositing the application's launch animation, if the compositing thread is ready on the current processing unit, the electronic device can migrate the compositing task of the compositing thread to other processing units, allowing the compositing thread to compose the application's launch animation on those other units. This speeds up the layer compositing process, helping the electronic device display the application's launch animation more quickly and improving the device's smoothness.
[0014] In one possible design, the first operation includes launching a first application, and the first task is a display task; the first thread executes the first task associated with the first operation on the second processing unit, including: the first thread transmits the launch animation of the first application to the display screen on the second processing unit; the method further includes: displaying the launch animation on the display screen.
[0015] In other words, in the scenario where a user launches the first application, during the process of sending the application's launch animation to the display unit, if the display thread is in a ready state on the current processing unit, the electronic device can migrate the compositing task of the display thread to other processing units. This allows the display thread to execute the launch animation on other processing units. This speeds up the display process, helping the electronic device to display the first application's launch animation faster and improving the device's smoothness.
[0016] In one possible design, the first operation includes closing the first application, and the first task is a layer compositing task; the first thread executes the first task associated with the first operation on the second processing unit, including: the first thread compositing a closing animation of the first application on the second processing unit; the method further includes: displaying the closing animation on a display screen.
[0017] In other words, when a user closes or exits the first application, during the compositing process for the application's close animation, if the compositing thread is ready on the current processing unit, the electronic device can migrate the compositing task to other processing units. This allows the compositing thread to compose the application's close animation on those other units. This speeds up layer compositing, helps the electronic device display the application's close animation more quickly, and improves the device's smoothness.
[0018] In one possible design, the first operation includes closing the first application, and the first task is a display task; the first thread executes the first task associated with the first operation on the second processing unit, including: the first thread transmits the closing animation of the first application to the display screen on the second processing unit; the method further includes: displaying the closing animation on the display screen.
[0019] In other words, when a user closes or exits the first application, during the process of sending the closing animation of the first application to the display unit, if the display sending thread is in a ready state on the current processing unit, the electronic device can migrate the composition task of the display sending thread to other processing units, so that the display sending thread can execute the display of the closing animation on other processing units. In this way, the display progress of the closing animation can be accelerated, which helps the electronic device display the closing animation of the first application faster and improves the smoothness of the electronic device.
[0020] In one possible design, the preset field of the first thread is set to a preset value. In this way, the electronic device can determine the type of the first thread and dynamically migrate the tasks of the first thread in the ready state according to the type of the first thread, thereby improving the performance of the electronic device.
[0021] Secondly, a thread scheduling method is provided, comprising: the electronic device receiving a first operation; the electronic device detecting that a first thread is in a ready state on a first processing unit, and a second thread is running on the first processing unit; the electronic device determining whether the duration of the first thread being in the ready state exceeds a threshold; if the duration of the first thread being in the ready state does not exceed the threshold, then executing a first task of the first thread on the first processing unit; or, if the duration of the first thread being in the ready state exceeds the threshold, then migrating the first task from the first processing unit to the second processing unit. The first thread includes a compositing thread or a display thread; the priority of the first thread is lower than the priority of the second thread. The first task includes a layer compositing task or a display task.
[0022] In other words, if the first thread remains in the ready state for longer than the threshold, it means that the task of the first thread is significantly affected. In this case, to improve the smoothness of the electronic device, the device can migrate the task of the first thread to other processing units. Conversely, if the first thread remains in the ready state for less than the threshold, the task of the second thread has already been completed on the first processing unit. In this case, the first thread does not need to wait on the first processing unit or migrate to other processing units, but can directly execute its first task on the first processing unit.
[0023] Thirdly, a thread scheduling device is provided, applied to an electronic device or a component capable of implementing the functions of an electronic device, such as a chip system. The device includes: a processor for receiving a first operation; detecting that a first thread is in a ready state on a first processing unit, and that a second thread is running on the first processing unit; and migrating a first task of the first thread to the second processing unit, so that the first thread executes a first task associated with the first operation on the second processing unit; the first task includes a layer compositing task or a display task. The first thread includes a compositing thread or a display thread; the priority of the first thread is lower than the priority of the second thread.
[0024] In one possible design, the processor is configured to transfer the first task of the first thread to the second processing unit, comprising: detecting that the duration of the first thread in the ready state exceeds a threshold, and transferring the first task of the first thread to the second processing unit.
[0025] In one possible design, a third thread runs on the second processing unit, the third thread having a lower priority than the first thread; the first thread executes a first task associated with the first operation on the second processing unit, including: the first thread preempting the third thread and executing the first task on the second processing unit.
[0026] In one possible design, the first operation includes launching a first application, and the first task is a layer compositing task; the first thread executes the first task associated with the first operation on the second processing unit, including: the first thread compositing the launch animation of the first application on the second processing unit; the device further includes: a display screen for displaying the launch animation composed by the compositing thread.
[0027] In one possible design, the first operation includes launching a first application, and the first task is a display task; the first thread executes the first task associated with the first operation on the second processing unit, including: the first thread transmits the launch animation of the first application to the display screen on the second processing unit; the display screen is used to display the launch animation.
[0028] In one possible design, the first operation includes closing the first application, and the first task is a layer compositing task; the first thread executes the first task associated with the first operation on the second processing unit, including: the first thread compositing a closing animation of the first application on the second processing unit; and a display screen is also used to display the closing animation.
[0029] In one possible design, the first operation includes closing the first application, and the first task is a display task; the first thread executes the first task associated with the first operation on the second processing unit, including: the first thread on the second processing unit transmits the closing animation of the first application to the display screen; the display screen is also used to display the closing animation.
[0030] In one possible design, the preset field of the first thread is set to a preset value.
[0031] Fourthly, a thread scheduling device is provided, comprising:
[0032] A processor is configured to receive a first operation; detect that a first thread is in a ready state on a first processing unit, and that a second thread is running on the first processing unit; determine whether the duration of the first thread being in the ready state exceeds a threshold; if the duration of the first thread being in the ready state does not exceed the threshold, execute the first task of the first thread on the first processing unit; or, if the duration of the first thread being in the ready state exceeds the threshold, migrate the first task from the first processing unit to the second processing unit. The first thread includes a compositing thread or a display thread; the priority of the first thread is lower than the priority of the second thread. The first task includes a layer compositing task or a display task.
[0033] Fifthly, embodiments of this application provide an electronic device that has the function of implementing the method described in any of the above aspects and any of its possible implementations; or, the electronic device has the function of implementing the method described in any of the above aspects and any of its possible implementations. This function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions.
[0034] Sixthly, embodiments of this application provide a computer-readable storage medium. The computer-readable storage medium stores a computer program that, when executed by an electronic device, causes the electronic device to perform any aspect or any implementation of the method. In some embodiments, the computer program may also be referred to as instructions or code.
[0035] In a seventh aspect, embodiments of this application provide a computer program product that, when run on an electronic device, causes the electronic device to perform any aspect or any implementation of any aspect.
[0036] Eighthly, embodiments of this application provide a circuit system including a processing circuit configured to perform a method of any aspect or any implementation thereof.
[0037] Ninthly, embodiments of this application provide a chip system including at least one processor and at least one interface circuit. The at least one interface circuit is used to perform transceiver functions and send instructions to the at least one processor. When the at least one processor executes the instructions, the at least one processor performs any aspect or any implementation of any aspect. Attached Figure Description
[0038] Figure 1 A schematic diagram of the application startup animation provided in an embodiment of this application;
[0039] Figure 2 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;
[0040] Figure 3 A schematic diagram of the software structure of an electronic device provided in an embodiment of this application;
[0041] Figure 4 A schematic diagram illustrating the running state of a thread as provided in an embodiment of this application;
[0042] Figure 5 A schematic diagram illustrating the thread scheduling method provided in an embodiment of this application;
[0043] Figure 6 Another structural schematic diagram of the electronic device provided in the embodiments of this application;
[0044] Figure 7 A schematic diagram of thread scheduling methods in related technologies;
[0045] Figure 8 A schematic diagram illustrating the thread scheduling method provided in an embodiment of this application;
[0046] Figure 9 Another schematic diagram of the thread scheduling method provided in the embodiments of this application;
[0047] Figure 10 A flowchart illustrating the thread scheduling method provided in an embodiment of this application;
[0048] Figures 11-14 Another schematic diagram of the thread scheduling method provided in the embodiments of this application;
[0049] Figure 15 This is a schematic diagram of the structure of the thread scheduling device provided in the embodiments of this application;
[0050] Figure 16 This is a schematic diagram of a chip system provided in an embodiment of this application. Detailed Implementation
[0051] In the description of the embodiments of this application, unless otherwise stated, " / " means "or". For example, A / B can mean A or B. "And / or" in this document is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone.
[0052] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of embodiments of this application, unless otherwise stated, "a plurality of" means two or more.
[0053] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0054] In some scenarios, depending on the displayed content, application animations on electronic devices can include two parts: application icon animation and application window animation. Depending on the application's usage scenario, application animations can include application startup animations and application exit animations (or application closing animations). In related technologies, due to limitations in hardware configuration, such as memory and processor version, stuttering application animations during application startup or shutdown can reduce the smoothness of electronic devices and negatively impact the user experience.
[0055] For example, such as Figure 1 In the interface 101 shown in (a), after detecting a user's click on the gallery icon 11, the electronic device displays application icon animations, such as enlarging the icon. Figure 1 In interface 102 shown in Figure (b), the icon indicated by reference numeral 12 represents the icon display effect at a certain moment during the icon enlargement animation. Afterwards, the electronic device displays application window animations, such as enlarging the application window. Figure 1 The interface 103 shown in Figure (c) illustrates the application window display effect at a specific moment during the application window animation process, as indicated by reference numeral 13. In related technologies, factors such as a large number of background applications running or high device temperature can easily cause application startup animations to lag. For example, electronic devices may remain in a state of high temperature for an extended period of time. Figure 1 Interface 103 is shown in (c). After the application window animation is completed, the electronic device displays the application startup animation, such as... Figure 1 The full-screen gallery window interface 104 shown in (d) completes the launch of the gallery application.
[0056] It can be seen that in the above Figure 1In the scenario shown, the electronic device is likely to display a certain interface and keep that interface displayed, causing the electronic device to freeze and affecting the user experience.
[0057] To reduce the probability of screen stuttering in electronic devices, this application provides a thread scheduling method. In this method, when the duration of time that an important thread, such as a synthesis thread, is in the ready state on the initial processing unit exceeds a threshold, the electronic device can migrate the task of the important thread from the initial processing unit to the target processing unit. This reduces the scheduling time of the important thread, enabling it to obtain the right to use the target processing unit in a timely manner and execute tasks related to system response latency, thereby avoiding screen stuttering and improving the smoothness of the electronic device's response.
[0058] The thread scheduling method of this application can be applied to electronic devices. For example, electronic devices may be mobile phones, tablets, personal computers (PCs), netbooks, wearable devices, in-vehicle devices, etc. This application does not impose any special restrictions on the specific form of the electronic device.
[0059] Taking mobile phones as an example, Figure 2 A schematic diagram of the hardware structure of electronic device 100 is shown. The structure of other electronic devices can be found in the structure of electronic device 100.
[0060] Electronic device 100 may include processor 110, external memory interface 120, internal memory 121, universal serial bus (USB) interface 130, charging management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity 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.
[0061] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0062] Processor 110 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). These different processing units may be independent devices or integrated into one or more processors.
[0063] For example, in an electronic device with a multi-core processor, each processor core can be treated as an independent processing unit. For instance, if the electronic device has an eight-core processor, each core can be considered an independent processing unit.
[0064] The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.
[0065] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0066] In some embodiments, the processor 110 may include one or more interfaces. Interfaces 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 (USB) interface, etc.
[0067] The USB interface 130 is a USB standard compliant interface, specifically a Mini USB interface, MicroUSB interface, or USB Type-C interface. USB interface 130 can be used to connect a charger to charge electronic device 100, and can also be used for data transfer between electronic device 100 and peripheral devices. It can also be used to connect headphones for audio playback. This interface can also be used to connect other electronic devices, such as AR devices.
[0068] It is understood that the interface connection relationships between the modules illustrated in the embodiments of the present invention are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0069] The charging management module 140 receives charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 receives charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 receives wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also supply power to the terminal via the power management module 141.
[0070] The power management module 141 connects the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, providing power to the processor 110, internal memory 121, display screen 194, camera 193, and wireless communication module 160, etc. The power management module 141 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be located in the same device.
[0071] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.
[0072] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with tuning switches.
[0073] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be housed in the same device.
[0074] The modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs sound signals through an audio device (not limited to speaker 170A, receiver 170B, etc.) or displays images or videos through the display screen 194. In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 110 and may be housed in the same device as the mobile communication module 150 or other functional modules.
[0075] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.
[0076] In some embodiments of this application, the electronic device 100 can establish a wireless connection with other terminals or servers through the wireless communication module 160 and the antenna 2 to realize communication between the electronic device 100 and other terminals or servers.
[0077] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, enabling electronic device 100 to communicate with networks and other devices via wireless communication technology. The wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. The GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).
[0078] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0079] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Mini-OLED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.
[0080] Electronic device 100 can perform shooting functions through ISP, camera 193, video codec, GPU, display 194 and application processor.
[0081] The ISP (Image Signal Processor) is used to process data fed back from the camera 193. For example, when taking a picture, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, and the camera's photosensitive element transmits the electrical signal to the ISP for processing, converting it into an image visible to the naked eye. The ISP can also perform algorithmic optimization on image noise and brightness. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.
[0082] Camera 193 is used to capture still images or videos. An object is projected onto a photosensitive element by generating an optical image through the lens. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then passed to an ISP for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into image signals in standard RGB, YUV, or other formats. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.
[0083] Digital signal processors (DSPs) are used to process digital signals. Besides digital image signals, they can also process other digital signals. For example, when electronic device 100 selects a frequency, the DSP can perform Fourier transforms on the frequency energy.
[0084] Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. Thus, electronic device 100 can play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0085] An NPU (Neural Processing Unit) is a computational processor for neural networks (NNs). By borrowing the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it can rapidly process input information and continuously learn on its own. NPUs enable intelligent cognitive applications in electronic devices, such as image recognition, facial recognition, speech recognition, and text understanding.
[0086] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.
[0087] Internal memory 121 can be used to store computer executable program code, which includes instructions. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. Processor 110 executes various functional applications and data processing of electronic device 100 by running instructions stored in internal memory 121 and / or instructions stored in memory located in the processor.
[0088] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.
[0089] The audio module 170 is used to convert digital audio information into analog audio signals for output, and also to convert analog audio input into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110.
[0090] The speaker 170A, also known as a "loudspeaker," is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music or make hands-free calls through the speaker 170A.
[0091] The receiver 170B, also known as the "earpiece," is used to convert audio electrical signals into sound signals. When the electronic device 100 answers a telephone call or voice message, the receiver 170B can be brought close to the ear to listen to the voice.
[0092] Microphone 170C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user can speak by bringing their mouth close to microphone 170C, inputting the sound signal into microphone 170C. Electronic device 100 may have at least one microphone 170C. In some embodiments, electronic device 100 may have two microphones 170C, which, in addition to collecting sound signals, can also perform noise reduction. In other embodiments, electronic device 100 may also have three, four, or more microphones 170C, which can collect sound signals, reduce noise, identify the sound source, and perform directional recording, etc.
[0093] The 170D headphone jack is used to connect wired headphones. The 170D headphone jack can be a USB 130 interface or a 3.5mm Open Mobile Terminal Platform (OMTP) standard interface, a CTIA (Cellular Telecommunications Industry Association of the USA) standard interface.
[0094] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. Electronic device 100 can receive button input and generate key signal inputs related to user settings and function control of electronic device 100.
[0095] Motor 191 can generate vibration alerts. Motor 191 can be used for incoming call vibration alerts or for touch vibration feedback. For example, different vibration feedback effects can be corresponding to touch operations applied to different applications (such as taking photos, playing audio, etc.). Motor 191 can also correspond to different vibration feedback effects for touch operations applied to different areas of the display screen 194. Different application scenarios (such as time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also be customized.
[0096] Indicator 192 can be an indicator light, used to indicate charging status, power changes, or to indicate messages, missed calls, notifications, etc.
[0097] The SIM card interface 195 is used to connect a SIM card. The SIM card can be inserted into or removed from the SIM card interface 195 to make contact with and separate from the electronic device 100. The electronic device 100 can support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 195 simultaneously. The multiple cards can be of the same or different types. The SIM card interface 195 is also compatible with different types of SIM cards. The SIM card interface 195 is also compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to realize functions such as calls and data communication. In some embodiments, the electronic device 100 uses an eSIM. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
[0098] It should be noted that the structure of electronic devices can also be referenced. Figure 2 The structure shown allows the electronic device to have a higher... Figure 2 The structures shown may have more or fewer components, or combine some components, or separate some components, or have different component arrangements. The components shown can be implemented in hardware, software, or a combination of software and hardware.
[0099] In some embodiments, the software system of the electronic device 100 may adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This embodiment of the invention uses a layered architecture... Taking the system as an example, the software structure of electronic device 100 is illustrated.
[0100] Figure 3 This is a software structure block diagram of the electronic device 100 according to an embodiment of the present invention.
[0101] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.
[0102] The application layer can include a series of application packages.
[0103] like Figure 3 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and SMS.
[0104] An application may run as one or more processes in the software system of electronic device 100. A process may contain one or more threads.
[0105] An electronic device may run one or more applications, each with at least one corresponding process. Each process has at least one thread executing a task. In other words, an electronic device runs multiple threads. To ensure the proper functioning of these threads, the electronic device can allocate processing units to them according to a certain strategy, such as allocating CPU cores. Once a thread is allocated a processing unit, it can execute the corresponding task through that unit.
[0106] In some embodiments, threads can be divided into different states according to their lifecycle. For example, such as... Figure 4 The states of a thread include: new, runnable, running, blocked, and dead.
[0107] In some embodiments, a thread can be in a newly created state after it is created. The ready state can also be called the runnable state.
[0108] A newly created thread can enter the ready state in certain ways. For example, a newly created thread can call the `start()` method to trigger it to enter the ready state. After entering the ready state, the thread has the conditions to run and is added to the ready queue, waiting for CPU scheduling to execute the corresponding task.
[0109] If a thread in the ready state is scheduled by the CPU, it can enter the running state and execute the corresponding task. Threads in the running state can be added to the run queue of an electronic device.
[0110] For a thread in the running state, it can switch back to the ready state under certain conditions. For example, if a running thread is preempted by another high-priority thread and loses its CPU usage, it can switch from the running state to the ready state. In other cases, if a thread relinquishes its CPU usage for some reason, such as giving up a CPU time slice, it temporarily stops running and enters the blocked state. A blocked thread cannot be added to the ready queue, but it can be added to the blocked queue. When certain events are triggered, such as the I / O device the thread was waiting for becoming idle, the thread can transition from the blocked state to the ready state and can be re-added to the ready queue. A thread re-added to the ready queue can resume execution from its previous position after being selected by an electronic device.
[0111] In some cases, a running thread executes its own task, and when certain conditions are met, such as the condition for completing the task, the thread will enter a dead state.
[0112] In some embodiments, the electronic device can maintain different queues corresponding to various thread states. For example, the queues may include, but are not limited to, one or more of the following: a ready queue, a running queue, and a blocked queue. The ready queue stores threads in the ready state, the running queue stores threads in the running state, and the blocked queue stores threads in the blocked state.
[0113] For example, if a thread is detected entering the ready state, the electronic device can add the thread to the ready queue. Under certain conditions, the CPU of the electronic device can schedule threads in the ready queue and add them to the run queue. Similarly, if a thread is detected entering the running state, the electronic device can add the thread to the run queue. Furthermore, if a thread is detected entering the blocked state, the electronic device can add the thread to the blocked queue. Under certain conditions, the thread can transition from the blocked state to the ready state and be added to the ready queue.
[0114] In some embodiments, each thread can be assigned a priority level, with higher-priority threads more likely to acquire runtime resources. In one example, each thread can be assigned a priority value; a higher priority value corresponds to a lower priority, and vice versa. For instance, assuming the synthetic thread has a priority value of 120 and the real-time thread has a priority value of 99, the real-time thread has a higher priority than the synthetic thread. In certain situations, such as when CPU resources are limited, real-time threads can easily preempt runtime resources from synthetic threads.
[0115] It should be understood that the embodiments of this application do not limit the correspondence between high and low priority values. In some other embodiments, the higher the priority value of a thread, the higher its priority; conversely, the lower the priority value of a thread, the lower its priority.
[0116] For example, such as Figure 5 As shown in (a), at time t1, thread B begins executing its task through processor core 1 and completes the task after time T1. Figure 5 In case (b), at time t1, thread B wants to start executing its task, but thread C, which has a higher priority than thread B, preempts the execution resources of core 1. Therefore, at time t1, thread C begins to execute its task through core 1.
[0117] To avoid the problem of low-priority threads experiencing delayed execution when high-priority threads preempt the execution resources of low-priority threads, in this embodiment, the low-priority thread can be migrated to other processing units when a high-priority thread preempts its execution resources. As before... Figure 5 As shown in (b), when a high-priority thread C preempts the running resources of thread B on core 1, the electronic device can migrate thread B to core 2 of the processor. In this way, thread B can continue to execute tasks on core 2 without waiting for thread C to finish, which helps to improve the execution efficiency of thread B, thereby improving the efficiency of the electronic device in executing tasks and reducing the probability of the electronic device lag.
[0118] As one possible implementation, when the execution resources of a low-priority thread are preempted on the current processing unit, the electronic device can determine the type of the low-priority thread and, based on the type of the low-priority thread, determine whether to migrate the low-priority thread to another processing unit.
[0119] In some embodiments, when a low-priority thread whose execution resources are being preempted belongs to a preset type of thread, the electronic device can migrate that low-priority thread to other processing units. Preset type threads include, but are not limited to, threads that significantly impact the smoothness and response latency of the electronic device. For example, preset type threads include threads related to layer compositing (composer) and threads related to image display. In some examples, the compositing thread may be called a kworker; of course, the compositing thread may have other names, and the thread name does not constitute a substantial limitation on the functionality or other aspects of the compositing thread.
[0120] In some embodiments, threads of a preset type may also be referred to as important threads or critical threads. Response latency may also be referred to as operation latency. Threads related to layer compositing may be simply referred to as compositing threads or layer compositing threads.
[0121] It is understandable that when a low-priority thread whose execution resources are being preempted has a significant impact on the smoothness of an electronic device, such as when the low-priority thread whose execution resources are being preempted is a thread related to layer compositing, the electronic device can migrate this low-priority thread to other processing units to continue execution. This helps to improve the execution efficiency of the low-priority thread, thereby improving the smoothness and other performance of the electronic device.
[0122] Conversely, when a low-priority thread that is preempted from running resources does not belong to the preset type of thread, since the low-priority thread has little impact on the smoothness, response speed and other performance of the electronic device, the electronic device may not migrate the low-priority thread, but wait for the initial processing unit to finish executing the task of the high-priority thread before executing the task of the low-priority thread on the initial processing unit.
[0123] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0124] In this embodiment, the framework layer may include a first service. The first service is used to mark threads of a preset type. In some examples, the first service may be used to detect the type of a thread and modify the corresponding fields of the thread to indicate whether the thread is a thread of the preset type. In some examples, the kernel may obtain the thread type from the first service and, based on the thread type, migrate threads of the preset type from non-idle processor cores to idle processor cores.
[0125] like Figure 3 As shown, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc.
[0126] The window manager is used to manage windowed applications. It can retrieve screen size, determine the presence of a status bar, lock the screen, and capture screenshots, among other things.
[0127] Content providers store and retrieve data, making that data accessible to applications. This data may include videos, images, audio, made and received phone calls, browsing history and bookmarks, phone books, etc.
[0128] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon could include views for displaying text and views for displaying images.
[0129] The phone manager is used to provide communication functions for electronic device 100. For example, it manages call status (including connection and disconnection).
[0130] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
[0131] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of download completion or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.
[0132] The Android runtime consists of core libraries and a virtual machine. The Android runtime is responsible for scheduling and managing the Android system.
[0133] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.
[0134] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.
[0135] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
[0136] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.
[0137] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0138] A 2D graphics engine is a graphics engine for 2D drawing.
[0139] The kernel layer is the layer between hardware and software. It includes at least display drivers, camera drivers, audio drivers, sensor drivers, and binder drivers. The kernel layer provides security management, memory management, process management, network protocol stack management, and driver model management for Android's system servers. System service processes can call kernel layer resources to provide various system services, such as Android Service Management System (AMS), Android Service Management System (PMS), and Android Service Management System (WMS).
[0140] The above merely exemplifies one possible software architecture for an electronic device. Other software architectures are also possible, and this application does not impose limitations. The software architecture can also be based on... The software architecture of such systems. For example, taking the first service as being located in the framework layer as an example above, in other embodiments, the first service may be located in other layers, or the first service may be further divided into multiple functional modules, and different functional modules may be set in different layers.
[0141] like Figure 6 Another possible structure of the electronic device is shown, which may include a processor 401, a memory 403, a transceiver 404, etc. Additionally, it may include a processor 408.
[0142] The aforementioned components may include a pathway for transmitting information between them.
[0143] The transceiver 404 is used to communicate with other devices or communication networks using protocols such as Ethernet and WLAN.
[0144] For detailed information on the processor and memory, please refer to [link / reference needed]. Figure 2 The description of the relevant structures in electronic devices will not be repeated here.
[0145] The technical solutions provided in the embodiments of this application will be described in detail below. The technical solutions of the embodiments of this application can be applied to electronic devices having multiple processing units. Processing units may include, but are not limited to, processor cores. The following description uses a processor core as an example of a processing unit, but this does not constitute a limitation on the processing unit.
[0146] Electronic devices can display various interfaces, such as application startup screens and application exit screens. Electronic devices complete the display of application interfaces through processes such as drawing and rendering, layer compositing, and sending to the display screen (which can be simply called display delivery).
[0147] For example, such as Figure 1 (a) After detecting that the user clicked the gallery app icon 11, the electronic device draws and renders, such as... Figure 1As shown in (b), icon animation 12 is obtained, and the corresponding layer data is acquired. Then, the electronic device calls the compositing thread to perform layer compositing on the layer corresponding to icon animation 12, obtaining the corresponding image, and sending the image to the display driver. For example, the compositing thread sends the composited image to the LCD driver, and the LCD driver calls the LCD to display the image of icon animation 12. The image displayed on the LCD can be perceived by the human eye, thus realizing the display of the application icon animation. Similarly, during application startup, the electronic device displays other startup animations, such as drawing and rendering. Figure 1 The application window 13 shown in (c) calls the compositing thread to compose the image corresponding to the application window 13, and sends the image of the application window 13 to the display module so that the display module displays the image of the application window 13.
[0148] During the aforementioned compositing thread's operation, higher-priority threads may preempt the compositing thread's runtime resources, causing the compositing thread to be unable to timely compose the application's startup animation image, thus preventing timely display and resulting in screen stuttering on electronic devices. For example, in related technologies, such as... Figure 7 As shown, task A runs on processor core 1. At time t1, the layer compositing thread wants to execute its layer compositing task, but thread B, with higher priority, preempts the layer compositing thread's execution resources, and thread B executes its own task on core 1. After thread B's task is completed, the compositing thread gains access to core 1 and executes its layer compositing task. Therefore, in this scheme, the image of application window 13 is composited with a delay, for example, in... Figure 7 In the process, the image was not synthesized until after a delay of T3, causing the electronic device's screen to stutter.
[0149] In this embodiment of the application, in order to minimize the probability of electronic devices experiencing lag, threads related to the smoothness and response speed of the electronic devices can be identified, and tasks of this type of thread can be dynamically migrated between different processing units to reduce the probability of this type of thread being delayed in execution. For example... Figure 8 As shown, task A is running on processor core 1. At time t1, the compositing thread wants to execute the layer compositing task, but thread B, with higher priority, preempts the compositing thread's execution resources. Thread B executes its own task on core 1, and the compositing thread is in a ready state. In this situation, the electronic device can migrate the compositing thread to another idle core and continue executing its task. Figure 8 As shown, the tasks of the compositing thread can be migrated from core 1 to core 2. This avoids interrupting the tasks of the compositing thread and improves the smoothness of application startup or shutdown animations.
[0150] For example, as Figure 1In (a), after detecting that the user clicks the gallery application icon 11, the electronic device schedules the rendering thread to render the startup animation and schedules the compositing thread to composite the image of the startup animation. For example, the compositing thread is scheduled to composite the image of the startup animation. Figure 1 The startup animation 12 of the application icon shown in (b). Assuming the compositing thread is in the ready queue of CPU core 1 and CPU core 1 is running a high-priority real-time thread, the electronic device can migrate the layer compositing task of the compositing thread to CPU core 2 to avoid the compositing delay of startup animation 12 caused by the compositing thread waiting for CPU core 1 to schedule in the ready queue of CPU core 1.
[0151] As can be seen, in the technical solution of this application embodiment, by dynamically migrating the layer compositing task, the layer compositing task can be executed in a timely manner, which helps to reduce the response latency of electronic devices, improve the smoothness of electronic device operation, and enhance the interactive experience. For example, by migrating the layer compositing task to an idle CPU core, the compositing can be accelerated on the idle CPU core. Figure 1 (b) The icon launch animation 12 and Figure 1 The startup animation 13 of the application window shown in (c) enables the startup animations to be displayed quickly and smoothly, which can improve the smoothness of electronic devices.
[0152] In other embodiments, if the duration of the synthesis thread in the ready state does not reach a threshold, it indicates that the synthesis task of the synthesis thread is not significantly affected, or the impact on the smoothness or other performance aspects of the electronic device is minimal. In this case, the synthesis thread can be allowed to remain in the ready state for longer than the threshold before its task is migrated. This reduces the probability of erroneous task migration and the frequency of task migration, thereby reducing power consumption and improving the performance of the electronic device. For example, as shown... Figure 9 At time t1, the layer compositing thread wants to execute its layer compositing task. However, a higher-priority thread B preempts the layer compositing thread's execution resources, and the compositing thread enters a ready state. Subsequently, the compositing thread remains in the ready state. When the compositing thread remains in the ready state for a duration of T4, to prevent the compositing thread from being blocked for an extended period, the electronic device can migrate the compositing thread to other idle cores. For example, the compositing thread can be migrated to core 2, where its task can continue to execute.
[0153] The following section describes some technical details involved in the above method. For example... Figure 10 The illustration shows an exemplary flow of a thread scheduling method according to an embodiment of this application, which includes the following steps:
[0154] S101, The first service identifies the type of thread.
[0155] The types of threads can include important threads and non-important threads. Important threads can include threads related to layer compositing.
[0156] In some embodiments, the first service may reside in the framework layer.
[0157] As one possible implementation, the first service can identify thread types and mark synthetic threads, etc., as important threads. The first service can characterize whether a thread is important by modifying the corresponding fields of the thread.
[0158] S102, The kernel obtains the thread type from the first service.
[0159] S103. For important threads, the kernel determines whether the duration of the important thread in the ready state exceeds a threshold. If it exceeds the threshold, proceed to step S104; otherwise, proceed to step S105.
[0160] In some embodiments, the threshold can be dynamically set according to actual needs. For example, the threshold can be set to a value within the range of 2-10ms.
[0161] As one possible implementation, the kernel triggers a CPU core switching process when certain conditions are met. Optionally, these conditions include, but are not limited to, detecting a clock interrupt instruction. After detecting the clock interrupt instruction, the kernel can detect the duration for which important threads have been in a ready state on the initial processing unit. When this duration times out, the kernel can determine the target processing unit and migrate the tasks of the important threads to the target processing unit. In this embodiment, the initial processing unit may be referred to as the first processing unit, and the target processing unit may be referred to as the second processing unit.
[0162] S104, The kernel migrates the tasks of important threads from the initial processing unit to the target processing unit.
[0163] The initial processing unit refers to the processing unit where the important thread is currently located. Optionally, the target processing unit refers to a processing unit that can be run. The target processing unit can be one of the following: a currently idle processing unit (with no running threads), a processing unit containing low-priority threads, a processing unit without critical tasks in the queue and without real-time tasks, or other processing units that can execute important thread tasks promptly.
[0164] In some embodiments, a low-priority thread refers to a thread with a lower priority than a synthetic thread.
[0165] For example, taking a synthetic thread as an example, such as... Figure 11At time t1, assume that thread 3 is running on CPU core 1, and thread 3 has a higher priority than the compositing thread. Since the compositing thread cannot preempt the execution resources of the higher-priority thread 3, it enters the ready state and is added to the ready queue of CPU core 1 (the initial processing unit of the compositing thread), waiting to be scheduled. Then, when time t2 arrives, if the kernel detects that the compositing thread has been in the ready state for a certain period (e.g., T2), the kernel can migrate the compositing thread to another CPU core (the target processing unit) so that the compositing thread can execute the layer compositing task on another core. This reduces the probability of the layer compositing task being delayed, thereby improving the smoothness of the electronic device.
[0166] As one possible approach, the kernel determines whether there are any idle CPU cores. In some examples, if there are idle CPU cores, the compositing thread can be migrated to the idle CPU core so that the compositing thread can perform layer compositing tasks on the idle CPU core, reducing the probability of layer compositing tasks being delayed and thus improving the smoothness of electronic devices.
[0167] Conversely, in other examples, if there are no idle CPU cores, the kernel can determine whether there is a CPU core running a low-priority thread. If it exists, the synthesized thread can be migrated to that CPU core. If it does not exist, the synthesized thread is not migrated and remains in the ready queue of the initial processing unit, waiting for scheduling.
[0168] For example, as Figure 11 When time t2 arrives, if the kernel detects that the synthesis thread has been in the ready state for a certain period of time (e.g., T2), the kernel can check if there are any idle CPU cores. If the kernel detects that there are no threads in the run queue of CPU core 2, it means that CPU core 2 is idle. Therefore, the kernel can control the synthesis thread to migrate to CPU core 2, so that the synthesis thread can perform the layer synthesis task on CPU core 2.
[0169] For example, such as Figure 12 When time t2 arrives, if the kernel detects that the synthesis thread has been in the ready state for a certain period (e.g., T2), it can then check for idle CPU cores. Upon checking, all CPU cores in the electronic device are found to be active. Next, the kernel can check for CPU cores running low-priority threads. Upon checking, the threads running on CPU cores 2 and 3 have lower priorities than the synthesis thread. Therefore, the kernel can control the synthesis thread to migrate to CPU core 2 (or CPU core 3), allowing the synthesis thread to perform layer compositing tasks on CPU core 2 (or CPU core 3).
[0170] For example, such as Figure 13 When time t2 arrives, the kernel detects that the synthetic thread has been in the ready state for a certain period of time (e.g., T2). Upon inspection, all CPU cores of the electronic device are not idle, and the threads running on each core have a higher priority than the synthetic thread. Therefore, the kernel does not migrate the synthetic thread; it remains in the ready queue of CPU core 1, awaiting scheduling.
[0171] Please refer to this again. Figure 10 In some examples, in addition to steps S101 to S104 described above, the thread scheduling method may also include the following steps:
[0172] S105. Important threads execute tasks on the initial processing unit.
[0173] It is understandable that, taking the synthesis thread as an example, if the synthesis thread is in the ready state on the initial processing unit for no more than a threshold time, the task of the real-time thread has already been completed on the initial processing unit. In this case, the synthesis thread does not need to wait on the initial processing unit or jump to other processing units, but can directly execute the synthesis task on the initial processing unit.
[0174] It should be understood that, depending on the actual needs of thread scheduling, the above steps S101 to S105 can be combined, deleted, or replaced, or other steps can be added, without any restrictions.
[0175] The above explanation primarily uses the layer compositing thread as an example of an important thread. In other embodiments, the important thread can be other types of threads. For example, an important thread may include a display sending thread. Figure 14 At time t1, the display sending thread wants to execute the display sending task. However, thread B, with higher priority, preempts the display sending thread's execution resources (the higher-priority thread B acquires the right to use core 1), and the display sending thread enters the ready state. Afterward, the display sending thread remains in the ready state. When the display sending thread remains in the ready state for a period of time, T4, to avoid the display sending thread being blocked for an extended period, the electronic device can migrate the display sending thread to another idle core (such as core 2), and the display sending task can continue to be executed on core 2.
[0176] The above mainly uses the example of a thread in the ready state to illustrate how to reduce the task latency of a thread in the ready state. In other embodiments, for a thread in the blocked state, the task of that thread can be executed asynchronously. In other words, the tasks of that thread and other threads can be executed simultaneously to reduce the task latency of that thread and improve the processing efficiency of the electronic device.
[0177] In some solutions, multiple embodiments of this application can be combined, and the combined solution can be implemented. Optionally, some operations in the processes of each method embodiment may be combined, and / or the order of some operations may be changed. Furthermore, the execution order between the steps of each process is merely exemplary and does not constitute a limitation on the execution order between steps; other execution orders are also possible. It is not intended to indicate that the execution order is the only possible order in which these operations can be performed. Those skilled in the art will conceive of various ways to reorder the operations described herein. In addition, it should be noted that the process details involved in one embodiment of this document are similarly applicable to other embodiments, or different embodiments may be combined.
[0178] Furthermore, some steps in the method embodiments can be equivalently replaced with other possible steps. Alternatively, some steps in the method embodiments may be optional and can be deleted in certain use cases. Or, other possible steps may be added to the method embodiments.
[0179] Furthermore, the various method embodiments can be implemented individually or in combination.
[0180] It is understood that the electronic device in the embodiments of this application includes hardware structures and / or software modules corresponding to the execution of each function in order to achieve the above-mentioned functions. Based on the units and algorithm steps of the various examples described in the embodiments disclosed in this application, the embodiments of this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the technical solution of the embodiments of this application.
[0181] This application embodiment can divide the electronic device into functional units according to the above method example. For example, each function can be divided into a separate functional unit, or two or more functions can be integrated into one processing unit. The integrated unit can be implemented in hardware or as a software functional unit. It should be noted that the unit division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0182] Figure 15 A schematic block diagram of a memory management device provided in an embodiment of this application is shown. This device can be the aforementioned electronic device or a component with corresponding functions. The device 1700 can exist in software form or as a chip usable in a device. The device 1700 includes a processing unit 1702.
[0183] Processing unit 1702 can be used to support Figure 10 S101, S103, S104, etc., shown, and / or other processes used in the scheme described herein.
[0184] In some embodiments, the device 1700 may further include a communication unit 1703. Optionally, the communication unit 1703 may further be divided into a transmitting unit (not included in the main unit). Figure 15 (shown in) and receiving unit (not shown in) Figure 15 (As shown in the diagram). The transmitting unit supports the device 1700 in transmitting information to other electronic devices. The receiving unit supports the device 1700 in receiving information from other electronic devices.
[0185] In some embodiments, the device 1700 may further include a storage unit 1701 for storing program code and data of the device 1700, the data including but not limited to raw data or intermediate data.
[0186] In one possible approach, the processing unit 1702 may be a controller or Figure 6 The processors 401 and / or 408 shown may be, for example, a Central Processing Unit (CPU), a general-purpose processor, a Digital Signal Processing (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. They can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor may also be a combination that implements computational functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0187] In one possible embodiment, the communication unit 1703 may include Figure 6 The transceiver 404 shown may also include transceiver circuits, radio frequency devices, etc.
[0188] In one possible approach, storage unit 1701 can be Figure 6 The memory 403 shown.
[0189] This application also provides an electronic device, including one or more processors and one or more memories. The one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program code, including computer instructions. When the one or more processors execute the computer instructions, the electronic device performs the aforementioned method steps to implement the methods in the above embodiments.
[0190] This application also provides a chip system, such as... Figure 16 As shown, the chip system includes at least one processor 1401 and at least one interface circuit 1402. The processor 1401 and the interface circuit 1402 are interconnected via lines. For example, the interface circuit 1402 can be used to receive signals from other devices (e.g., the memory of an electronic device). As another example, the interface circuit 1402 can be used to send signals to other devices (e.g., the processor 1401). Exemplarily, the interface circuit 1402 can read instructions stored in the memory and send those instructions to the processor 1401. When the instructions are executed by the processor 1401, the electronic device can perform the steps in the above embodiments. Of course, the chip system may also include other discrete devices, and this application embodiment does not specifically limit this.
[0191] This application also provides a computer-readable storage medium including computer instructions that, when executed on the electronic device, cause the electronic device to perform various functions or steps performed by the mobile phone in the above method embodiments.
[0192] This application also provides a computer program product that, when run on a computer, causes the computer to perform the various functions or steps performed by the mobile phone in the above method embodiments.
[0193] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0194] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0195] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0196] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0197] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially or in other words, the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0198] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0199] It should be understood that each step in the above method embodiments can be completed by integrated logic circuits in the processor hardware or by instructions in software form. The method steps disclosed in the embodiments of this application can be directly manifested as being executed by a hardware processor, or being executed by a combination of hardware and software modules in the processor.
[0200] This application also provides a computer-readable storage medium storing computer instructions. When the computer instructions are executed on an electronic device, the electronic device performs the aforementioned method steps to implement the methods described in the above embodiments.
[0201] This application also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned steps to implement the methods described in the above embodiments.
[0202] In addition, embodiments of this application also provide an apparatus, which may specifically be a component or module. The apparatus may include a connected processor and a memory; wherein the memory is used to store computer execution instructions, and when the apparatus is running, the processor may execute the computer execution instructions stored in the memory to cause the apparatus to perform the methods in the above-described method embodiments.
[0203] In this application, the electronic device, computer-readable storage medium, computer program product or chip provided in the embodiments are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0204] It is understood that, in order to achieve the above functions, the electronic device includes hardware and / or software modules that perform the respective functions. Based on the algorithmic steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is implemented in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.
[0205] This embodiment can divide the electronic device into functional modules according to the above method example. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into one processing module. The integrated modules can be implemented in hardware. It should be noted that the module division in this embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0206] Through the above description of the embodiments, those skilled in the art will clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In practical applications, the above functions can be assigned to different functional modules as needed, and the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device, and unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0207] In the several embodiments provided in this application, it should be understood that the disclosed methods can be implemented in other ways. For example, the terminal device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of modules or units may be electrical, mechanical, or other forms.
[0208] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0209] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0210] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program instructions, such as flash memory, portable hard disk, read-only memory, random access memory, magnetic disk, or optical disk.
[0211] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A thread scheduling method, characterized in that, The method is applied to an electronic device, and the method includes: The electronic device receives a first operation, the first operation including the operation of starting or closing a first application; The electronic device detects that the first thread has been in a ready state on the first processing unit for a period of time exceeding a threshold, and that a second thread is running on the first processing unit; the first thread is a thread of a preset type, the second thread is a real-time thread, and the first thread includes a synthesis thread or a display thread; the priority of the first thread is lower than the priority of the second thread; The electronic device migrates the first task of the first thread to the second processing unit, so that the first thread executes the first task associated with the first operation on the second processing unit, the first task including a layer compositing task or a display task; Display the startup or shutdown animation of the first application on the screen.
2. The method according to claim 1, characterized in that, The second processing unit runs a third thread, the priority of which is lower than that of the first thread; The first thread executes a first task associated with the first operation on the second processing unit, including: the first thread preempting the third thread and executing the first task on the second processing unit.
3. The method according to claim 1 or 2, characterized in that, When the first operation includes launching the first application, the first task is a layer compositing task; The first thread executes the first task associated with the first operation on the second processing unit, including: the first thread synthesizing the startup animation of the first application on the second processing unit.
4. The method according to claim 1 or 2, characterized in that, When the first operation includes launching the first application, the first task is a display task. The first thread executes a first task associated with the first operation on the second processing unit, including: the first thread transmitting the startup animation of the first application to the display screen on the second processing unit.
5. The method according to claim 1 or 2, characterized in that, When the first operation includes closing the first application, the first task is a layer compositing task; The first thread executes a first task associated with the first operation on the second processing unit, including: the first thread synthesizing a closing animation of the first application on the second processing unit.
6. The method according to claim 1 or 2, characterized in that, When the first operation includes closing the first application, the first task is a display task; The first thread executes a first task associated with the first operation on the second processing unit, including: the first thread transmitting the closing animation of the first application to the display screen on the second processing unit.
7. The method according to claim 1 or 2, characterized in that, The preset fields of the first thread are set to preset values.
8. An electronic device, characterized in that, include: A processor and a memory, the memory being coupled to the processor, the memory being used to store computer program code, the computer program code including computer instructions, the processor reading the computer instructions from the memory to cause the electronic device to perform the method as described in any one of claims 1-7.
9. A computer-readable storage medium, characterized in that, Includes computer instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1-7.
10. A computer program product, characterized in that, When the computer program product is run on an electronic device, it causes the electronic device to perform the method as described in any one of claims 1-7.
Citation Information
Patent Citations
Thread scheduling method and device, storage medium and electronic equipment
CN111813521A