Thread scheduling method and related device

By creating an associated thread group in the terminal device and scheduling threads to the target CPU, the low frequency problem caused by threads running on different CPUs is solved, reducing frame loss rate and improving user experience.

CN119829225APending Publication Date: 2025-04-15HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311332730.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-13
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

In terminal devices, when threads run on different CPUs, the CPU runs at a low frequency, which may cause frame drops during interface display, affecting the user experience.

Method used

By detecting the boot event, an associated thread group (RTG) is created, multiple threads used to perform the display tasks are scheduled to the target CPU, and their operating frequency is adjusted according to the load status of the target CPU.

Benefits of technology

It increases the load and operating frequency of the target CPU, reduces the probability of frame drop during interface display, and thus improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829225A_ABST
    Figure CN119829225A_ABST
Patent Text Reader

Abstract

The invention provides a thread scheduling method and a related device, the method is applied to terminal equipment, and the method comprises the steps that when a startup event is detected, an associated thread group is created, the associated thread group comprises a plurality of threads, and the threads are used for executing a display task; scheduling the plurality of threads to a target CPU (Central Processing Unit); and adjusting the operation frequency of the target CPU according to the load condition of the target CPU. According to the embodiment of the invention, the plurality of threads for executing the display task form the associated thread group, and the plurality of threads are scheduled to the same CPU (namely the target CPU), so that the load can be improved, the operation frequency of the target CPU can be improved, the probability of frame loss can be reduced, and the user experience can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminal technology, and in particular to a thread scheduling method and related devices. Background Art

[0002] With the development of Internet technology, the functions of terminal devices are becoming more and more diversified, and the performance of processors is also improving. The central processing unit (CPU) of the terminal device is its control core, which is mainly used to realize information processing and program operation.

[0003] In general, different threads may run on different CPUs. For example, thread 0 runs on CPU 0 and thread 1 runs on CPU 1. After thread 0 runs for a period of time, thread 1 is awakened and thread 0 goes to sleep. Similarly, after thread 1 runs for a period of time, thread 0 is awakened and thread 1 goes to sleep. In this way, the loads of CPU 0 and CPU 1 are not high, and the CPU operating frequency is low. In some scenarios (such as the displayed scenario), assuming that thread 0 and thread 1 are threads for executing display tasks and thread 0 and thread 1 run on different CPUs, it is likely that frame loss will occur due to the low CPU operating frequency.

[0004] Therefore, it is hoped to provide a method to reduce the probability of frame loss during interface display, thereby improving user experience. Summary of the invention

[0005] The present application provides a thread scheduling method and related devices, in order to reduce the probability of frame loss during interface display, thereby improving user experience.

[0006] On the first aspect, the present application provides a thread scheduling method, which can be executed by a terminal device, or the method can also be executed by a component configured in the terminal device (such as a chip, a chip system, etc.), or it can also be implemented by a logic module or software that can realize all or part of the terminal device functions, and the present application does not limit this.

[0007] Exemplarily, the method includes: when a power-on event is detected, creating a related thread group (RTG), the RTG including multiple threads, the multiple threads being used to execute display tasks; scheduling the multiple threads to a target CPU; and adjusting the operating frequency of the target CPU according to the load condition of the target CPU.

[0008] In the above technical solution, RTG is created when a power-on event is detected, and multiple threads used to execute display tasks are composed of RTG. Since these multiple threads are divided into a group, these multiple threads are scheduled to the same CPU (that is, the target CPU), and the load of the target CPU will increase. In this way, the operating frequency of the target CPU will be increased, which will help reduce the probability of frame loss and improve the user experience.

[0009] It should be understood that the above-mentioned multiple threads are scheduled to the target CPU, which can be a large core, a small core or a medium core, and this application does not limit this. The CPU large core, small core and medium core refer to the number of cores used by the processor, that is, the smallest unit that can complete command processing. The more cores there are, the stronger the CPU computing power is and the higher the computing speed is. In this application, the large core can be regarded as a group, called a CPU cluster, and similarly, the small core can be regarded as a group, called a CPU cluster, and the medium core can be regarded as a group, called a CPU cluster.

[0010] In combination with the first aspect, in some possible implementations, the target CPU corresponds to a scheduling parameter.

[0011] The target CPU corresponds to the scheduling parameter, and it can be understood that the target CPU can be different when the scheduling parameter is different. In other words, the terminal device can schedule the multiple threads to different CPUs according to the scheduling parameter. For example, the terminal device can predefine the initial value of the scheduling parameter when it is turned on, and according to the initial value of the scheduling parameter, the terminal device can schedule the multiple threads to the corresponding target CPU.

[0012] In combination with the first aspect, in some possible implementations, the scheduling parameters include one or more of the following: sampling duration, load clamping (uclamp), minimum thread priority (minutil), or maximum running time (margin).

[0013] The sampling duration may also be referred to as a sampling window, or a load window, etc., and this application does not specifically limit its name. The sampling duration refers to the time window of each sampling, and accordingly, the load condition refers to the duration that the target CPU is in the running state within the time window. In this application, the duration that multiple threads in the same RTG are in the running state within the time window is calculated uniformly. In other words, the load condition includes the sum of the duration that each thread in the multiple threads is in the running state within the time window.

[0014] Load clamping is used to limit the CPU usage. Load clamping can be used to define the maximum and minimum CPU usage of display tasks under different loads. By setting the load clamping parameter, it is helpful to ensure that the display task does not occupy excessive CPU resources when executing, thereby improving the overall performance and responsiveness of the system.

[0015] The minimum value of the thread priority refers to the minimum value of the priorities corresponding to multiple threads. For example, the thread priority range is 1 to 10, where 1 is the lowest priority and 10 is the highest priority. The terminal device can schedule multiple threads according to the thread priority.

[0016] The maximum run time is the maximum run time allocated to each thread.

[0017] It is understandable that the above scheduling parameters are some parameters used in the thread scheduling process, but this should not constitute any limitation to this application. In practical applications, the scheduling parameters may also include other parameters, such as a scheduling policy.

[0018] In combination with the first aspect, in some possible implementations, the above-mentioned sampling duration decreases as the refresh rate of the terminal device increases; the minimum values ​​of load clamping and thread priority increase as the refresh rate of the terminal device increases. For example, the terminal device predefines the minimum values ​​of the sampling duration, load clamping, and thread priority when booting up. When the refresh rate of the terminal device changes, the sampling duration decreases as the refresh rate of the terminal device increases, and the minimum values ​​of load clamping and thread priority increase as the refresh rate of the terminal device increases.

[0019] It is understandable that the terminal device can automatically adjust the refresh rate according to the needs of the current application. For example, when an interactive intensive application (such as a desktop) is started, the refresh rate can be increased to provide a better user experience, while in other applications (such as video applications), the refresh rate can be automatically reduced to save power consumption. Under different refresh rates, the required CPU operating frequency is different (such as a low refresh rate in a simple rendering scene, and the required CPU operating frequency is low). If the CPU operating frequency is the same, it is likely to waste power. Therefore, in this application, when the refresh rate of the terminal device changes, the sampling duration, load clamping, and the minimum value of the thread priority are dynamically adjusted. The CPU load condition is related to the above-mentioned scheduling parameters. In this way, the CPU load condition is different, and then the CPU operating frequency is different. In other words, according to the change in the refresh rate, the above-mentioned scheduling parameters are dynamically adjusted, and then the CPU operating frequency is dynamically adjusted to reduce power consumption waste.

[0020] In combination with the first aspect, in some possible implementations, the maximum running time is determined according to the number of buffers; and the maximum running time increases as the number of buffers increases.

[0021] In combination with the first aspect, in some possible implementations, the multiple threads are predefined core threads for executing display tasks.

[0022] The multiple threads may be core threads (or key threads) for executing display tasks, including but not limited to: a frame drawing main thread, a rendering thread, etc.

[0023] Optionally, the operating frequency of the target CPU increases as the load of the target CPU increases. That is, if the load of the target CPU increases, the operating frequency of the target CPU is increased; if the load of the target CPU decreases, the operating frequency of the target CPU is decreased.

[0024] In a second aspect, the present application provides a terminal device that can implement the method described in the first aspect and any possible implementation of the first aspect. The device includes a corresponding module for executing the above method. The module included in the terminal device can be implemented by software and / or hardware.

[0025] In a third aspect, the present application provides a terminal device, the terminal device comprising a processor. The processor is coupled to a memory and can be used to execute a computer program in the memory to implement the method in the first aspect and any possible implementation of the first aspect.

[0026] Optionally, the terminal device further includes a communication interface, and the processor is coupled to the communication interface. The communication interface is used to receive signals from other communication devices outside the device and transmit them to the processor, or send signals from the processor to other communication devices outside the device. Exemplarily, the communication interface can be a transceiver, circuit, bus, module or other type of communication interface.

[0027] Optionally, the terminal device further includes a memory, and the processor is coupled to the memory. The memory is used to store program instructions and data.

[0028] In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program or instructions. When the computer program or instructions are executed, the method in the first aspect and any possible implementation manner of the first aspect is implemented.

[0029] In a fifth aspect, the present application provides a computer program product, which includes instructions. When the instructions are executed, the method in the first aspect and any possible implementation manner of the first aspect is implemented.

[0030] In a sixth aspect, the present application provides a chip system comprising at least one processor for supporting the implementation of the functions involved in the above-mentioned first aspect and any possible implementation method of the first aspect, for example, receiving or processing the data involved in the above-mentioned method, etc.

[0031] In one possible design, the chip system also includes a memory, which is used to store program instructions and data, and the memory is located inside or outside the processor.

[0032] The chip system may be composed of the chip, or may include the chip and other discrete devices.

[0033] It should be understood that the second to sixth aspects of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0035] Figure 2 It is a structural block diagram of the software of the terminal device provided in the embodiment of the present application;

[0036] Figure 3 It is a schematic diagram of a thread running on a CPU provided by an embodiment of the present application;

[0037] Figure 4 It is a flame diagram provided by an embodiment of the present application;

[0038] Figure 5 is a schematic diagram of the structure of a terminal device provided in an embodiment of the present application;

[0039] Figure 6 is a schematic flow chart of a thread scheduling method provided in an embodiment of the present application;

[0040] Figure 7 is another flame diagram provided by an embodiment of the present application;

[0041] Figure 8 It is a schematic diagram of the interaction of various modules provided in the embodiments of the present application. DETAILED DESCRIPTION

[0042] The technical solution in this application will be described below in conjunction with the accompanying drawings.

[0043] To facilitate understanding of the embodiments of the present application, the following description is first made:

[0044] First, in this application, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship, but it does not exclude the situation where the previous and next associated objects are in an "and" relationship. The specific meaning can be understood in combination with the context. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can mean: a, b, c; a and b; a and c; b and c; or a and b and c. Where a, b, c can be single or multiple.

[0045] Second, in the present application, "when", "assuming", "if", "under the circumstances" and "if" all mean that the device will take corresponding actions under certain objective circumstances, but do not limit the time, nor do they require that the device must make a judgment when it is implemented, nor do they mean that there are other limitations.

[0046] Third, in the embodiments of the present application, the terminal device may also be referred to as user equipment (UE), access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication equipment, user agent or user device, etc., which is not limited to the embodiments of the present application.

[0047] In the embodiments of the present application, the types of terminal devices include, but are not limited to: mobile phones, tablet computers, computers with wireless transceiver functions (such as laptops, PDAs, etc.), mobile Internet devices (MID), virtual reality (VR) devices, augmented reality (AR) devices, wireless terminals in industrial control, wireless terminals in self-driving, wireless terminals in remote medical, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, cellular phones, cordless phones, session initiation protocol (SIP) phones, wireless local loop (WLL) stations, personal digital assistants (PDAs), handheld devices with wireless communication functions, computing devices or other processing devices connected to wireless modems, vehicle-mounted devices, wearable devices, fifth generation (5th generation) The present invention relates to terminals in the 5G generation (5G) network or terminals in the future evolved public land mobile network (PLMN), laptop computers, machine type communication (MTC) terminals, etc.

[0048] In addition, the terminal device can also be a terminal device in the Internet of Things (IoT) system. IoT is an important part of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, thereby realizing an intelligent network of human-machine interconnection and object-to-object interconnection. IoT technology can achieve massive connections, deep coverage, and terminal power saving through narrowband (NB) technology, for example.

[0049] Figure 1 1 is a schematic diagram of the hardware structure of the terminal device 100 provided in the embodiment of the present application. Figure 1 Describe in detail the possible hardware structure of the terminal device.

[0050] For example, Figure 1FIG. 1 shows a schematic diagram of the structure of the terminal device 100. Figure 1 As shown, the terminal device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a SIM card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

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

[0052] The application processor outputs sound signals through the audio module 170 (such as the speaker 170A, etc.), or displays images or videos through the display screen 194.

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

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

[0055] The processor 110 can perform different operations to achieve different functions by executing instructions. The instructions can be, for example, instructions pre-stored in the memory before the device leaves the factory, or instructions read from the APP after the user installs a new application (APP) during use, and the embodiments of the present application do not impose any limitation on this.

[0056] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a secure digital input and output interface (SDIO), a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a universal synchronous asynchronous receiver / transmitter (USART), a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a SIM interface, and / or a USB interface, etc.

[0057] The USB interface 130 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the terminal device 100, and can also be used to transmit data between the terminal device 100 and peripheral devices. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.

[0058] It is understandable that the interface connection relationship between the modules illustrated in the present application is only a schematic illustration and does not constitute a structural limitation on the terminal device 100. In other embodiments, the terminal device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0059] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the terminal device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device through the power management module 141.

[0060] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193 and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.

[0061] The wireless communication function of the terminal device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0062] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in terminal device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.

[0063] The mobile communication module 150 can provide wireless communication solutions including 2G / 3G / 4G / 5G etc. applied on the terminal device 100 .

[0064] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN), such as wireless fidelity (Wi-Fi) networks, Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., applied to the terminal device 100. 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 the antenna 2, modulates the frequency of the electromagnetic wave signal and filters it, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0065] In some embodiments, the antenna 1 of the terminal device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the terminal device 100 can communicate with the network and other devices through 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), fifth generation (5G) communication system, BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. The GNSS may include a global positioning system (GPS), a GNSS, a BeiDou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).

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

[0067] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. It should be understood that the display screen 194 may also include more components. For example, a backlight plate, a drive circuit, etc. Among them, the backlight plate can be used to provide a light source, and the display panel emits light based on the light source provided by the backlight plate. The drive circuit can be used to control whether the liquid crystal of the liquid crystal layer is light-transmissive or light-proof.

[0068] The terminal device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.

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

[0070] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the terminal device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area can store data created during the use of the terminal device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0071] The terminal device 100 can implement audio functions such as music playing and recording through the audio module 170, such as the speaker 170A, the receiver 170B, the microphone 170C and the earphone interface 170D, and the application processor.

[0072] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to or disconnected from the terminal device 100 by inserting the SIM card interface 195 or pulling the SIM card interface 195 out. The terminal device 100 can support one or more SIM card interfaces. 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 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The terminal device 100 interacts with the network through the SIM card to implement functions such as calls and data communications.

[0073] It is to be understood that the structure illustrated in the present application does not constitute a specific limitation on the terminal device 100. In other embodiments, the terminal device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0074] In addition, the operating system of the terminal device may be an Android operating system (Android OS), a Harmony OS, an open source Harmony OS, etc. The present application embodiment does not impose any limitation on this.

[0075] Figure 2 It is a structural block diagram of the software of the terminal device provided in the embodiment of the present application. It can be understood that Figure 2 Taking the layered architecture Android system as an example, the software structure of the terminal device is exemplified. Among them, this application does not limit the type of operating system of the terminal device.

[0076] like Figure 2 As shown, the layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (Android runtime) and the system library, and the kernel layer.

[0077] The application layer can include a series of application packages. Figure 2 As shown, the application layer may include lock screen applications, desktop applications, etc. Desktop applications may further include applications such as camera, gallery, calendar, call, map, navigation, Bluetooth, music, video, game, shopping, travel, instant messaging (such as short messages, WeChat, etc.), smart home, device control, etc.

[0078] The application framework layer provides application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions. Figure 2As shown, the application framework layer may include input management service (IMS), display policy service, power management service (PMS), display management service (DMS), activity management service, resource management service, content provisioning service, view system, phone management service, notification management service, window management service, process management service, drawing service, etc. ( Figure 2 Some services are shown as examples in FIG. 1 ). The embodiments of the present application do not impose any limitation on this.

[0079] The window management service can be used to manage window programs. The window management service can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.

[0080] Content provisioning services can be used to store and retrieve data and make it accessible to applications. The data may include video, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0081] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.

[0082] The call management service is used to provide communication functions of the electronic device 100, such as the management of call status (including answering, hanging up, etc.).

[0083] The resource management service provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.

[0084] The notification management service enables applications to display notification information in the status bar. It can be used to convey notification-type messages, and can stay for a short time and then disappear automatically without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.

[0085] The drawing service can be used to draw the interface. For example, the drawing service can convert the application layout and resources into a format that can be recognized by the display service of the kernel layer. The drawing service can send the drawn interface to the display service of the kernel layer, thereby realizing the display of the drawn interface.

[0086] It is understood that the above services are only examples and should not constitute any limitation to the embodiments of the present application. For example, the application framework layer may also include a resource scheduling subsystem, which is responsible for the scheduling and management of the CPU, memory, and storage resources in the system, including the grouping of tasks, priority management, and management of background tasks. On the basis of ensuring smooth foreground operations, a smooth running environment is provided for background multitasking.

[0087] Exemplarily, the resource scheduling subsystem specifically includes a scene perception module, a frame perception module, a scheduling parameter control module and an RTG group management module. Among them, the scene perception module is used to perceive events such as terminal device startup, foreground and background switching, system anomalies, and issue event notifications. The frame perception module is used to perceive the drawing of the foreground application and the change of the refresh rate of the screen. The scheduling parameter control module is used to send scheduling parameters to the kernel. The RTG group management module is used to create an RTG after receiving a power-on event notification from the scene perception module. The RTG includes multiple threads, and the multiple threads are used to perform display tasks. Optionally, the multiple threads can be core threads for performing display tasks. The RTG group management module can also be used to add a thread to the RTG or remove a thread from the RTG. For example, if a core thread exits abnormally, the core thread is removed from the RTG, and after the thread is restarted, the thread is added to the RTG.

[0088] The Android runtime can include core libraries and virtual machines. The Android runtime is responsible for scheduling and management of the Android system.

[0089] The core library can include two parts: one part is the function that needs to be called by the Java language, and the other part is the core library of the Android system.

[0090] The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0091] The system library may include multiple functional modules, such as status monitoring services, surface managers, media libraries, 3D graphics processing libraries (eg, OpenGL ES), 2D graphics engines (eg, SGL), etc.

[0092] The status monitoring service is used to determine the specific orientation of the mobile phone, the physical state of the flexible screen, etc. based on the monitoring data reported by the kernel layer. The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D (3D) layers for multiple applications. The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files. The media library can support a variety of audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis and layer processing. The 2D graphics engine is a drawing engine for 2D drawing.

[0093] The kernel layer is a layer between hardware and software. The kernel layer at least includes power management services, sensor services (also called sensor drivers), display services (also called display drivers), camera drivers, audio drivers, etc. The present application embodiment does not impose any restrictions on this.

[0094] In an embodiment of the present application, the kernel layer may further include a kernel subsystem, which is used to provide basic kernel capabilities to the upper layer, including process and / or thread management, memory management, file system, network management, and peripheral management. The kernel subsystem specifically includes a scheduling module and a control group (Cgroup) module. Among them, the scheduling module is used to count the task load and schedule each thread to the CPU according to a predefined scheduling policy. The Cgroup module is used to perform unified resource monitoring and restriction on a group of processes to achieve refined control of resources such as CPU and memory.

[0095] The system library and kernel layer below the application framework layer are referred to as the underlying system. The underlying system includes an underlying display system for providing display services, for example, the underlying display system includes a display driver in the kernel layer and a surface manager in the system library.

[0096] It should be understood that Figure 1 and Figure 2 The structure of the terminal device described is only an example and should not limit the embodiments of the present application. In practical applications, the structure of the terminal device may also be divided into other types, which is not limited in the present application.

[0097] To facilitate understanding, the following is a brief explanation of the terms involved in this application.

[0098] 1. RTG: refers to a thread group composed of associated threads. The terminal device can divide RTG according to the task type (or business type). For example, threads used to perform display tasks can form an RTG. For another example, threads used to perform tasks with frequent calculations can form an RTG. For another example, threads used to perform tasks with frequent input (I) / output (O) can form an RTG. In this application, the threads used by the terminal device to perform display tasks can form an RTG.

[0099] One advantage of RTG is core selection optimization. Threads in the same RTG can be scheduled to the same CPU. For example, multiple threads for executing display tasks can form an RTG, and the multiple threads can be scheduled to the same CPU (i.e., the target CPU). The target CPU can be a large core, a small core, or a medium core, which is not limited in this application. There may be data sharing between them. The large core, small core, and medium core of the CPU refer to the number of cores used by the processor, that is, the smallest unit that can complete command processing. The more cores there are, the stronger the CPU computing power is and the higher the computing speed is. In this application, the large core can be regarded as a group, called a CPU cluster. Similarly, the small core can be regarded as a group, called a CPU cluster, and the medium core can be regarded as a group, called a CPU cluster. For a certain CPU cluster, there is a shared cache memory (cache) between the cores in the CPU cluster, so these cache memories can be reasonably used to improve performance and reduce power consumption.

[0100] For example, if the CPU small cores share a cache memory, and the calculation result of thread 0 is given to thread 1, if both thread 0 and thread 1 are running on the CPU small core, they can be easily obtained because they are in the same cache memory. If the two threads are not running in the same CPU cluster, the calculation result of thread 0 needs to be moved from one cache memory to another, resulting in greater latency and lower performance.

[0101] Another advantage of RTG is aggregate frequency modulation. Multiple threads in the same RTG can jointly calculate the load to optimize the dynamic clock and voltage scaling (DCVS) frequency modulation. In more detail, the greater the load, the higher the CPU operating frequency is adjusted. Since multiple threads in the same RTG can jointly calculate the load, the load will increase and the CPU operating frequency will also increase accordingly.

[0102] The following will be combined Figure 3 Explain the advantages of RTG in detail.

[0103] Figure 3This is a schematic diagram of a thread running on a CPU provided in an embodiment of the present application.

[0104] like Figure 3 As shown in a) in , thread 0 runs on CPU 0, as shown in Figure 3 As shown in b), thread 1 runs on CPU 1, where thread 0 wakes up thread 1 after running for a while and thread 0 sleeps. Similarly, thread 1 wakes up thread 0 after running for a while and thread 1 sleeps. In this way, the load of CPU 0 and CPU 1 is not high, or in other words, the utilization rate of CPU 0 and CPU 1 is not high, and the CPU running frequency is low. However, if both thread 0 and thread 1 run on the same CPU (such as CPU 0), Figure 3 As shown in c), the load (or utilization rate) of CPU 0 will be higher, and the operating frequency of the CPU will be higher.

[0105] 2. Sampling window and load within the sampling window: The sampling window can be understood as the time window for each sampling. The sampling window can also be called the sampling duration, or the load window, etc. This application does not specifically limit its name. Correspondingly, the load refers to the length of time that the CPU is in the running state within the time window. In this application, for multiple threads in the same RTG, the length of time that the CPU is in the running state within the time window is calculated uniformly. In other words, the load includes the sum of the length of time that each of the multiple threads is in the running state within the time window.

[0106] 3. Frequency point and frequency: The frequency point refers to a specific absolute frequency value, which is a number given to a fixed frequency. For example, the terminal device can divide the frequency range of the CPU when it is working, and the frequency range can be divided according to a certain frequency interval to obtain multiple frequency bands. Each frequency band can be set with a number as a frequency point. The frequency point can correspond to a frequency value, which can be the maximum value in the frequency range. This application does not limit this.

[0107] 4. Frequency increase: Increase the CPU's operating frequency (also referred to as frequency). At present, the minimum computing power requirements for test data can be manually calculated. For example, after manual calculation, in certain scenarios, such as dragging and sliding a small window in the taskbar to display a new frame of an image, a computing power of 800 megahertz (MHz) is required for the middle core. If the current computing power does not meet the calculated minimum computing power requirement, the thread used to execute the display task will be scheduled to the middle core, and an instruction will be issued to instruct the frequency to be increased to 800MHz.

[0108] The following will be combined Figure 4 , describe in detail the above-mentioned scheme of manual calculation with minimum computing power requirements.

[0109] Figure 4 It is a flame graph provided in an embodiment of the present application.

[0110] The flame graph can be used to indicate how busy the CPU is, the name of the function the CPU is executing, and the call stack. The vertical axis represents the call stack, and each layer is a function. The deeper the call stack, the higher the flame. The top is the function being executed, and the bottom is its parent function. The horizontal axis represents the execution time. Figure 4 In the figure, different fills represent different functions, and the black rectangular frame represents that the thread is in running state.

[0111] like Figure 4 As shown, the time used to display a frame of image is 11.2 milliseconds (millisecond, ms), and the corresponding frequency point is 633600 kilohertz (kilohertz, kHz). The computing power requirement is manually calculated = 809×(11.2÷8.3)=1091, where 809 is the computing power corresponding to the frequency point of 633600kHz, and 8.3 is 1000 / 120=8.3ms for one frame when the refresh rate is 120Hz. The corresponding frequency point when the computing power is 1091 is 800MHz. It can be seen that the time used for this frame of image is actually 11.2ms, which should be completed in 8.3ms according to the calculation. Therefore, the computing power is insufficient, the operating frequency is low, and the time of the next frame is occupied. Therefore, it is likely to cause the next frame to be lost. Among them, the corresponding relationship between the frequency point and the computing power is shown in Table 1. Table 1 shows the computing power corresponding to different frequency points in the case of a CPU core.

[0112] Table 1

[0113]

[0114] It is understandable that Table 1 only shows the computing power, power consumption and other parameters corresponding to some frequency points, but this should not constitute any limitation to this application. In addition, the computing power corresponding to the same frequency point of different manufacturers may also be different, which is not limited in this application.

[0115] In order to reduce the probability of frame loss when the interface is displayed, the present application provides a thread scheduling method, which creates an RTG when a power-on event is detected, and multiple threads used to execute display tasks form the RTG. Since these multiple threads are grouped together, these multiple threads are scheduled to the same CPU, and the CPU load will increase. In this way, the CPU operating frequency will increase, which will help reduce the probability of frame loss and improve the user experience.

[0116] Before describing in detail the thread scheduling method provided by the present application, each functional module in the terminal device provided by the present application is first described in detail.

[0117] Figure 5 It is a schematic diagram of the structure of the terminal device provided in an embodiment of the present application.

[0118] like Figure 5 As shown, the terminal device includes a resource scheduling subsystem and a kernel subsystem. The resource scheduling subsystem is used to undertake the scheduling management of the CPU, memory, and storage resources in the system, including task grouping, priority management, and background task management. On the basis of ensuring smooth foreground operation, it provides a smooth running environment for background multitasking.

[0119] Exemplarily, the resource scheduling subsystem specifically includes a scene perception module, a frame perception module, a scheduling parameter control module and an RTG group management module. Among them, the scene perception module is used to perceive events such as terminal device startup, front-end and back-end switching, system abnormalities, and issue event notifications. The frame perception module is used to perceive the drawing of the foreground application and the change of the screen refresh rate. The scheduling parameter control module is used to send scheduling parameters to the kernel. The RTG group management module is used to create an RTG after receiving a power-on event notification from the scene perception module. The RTG includes multiple threads, and the multiple threads are used to perform display tasks. Optionally, the multiple threads can be core threads for performing display tasks. The RTG group management module can also be used to add a thread to the RTG or remove a thread from the RTG. For example, if a core thread exits abnormally, the core thread is removed from the RTG. After the thread is restarted, the thread is added to the RTG. After the RTG group management module creates the RTG, it can also send group information to the control group module, and the group information may include the identifiers of the multiple threads included in the RTG.

[0120] The kernel subsystem is used to provide basic kernel capabilities to the upper layer, including process / thread management, memory management, file system, network management, and peripheral management. The kernel subsystem specifically includes a scheduling module and a control group module. Among them, the scheduling module is used to count the task load and schedule each thread to the CPU according to the pre-defined scheduling strategy. The control group module is used to uniformly monitor and limit resources for a group of processes, and realize refined control of resources such as CPU and memory.

[0121] The following will be combined with the accompanying drawings to describe in detail the thread scheduling method provided by the embodiment of the present application. It should be understood that the embodiment shown below describes the method from the perspective of the terminal device, but should not constitute any limitation on the execution subject of the method. As long as the program with the code of the method provided by the embodiment of the present application can be run, the method provided by the embodiment of the present application can be executed. For example, the terminal device can also be replaced by a component (such as a chip, a chip system, etc.) configured in the terminal device, or other functional modules that can call and execute the program. The embodiment of the present application does not limit this.

[0122] Figure 6 It is a schematic flowchart of a thread scheduling method 600 provided in an embodiment of the present application. Figure 6 The method 600 shown may include steps 610 to 630. Each step in the method 600 is described in detail below.

[0123] In step 610, when a power-on event is detected, an RTG is created, wherein the RTG includes a plurality of threads for executing display tasks.

[0124] It should be understood that each time the terminal device is powered on, the thread identifier (tid) of the thread may change. In other words, after the terminal device is powered on, the tid of the thread can be fixed. Therefore, when the terminal device detects a power-on event, it can create an RTG and add the tids of multiple threads for executing the display task to the RTG, that is, the RTG includes multiple threads for executing the display task.

[0125] After the terminal device is powered on, an RTG can be created, and multiple threads for executing display tasks can be added to the RTG. As an example and not a limitation, the scene perception module in the terminal device can sense that the terminal device is powered on, and then notify the RTG group management module of the power-on event. For example, the scene perception module can send a power-on event notification to the RTG group management module. After receiving the above-mentioned power-on event notification, the RTG group management module creates an RTG and adds multiple threads for executing display tasks to the RTG.

[0126] Optionally, the multiple threads mentioned above may be core threads (or key threads) for executing display tasks.

[0127] Among them, in this application, the display task includes multiple parts such as layout, drawing, rendering, and display sending. The core thread can be understood as a thread used to complete functions such as layout, drawing, rendering, and display sending.

[0128] In step 620, the multiple threads are scheduled onto the target CPU.

[0129] The above multiple threads are scheduled to the same CPU (ie, the target CPU), and these threads can unify the computing load.

[0130] It should be understood that the above-mentioned multiple threads are scheduled to the target CPU, which can be a large core, a small core or a medium core, and this application does not limit this. In this application, the large core can be regarded as a group, called a CPU cluster, similarly, the small core can be regarded as a group, called a CPU cluster, and the medium core can be regarded as a group, called a CPU cluster.

[0131] Exemplarily, after the terminal device adds multiple threads for executing the display task to the RTG, the multiple threads may be scheduled to the target CPU.

[0132] Optionally, the target CPU corresponds to a scheduling parameter.

[0133] The above-mentioned target CPU corresponds to the scheduling parameters. It can be understood that different values ​​of the scheduling parameters may lead to different target CPUs. In other words, the terminal device may schedule the above-mentioned multiple threads to the target CPU according to the scheduling parameters.

[0134] Exemplarily, the initial value of the scheduling parameter at startup can be predefined in the terminal device, and according to the initial value of the scheduling parameter, the terminal device can schedule the above-mentioned multiple threads to the target CPU. Among them, when the terminal device schedules the above-mentioned multiple threads, it can also consider the busyness, the operation status of the whole machine, etc., and schedule them. In this application, when the refresh rate increases, the operating frequency of the CPU can be increased by changing the value of the scheduling parameter; similarly, when the refresh rate decreases, the operating frequency of the CPU can also be reduced by changing the value of the scheduling parameter. The specific relationship between the refresh rate and the value of the scheduling parameter can be found in the description below.

[0135] It can be understood that in practical applications, different values ​​of the scheduling parameters may correspond to different scheduling strategies, and the terminal device may determine the corresponding scheduling strategy (such as scheduling the above-mentioned multiple threads to the small core, the medium core or the small core, etc.) according to the value of the scheduling parameter, and then schedule the multiple threads. This application does not limit the specific scheduling strategy.

[0136] Optionally, the scheduling parameters include one or more of the following: sampling duration, load clamping, minimum thread priority, or maximum running time.

[0137] The sampling duration may also be referred to as a sampling window, or a load window, etc., and this application does not specifically limit its name. The sampling duration refers to the time window of each sampling, and accordingly, the load condition refers to the duration that the target CPU is in the running state within the time window. In this application, for multiple threads in the same RTG, the duration that the target CPU is in the running state within the time window is calculated uniformly. In other words, the load condition includes the sum of the duration that each of the multiple threads is in the running state within the time window.

[0138] Load clamping is used to limit the CPU usage. Load clamping can be used to define the maximum and minimum CPU usage of display tasks under different loads. By setting the load clamping parameter, it is helpful to ensure that the display task does not occupy excessive CPU resources when executing, thereby improving the overall performance and responsiveness of the system.

[0139] The minimum value of thread priority refers to the minimum value of the priorities corresponding to multiple threads. For example, the thread priority range is 1 to 10, where 1 is the lowest priority and 10 is the highest priority. Terminal devices can schedule multiple threads based on the thread priorities. The maximum run time refers to the maximum run time allocated to each thread.

[0140] It is understandable that the above scheduling parameters are some parameters used in the thread scheduling process, but this should not constitute any limitation to this application. In practical applications, the scheduling parameters may also include other parameters, which are not limited in this application.

[0141] Optionally, the sampling duration decreases as the refresh rate of the terminal device increases; the minimum values ​​of load clamping and thread priority increase as the refresh rate of the terminal device increases.

[0142] Exemplarily, the terminal device may determine parameters such as sampling duration, load clamping, and the minimum value of thread priority according to the change of refresh rate. For example, when the refresh rate increases, the sampling duration is reduced, the load clamping is increased, and the minimum value of thread priority is increased. Conversely, when the refresh rate decreases, the sampling duration is increased, the load clamping is reduced, and the minimum value of thread priority is reduced.

[0143] It is understandable that the terminal device can automatically adjust the refresh rate according to the needs of the current application. For example, when an interactively intensive application (such as a desktop) is started, the refresh rate can be increased, while in other applications (such as video applications, especially when the video application is in a playing state), the refresh rate can be automatically reduced to save power consumption. Under different refresh rates, the required CPU operating frequency is different (such as a low refresh rate in a simple rendering scene, and a low required CPU operating frequency). If the CPU operating frequency is the same, it is likely to waste power. Therefore, in this application, when the refresh rate of the terminal device changes, the sampling duration, load clamping, and the minimum value of the thread priority are dynamically adjusted. The CPU load condition is related to the above-mentioned scheduling parameters. In this way, the CPU load condition is different, and then the CPU operating frequency is different. In other words, according to the change in the refresh rate, the above-mentioned scheduling parameters are dynamically adjusted, and then the CPU operating frequency is dynamically adjusted to reduce power consumption waste.

[0144] Exemplarily, the terminal device can dynamically adjust the sampling duration, load clamping, minimum thread priority, etc. when the refresh rate changes. For example, the refresh rate of the terminal device when it is turned on is 60 (hertz, Hz), and the terminal device can schedule the above multiple threads according to the value of the minimum value of the sampling duration, load clamping, and thread priority corresponding to the refresh rate. When the terminal device intelligently adjusts the refresh rate according to different scenarios, for example, when the terminal device video application is converted to a desktop application (the desktop application is intensively interactive, the required refresh rate is higher, and when the video application is in the playback state, the required refresh rate is relatively low), the refresh rate may change from 60Hz to 120Hz, and the terminal device can adjust the values ​​of the above parameters, schedule multiple threads, and then adjust the operating frequency of the CPU. It can be understood that the above parameters can affect the execution order and resource allocation of threads, thereby affecting the load of the CPU, and then affecting the operating frequency of the CPU.

[0145] Optionally, the maximum running time is determined according to the number of caches; and the maximum running time increases as the number of caches increases.

[0146] Exemplarily, the terminal device may determine the maximum running time according to the number of caches. For example, when the number of caches increases, the maximum running time may be increased, and conversely, when the number of caches decreases, the maximum running time may be reduced.

[0147] The terminal device can dynamically adjust the scheduling parameters according to the changes in refresh rate and cache quantity, and then schedule the multiple threads used to execute display tasks, so that the CPU operating frequency is dynamically adjusted to reduce power consumption.

[0148] In step 630, the operating frequency of the target CPU is adjusted according to the load condition of the target CPU.

[0149] The terminal device can dynamically adjust the operating frequency of the target CPU according to the current load conditions. When the load is high, the target CPU can increase the frequency to cope with more computing needs; when the load is low, the target CPU can reduce the frequency to save power. In this application, multiple threads in the same RTG run on the target CPU, and these multiple threads can calculate the load together, that is, the load of these multiple threads is accumulated to obtain the load of the target CPU, and then the operating frequency of the target CPU is adjusted according to the load condition of the target CPU.

[0150] Exemplarily, when the load of the terminal device increases, the operating frequency of the target CPU is increased; when the load decreases, the operating frequency of the target CPU is reduced. As an example and not a limitation, the adjustment module of the terminal device can increase the operating frequency of the target CPU when the load increases; when the load decreases, the operating frequency of the target CPU is reduced.

[0151] It can be understood that since multiple threads in the same RTG run on the same CPU, the load is relatively high and the CPU operating frequency increases faster, which is beneficial to reduce the probability of frame loss and improve user experience.

[0152] Figure 7 It is another flame diagram provided by an embodiment of the present application.

[0153] The flame graph can be used to show the CPU's busyness, the function name being executed by the CPU, and the call stack. The vertical axis represents the call stack, and each layer is a function. Figure 7 Only some functions are shown as examples, but this should not constitute any limitation to the present application. Figure 7 In , different fillings represent different functions.

[0154] like Figure 7 As shown, the multiple threads may be, for example, the main thread 1429, "renderEngine 1866" (thread 1866 in the figure), "composer-service 1486" (thread 1486 in the figure), "binder 1804" (thread 1804 in the figure), and "Crtc_commit 863" (thread 863 in the figure). Each thread runs for a period of time and sleeps for a period of time. For example, ① indicates that the main thread 1429 wakes up the thread 1804 to run, and the main thread 1429 sleeps, ② indicates that the calculation result of the thread 1804 is returned to the main thread 1429, the main thread 1429 runs, and the thread 1804 sleeps, ③ indicates that the main thread 1429 wakes up the thread 1866 to run, and the main thread 1429 sleeps, ④ indicates that the thread 1866 wakes up the main thread 1429 to run, and the thread 1866 sleeps, ⑤ indicates that the main thread 1429 wakes up the thread 1804 to run, and the main thread 1429 sleeps, ⑥ indicates that the thread 1804 wakes up the thread 1486 to run, and the thread 1804 sleeps, and ⑦ indicates that the thread 1486 wakes up the thread 863 to run, and the thread 1486 sleeps. If each thread is scheduled to a different CPU, the load is low, and the CPU's operating frequency is low, which is easy to cause frame loss.

[0155] If the above multiple threads are combined into RTG and scheduled to the same CPU, the load will be reduced, and the CPU operating frequency will be increased, which will reduce the possibility of frame loss and improve user experience.

[0156] Figure 8 It is a schematic diagram of the interaction of various modules provided in the embodiments of the present application.

[0157] In step 801, the scene perception module sends a power-on event notification to the RTG group management module. Correspondingly, the RTG group management module receives the power-on event notification.

[0158] The above power-on event notification is used to notify the RTG group management module that the terminal device has completed the power-on event.

[0159] In step 802, the RTG group management module creates an RTG and displays the core thread joining the RTG.

[0160] After receiving the power-on event notification, the RTG group management module creates an RTG and adds the core thread for executing the display task to the RTG.

[0161] In step 803, the RTG group management module sends group information to the control group module. Correspondingly, the control group module receives the above group information.

[0162] The grouping information includes, for example, a plurality of core threads included in the RTG, and may be, for example, tids of the plurality of core threads.

[0163] In step 804, the frame perception module monitors the refresh rate changes.

[0164] In step 805, the frame perception module sends a refresh rate change notification to the scheduling parameter control module.

[0165] This notification is used to notify the scheduling parameter control module that the refresh rate of the terminal device has changed.

[0166] In step 806, the scheduling parameter control module adjusts the scheduling parameters according to the change of the refresh rate to obtain updated values ​​of the scheduling parameters.

[0167] Exemplarily, the sampling duration decreases as the refresh rate of the terminal device increases; the minimum values ​​of load clamping and thread priority increase as the refresh rate of the terminal device increases.

[0168] The terminal device can determine parameters such as sampling duration, load clamping, and minimum thread priority according to the change of refresh rate. For example, when the refresh rate increases, the sampling duration is shorter, the load clamping is greater, and the minimum thread priority is greater.

[0169] The terminal device may also determine the maximum running time according to the number of caches. For example, when the number of caches increases, the maximum running time may be increased, and conversely, when the number of caches decreases, the maximum running time may be decreased.

[0170] After the terminal device adjusts the scheduling parameters (such as sampling duration, load clamping, minimum value of thread priority, and maximum running time) according to the above relationship, it obtains the updated value of the scheduling parameters.

[0171] In step 807, the scheduling parameter control module sends scheduling parameters to the scheduling module.

[0172] The scheduling parameter refers to the updated value of the scheduling parameter. The scheduling parameter control module sends the updated value of the scheduling parameter to the scheduling module so that the scheduling module can schedule the above-mentioned multiple core threads to the target CPU according to the updated value of the scheduling parameter, and adjust the operating frequency of the target CPU according to the load condition of the target CPU.

[0173] In step 808, the scheduling module obtains grouping information from the control group module, that is, determines which threads are in the same RTG. Then, the scheduling module schedules the threads for executing display tasks belonging to the same RTG to the target CPU according to the updated value of the scheduling parameter, and then adjusts the operating frequency of the target CPU.

[0174] Based on the above technical solution, RTG is created when a power-on event is detected, and multiple threads used to execute display tasks are composed of RTG. Since these multiple threads are divided into a group, these multiple threads are scheduled to the same CPU (that is, the target CPU), and the load of the target CPU will increase. In this way, the frequency of the target CPU will increase, which will help reduce the probability of frame loss and improve the user experience.

[0175] In addition, when the refresh rate of the terminal device changes, the scheduling parameters are adjusted. The CPU load condition is related to the scheduling parameters. In this way, the CPU load condition is different, and then the CPU operating frequency is different to reduce power consumption.

[0176] The present application also provides a terminal device that can implement Figure 6 or Figure 8 The method described in the embodiment shown. The terminal device includes a corresponding module for executing the above method. The module included in the device can be implemented by software and / or hardware.

[0177] The embodiment of the present application also provides a terminal device, which includes a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to call and execute the computer program, so that the terminal device can realize Figure 6 or Figure 8 The method described in the illustrated embodiment.

[0178] The present application also provides a chip system, which includes at least one processor for implementing the above Figure 6 or Figure 8 The functions involved in the methods described in the illustrated embodiments, for example, receive or process the data and / or information involved in the above methods.

[0179] In one possible design, the chip system also includes a memory, which is used to store program instructions and data, and the memory is located inside or outside the processor.

[0180] The chip system may be composed of the chip, or may include the chip and other discrete devices.

[0181] The present application also provides a computer-readable storage medium, wherein a computer program (also referred to as code or instruction) is stored on the computer storage medium. When the computer program is executed by a processor, the above Figure 6 or Figure 8 The method described in the illustrated embodiment is carried out.

[0182] The present application also provides a computer program product, the computer program product comprising: a computer program (also referred to as code, or instruction), when the computer program is executed, causes the computer to execute Figure 6 or Figure 8 The method described in the illustrated embodiment.

[0183] It should be understood that the processor in the embodiment of the present application can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method embodiment can be completed by the hardware integrated logic circuit or software instructions in the processor. The above processor can be a general processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or the hardware and software modules in the decoding processor can be combined to perform. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.

[0184] It should also be understood that the memory in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM (DR RAM). It should be noted that the memory of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0185] The terms "unit", "module", etc. used in this specification may be used to represent computer-related entities, hardware, firmware, a combination of hardware and software, software, or software in execution. The units and modules in the embodiments of the present application have the same meaning and can be used interchangeably.

[0186] It will be appreciated by those skilled in the art that the various illustrative logical blocks and steps described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or in combination with computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application. In the several embodiments provided in this application, it should be understood that the disclosed devices, equipment and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0187] In the above embodiments, the functions of each functional unit can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions (programs). When loading and executing computer program instructions (programs) on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. Computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media integrated. Available media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes), optical media (eg, digital video discs (DVD)), or semiconductor media (eg, solid state drives (SSD)).

[0188] If the functions provided by the embodiments of the present application are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.

[0189] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A thread scheduling method, characterized in that: Applied to a terminal device, the method comprises: When a power-on event is detected, an associated thread group RTG is created, wherein the RTG includes a plurality of threads, and the plurality of threads are used to execute a display task; Scheduling the multiple threads to a target central processing unit (CPU); According to the load condition of the target CPU, the operating frequency of the target CPU is adjusted.

2. The method according to claim 1, characterized in that The target CPU corresponds to the scheduling parameter.

3. The method according to claim 2, characterized in that The scheduling parameters include one or more of the following: sampling duration, load clamping, minimum value of thread priority, or maximum running time.

4. The method according to claim 3, characterized in that The sampling duration decreases as the refresh rate of the terminal device increases; the load clamping and the minimum value of the thread priority increase as the refresh rate of the terminal device increases.

5. The method according to claim 3 or 4, characterized in that The maximum running time is determined according to the number of caches; and the maximum running time increases as the number of caches increases.

6. The method according to any one of claims 1 to 5, characterized in that The plurality of threads are predefined core threads for executing display tasks.

7. The method according to any one of claims 1 to 6, characterized in that The operating frequency of the target CPU increases as the load of the target CPU increases.

8. A terminal device, characterized in that: The method comprises modules for implementing the method as claimed in any one of claims 1 to 7.

9. A terminal device, characterized in that: comprising a processor and a memory, wherein: The memory is used to store computer programs; The processor is used to call the computer program so that the terminal device implements the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program or instruction. When the computer program or instruction is executed by a computer, the method according to any one of claims 1 to 7 is implemented.

11. A computer program product, characterized in that The computer program product comprises instructions, and when the instructions are executed by a computer, the method according to any one of claims 1 to 7 is implemented.