Task management method and related equipment
By recording the task execution time and processor frequency, calculating the normalized execution time, identifying and managing high-load tasks, the system resource occupation caused by high-load tasks in smart electronic devices is solved, reducing system power consumption and improving user experience.
Patent Information
- Application Number
- CN202410041940.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-10
- Publication Date
- 2025-07-18
AI Technical Summary
In smart electronic devices, high-load tasks lead to increased system resource occupancy, causing system lag, affecting user experience, and it is difficult for the existing technology to accurately identify and manage high-load tasks.
By recording the execution time and processor frequency of the task, calculating the normalized execution time, determining the load ratio of the task, and using the small-core processor binding or usage clamping mechanism to manage high-load tasks, avoiding high-load tasks from occupying critical task resources.
Accurately identify high-load tasks, reduce processor load and system power consumption, improve the execution efficiency of critical tasks, and improve user experience.
Smart Images

Figure CN120335939A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of intelligent terminals, and particularly to a task management method and related devices. Background Art
[0002] During the operation of applications in intelligent electronic devices such as smartphones and personal computers, a large number of tasks are generated. Among them, the execution time of some high-load tasks is long, which will cause the system load of the intelligent electronic device to increase. For example, the occupancy rates of resources such as the processor and memory increase, resulting in insufficient system resources for processing some key scenarios or tasks, and then causing the system to freeze, thus affecting the user experience. Summary of the Invention
[0003] In view of the above, it is necessary to provide a task management method to solve the problem that the occupancy rate of system resources by high-load tasks is too high, resulting in insufficient system resources for processing key tasks.
[0004] In a first aspect, this application provides a task management method applied to an electronic device. The method includes: recording the start execution time and end execution time of each execution of a task within a statistical window; collecting the frequency points of the processor of the electronic device when executing the task; calculating the normalized execution duration of the task according to the start execution time, end execution time, and the frequency points; determining the load of the task within the window according to the normalized execution duration of the task; determining the load ratio of the task within the window according to the load of the task within the window and the statistical window; if the load ratio of the task within the window is greater than or equal to a preset threshold, determining that the task is a high-load task, and controlling the task according to a preset policy.
[0005] Through the above technical solution, the normalized execution duration of a task can be accurately calculated according to the execution duration and processor frequency points of each execution of the task within a statistical window, and then the load of the task within the statistical window can be accurately determined. According to the load of the task within the statistical window, the load ratio of the task within the statistical window is determined. Whether the task is a high-load task is accurately identified according to the load ratio of the task within the statistical window, and the high-load task is controlled, effectively reducing the processor load and system power consumption.
[0006] In a possible implementation, the recording of the start execution time and end execution time of each execution of the task within the statistical window includes: creating a task listener, listening to the thread that executes the task within the statistical window through the task listener, recording the creation time of the thread as the start execution time, and recording the destruction time of the thread as the end execution time.
[0007] Through the above technical solution, the start execution time and end execution time of the task in each execution process can be accurately determined.
[0008] In a possible implementation manner, collecting the frequency points of the processor of the electronic device when executing the task includes: during the execution process of the task, collecting real-time processor frequency points at preset time intervals; determining the maximum frequency point or average frequency point of the collected multiple processor frequency points as the frequency point of the processor when executing the task.
[0009] Through the above technical solution, the frequency point of the processor when executing the task can be accurately determined.
[0010] In a possible implementation manner, calculating the normalized execution duration of the task according to the start execution time, end execution time, and the frequency point includes: calculating the difference between the end execution time and the start execution time to obtain the execution duration of the task; calculating the product of the ratio of the execution duration of the task, the frequency point, and the maximum frequency point of the processor and the computing power of the processor to obtain the normalized execution duration.
[0011] Through the above technical solution, the normalized execution duration of the task can be accurately calculated, unifying the calculation standards of the task execution durations corresponding to different types of processors and different processor frequency points, and avoiding the differences in the task execution durations when the task runs on different types of processors and different processor frequency points.
[0012] In a possible implementation manner, determining the load within the window of the task according to the normalized execution duration of the task includes: if the number of executions of the task within the statistical window is multiple times, calculating the sum value of all the normalized execution durations when the task is executed multiple times within the statistical window to obtain the load within the window of the task; if the number of executions of the task within the statistical window is one time, determining the normalized execution duration when the task is executed within the statistical window as the load within the window of the task.
[0013] Through the above technical solution, the load of the task within the statistical window can be accurately calculated according to the number of executions of the task within the statistical window and the execution duration each time.
[0014] In a possible implementation manner, determining the load ratio within the window of the task according to the load within the window of the task and the statistical window includes: calculating the ratio between the load within the window of the task and the statistical window to obtain the load ratio within the window of the task.
[0015] Through the above technical solution, the load ratio of the task within the statistical window can be accurately determined, and the load ratio of the task within the statistical window is used as the judgment criterion for high-load tasks, so as to accurately determine whether the task is a high-load task.
[0016] In a possible implementation manner, the controlling the task according to a preset policy includes: binding the task to the small core processor of the electronic device, and executing the task by the small core processor.
[0017] Through the above technical solution, by binding the core, the high-load task is executed by the small core processor, it is possible to prevent the high-load task from preempting the processing resources of the critical task, reduce the processor load, and reduce the system power consumption.
[0018] In a possible implementation manner, the controlling the task according to a preset policy includes: setting the usage rate clamping parameter of the task according to the usage rate clamping mechanism, so that the task is executed by the small core processor of the electronic device.
[0019] Through the above technical solution, by setting the usage rate clamping parameter of the task, the high-load task is executed by the small core processor, it is possible to prevent the high-load task from preempting the processing resources of the critical task, reduce the processor load, and reduce the system power consumption.
[0020] In a second aspect, an embodiment of the present application provides a task management method, which is applied to an electronic device. The method includes: recording the start execution time and the end execution time of each execution of the task per second within a preset time period; collecting the frequency point when the processor of the electronic device executes the task; calculating the normalized execution duration of the task according to the start execution time, the end execution time and the frequency point; determining the normalized load of the task per second within the preset time period according to the normalized execution duration of the task; obtaining the normalized load per second within a specified statistical window from the normalized load per second of the task within the preset time period, where the specified statistical window is less than or equal to the preset time period; determining the actual normalized load of the task within the specified statistical window according to the normalized load per second of the task within the specified statistical window, the window load classification level, and the correspondence between the statistical window and the actual normalized load; determining the load level of the task within the specified statistical window according to the actual normalized load of the task within the specified statistical window, the window load classification level, and the correspondence between the statistical window and the actual normalized load; if the load level of the task within the specified statistical window is greater than or equal to the preset threshold level corresponding to the specified statistical window, determining that the task is a high-load task, and controlling the task according to a preset policy.
[0021] Through the above technical solution, it is only necessary to determine the normalized load of the task per second within a preset time period, and then the load classification level corresponding to different statistical windows can be determined according to the corresponding relationship between the window load classification level, the statistical window, and the actual normalized load, without calculating the load data of different statistical windows simultaneously, reducing the data storage overhead and the memory occupancy of the task management data.
[0022] In a possible implementation manner, the recording of the start execution time and the end execution time of each execution of the task per second within a preset time period includes: creating a task listener, listening to the thread that executes the task per second through the task listener, recording the creation time of the thread as the start execution time of the task, and recording the destruction time of the thread as the end execution time of the task.
[0023] Through the above technical solution, the start execution time and the end execution time of the task during each execution can be accurately determined.
[0024] In a possible implementation manner, the calculating of the normalized execution duration of the task according to the start execution time, the end execution time, and the frequency point includes: calculating the difference between the end execution time and the start execution time to obtain the execution duration of the task; calculating the product of the ratio of the execution duration of the task, the frequency point, and the theoretical maximum frequency of the processor and the computing power of the processor to obtain the normalized execution duration.
[0025] Through the above technical solution, the normalized execution duration of the task can be accurately calculated, unifying the calculation criteria for the task execution durations corresponding to different types of processors and different processor frequency points, and avoiding the differences in the task execution durations when the task runs on different types of processors and different processor frequency points.
[0026] In a possible implementation manner, the determining of the actual normalized load of the task within the specified statistical window according to the normalized load of the task per second within the specified statistical window, the window load classification level, and the corresponding relationship between the statistical window and the actual normalized load includes: comparing the normalized load of the task per second within the specified statistical window with the corresponding relationship table between the window load classification level, the statistical window, and the actual normalized load to determine the load level of the task per second; determining the actual normalized load corresponding to the load level of the task per second in the corresponding relationship table, and determining the sum value of multiple actual normalized loads as the actual normalized load of the task within the specified statistical window.
[0027] Through the above technical solution, the actual normalized load of a task within a specified statistical window can be quickly determined by looking up a table, effectively improving the efficiency of obtaining the actual normalized load of the task.
[0028] In a possible implementation manner, the determining the load level of the task within the specified statistical window according to the actual normalized load of the task within the specified statistical window, the window load classification levels, and the correspondence between the statistical window and the actual normalized load includes: comparing the actual normalized load of the task within the specified statistical window with the correspondence table of the window load classification levels and the statistical window and the actual normalized load to determine the load level of the task within the specified statistical window.
[0029] Through the above technical solution, the load level of a task within a specified statistical window can be quickly determined by looking up a table, effectively improving the efficiency of determining the load level of the task.
[0030] In a possible implementation manner, the controlling the task according to a preset policy includes: binding the task to the small-core processor of the electronic device, and the small-core processor executes the task.
[0031] Through the above technical solution, by binding the core, the high-load task is executed by the small-core processor, which can prevent the high-load task from preempting the processing resources of the critical task, reduce the processor load, and reduce the system power consumption.
[0032] In a possible implementation manner, the controlling the task according to a preset policy includes: setting the usage clamping parameter of the task according to the usage clamping mechanism, so that the task is executed by the small-core processor of the electronic device.
[0033] Through the above technical solution, by setting the usage clamping parameter of the task, the high-load task is executed by the small-core processor, which can prevent the high-load task from preempting the processing resources of the critical task, reduce the processor load, and reduce the system power consumption.
[0034] In a third aspect, the present application provides an electronic device, and the electronic device includes a memory and a processor: wherein, the memory is used for storing program instructions; the processor is used for reading and executing the program instructions stored in the memory, and when the program instructions are executed by the processor, the electronic device executes the above-mentioned task management method.
[0035] In a fourth aspect, the present application provides a chip, which is coupled to the memory in the electronic device, and the chip is used for controlling the processor of the electronic device to execute the above-mentioned task management method.
[0036] In a fifth aspect, the present application provides a computer storage medium storing program instructions, which, when running on an electronic device, cause the processor of the electronic device to execute the above-mentioned task management method.
[0037] In addition, for the technical effects brought by the third to fifth aspects, reference may be made to the descriptions related to the methods of each design in the above method section, which will not be elaborated here. Description of the Drawings
[0038] Figure 1 It is a schematic diagram of the load types of an electronic device provided by an embodiment of the present application in a critical scenario.
[0039] Figure 2 It is a schematic diagram of the task types of an electronic device provided by an embodiment of the present application in a critical scenario.
[0040] Figure 3 It is a schematic diagram of the load change of an electronic device provided by an embodiment of the present application.
[0041] Figure 4 It is a software architecture diagram of an electronic device provided by an embodiment of the present application.
[0042] Figure 5 It is a flowchart of the task management method provided by an embodiment of the present application.
[0043] Figure 6 It is a schematic diagram of the time nodes in the task execution process provided by an embodiment of the present application.
[0044] Figure 7 It is a flowchart of the task management method provided by another embodiment of the present application.
[0045] Figure 8 It is a schematic diagram of the execution duration per second of a task within 10 seconds provided by an embodiment of the present application.
[0046] Figure 9 It is a schematic diagram of the correspondence table between the window load grading levels, statistical windows, and actual execution durations provided by an embodiment of the present application.
[0047] Figure 10 It is a schematic diagram of the window load grading levels of a task within different specified statistical windows provided by an embodiment of the present application.
[0048] Figure 11 It is a hardware architecture diagram of an electronic device provided by an embodiment of the present application. Detailed Embodiments
[0049] In the embodiments of the present application, the terms "first" and "second" are only used for descriptive purposes and should not be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, words such as "exemplary" or "for example" are used to represent examples, illustrations or explanations. Any embodiment or design solution described as "exemplary" or "for example" in the embodiments of the present application should not be construed as being more preferred or more advantageous than other embodiments or design solutions. Rather, the use of words such as "exemplary" or "for example" is intended to present relevant concepts in a specific manner.
[0050] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which this application belongs. The terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. It should be understood that unless otherwise specified in this application, " / " means "or". For example, A / B may mean A or B. The "and / or" in this application is only a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may mean: A exists alone, A and B exist simultaneously, and B exists alone, these three situations. "At least one" means one or more. "Multiple" means two or more than two. For example, at least one of a, b or c may mean: a, b, c, a and b, a and c, b and c, a, b and c, these seven situations. Without conflict, the following embodiments and the features in the embodiments may be combined with each other.
[0051] For ease of understanding, some descriptions of concepts related to the embodiments of the present application are given by way of example for reference.
[0052] Process: It is an execution activity of a program in a computer with respect to a certain data set. It is the basic unit for the system to allocate and schedule resources and is the basis of the operating system structure. A process is the basic execution entity of a program; in a contemporary computer structure designed for threads, a process is a container for threads. A program is a description of instructions, data and their organizational forms, and a process is the entity of a program. A process can be regarded as an independent program with its complete data space and code space in memory. The data and variables owned by a process only belong to itself.
[0053] Thread: The smallest unit that performs operations in a process, i.e., the basic unit for the execution of processor scheduling. If a process is understood as the task completed by the operating system logically, then a thread represents one of the many possible subtasks to complete this task. That is to say, a thread exists within a process. A process consists of one or more threads, and each thread shares the same code and global data.
[0054] Task: Includes each action of the user when operating the computer and the corresponding response events (such as single-clicking the mouse, right-clicking the mouse, opening a dialog box, closing a file, starting a program, etc.). A task can be represented as an activity completed by software. In the embodiments of the present application, a task can be either a process or a thread. A task can be a series of multiple operations that jointly achieve a certain purpose. For example, reading data and putting the data into memory. This task can be implemented as a process or as a thread (or as an interrupt task).
[0055] As the configurations of intelligent electronic devices such as smart phones and personal computers are getting higher and higher, users' requirements for the performance of intelligent electronic devices are also getting higher and higher. Especially in key scenarios where human-computer interaction is relatively frequent and visual perception is relatively obvious, such as starting an application, fingerprint recognition, lighting up the display screen, etc., a fast start of the application, a fast fingerprint recognition speed, and a fast display screen lighting up can bring a better performance experience to users. However, during the operation of an application in an intelligent electronic device, a large number of tasks will be generated. During the process of human-computer interaction, in addition to executing tasks in key scenarios, the system also needs to execute tasks generated by other applications or services, such as system tasks, tasks generated by background applications, etc. Among them, the execution time of some high-load tasks is long, which will cause the system load to increase. For example, the occupancy rates of resources such as the processor and memory increase, resulting in insufficient system resources for processing some key scenarios or tasks, and then causing the system to freeze, thus affecting the user experience.
[0056] Refer to Figure 1 As shown, in key scenarios such as video playback or responding to the user's sliding operation, an electronic device usually includes the main thread / rendering thread load, key task load, other loads, and also includes background load and system load. Refer to Figure 2As shown, the main thread / rendering thread load may include UI (interface refresh) tasks and Render (rendering) tasks. The critical task load may include Poll (polling) tasks, Binder (inter-process communication) tasks, Worker (worker) tasks, etc. Other loads include Log (logging) tasks, network access tasks, download tasks, etc. The background load includes background application load and background service load. The background application load is the load caused by applications running in the background, and the background service load is the load caused by system services running in the background. The background service load includes Log (logging) tasks, hiview (monitoring) tasks, etc. The system load includes kernel load and Android operating system load. The kernel load includes Kworker (kernel worker) tasks, Kthread (kernel thread) tasks, Kswapd (kernel memory reclaim) tasks, etc. The Android operating system load includes systemserver (system service) tasks, systemui (system interface) tasks, launcher (launch) tasks, etc. It can be seen that even in critical scenarios, the system of the electronic device needs to execute a large number of tasks. If high-load tasks are generated by the system or in the background, it may preempt the processing resources of the big-core processor, resulting in the inability to process critical tasks in critical scenarios in a timely manner, and it is also easy to cause the processor to run at a high frequency point for a long time, greatly increasing the system power consumption.
[0057] Refer to Figure 3 As shown, it is a schematic diagram of the load change of an electronic device provided by an embodiment of the present application. In one embodiment, it is assumed that the electronic device includes three processors, namely CPU0, CPU1, and CPU3. Among them, CPU1 executed task A in the first and fifth statistical windows. The operating frequency points of all CPUs were 600 MHz in the first statistical window, and the highest reached 2.3 GHz in the fifth statistical window. CPU0 executed task A in the third statistical window, and the highest operating frequency point of all CPUs reached 2.3 GHz in the third statistical window. CPU3 executed task B in the first to fifth statistical windows. It can be seen that the load is relatively high when the processor executes task A, but it may be misjudged as a low-load task by the system due to the short execution time of task A, so no control is performed on task A, resulting in a relatively high system power consumption. The load is relatively low when the processor executes task B, but it may be misjudged as a high-load task by the system due to the long execution time of task B, so task B is controlled, resulting in task B not being processed in a timely manner.
[0058] In order to avoid the inability to accurately identify high-load tasks, an embodiment of the present application provides a task management method, which provides a normalized high-load task quantization method, which can accurately identify high-load tasks and control high-load tasks.
[0059] Refer to Figure 4 As shown, it is the software architecture diagram of the electronic device provided by the embodiment of the present application. The layered architecture divides the software into several layers, and each layer has clear roles and divisions of labor. The layers communicate with each other through software interfaces. For example, the Android system is divided into four layers, from top to bottom, namely the application layer 101, the framework layer 102, the Android runtime and system libraries 103, the hardware abstraction layer 104, the kernel layer 105, and the hardware layer 106.
[0060] The application layer 101 may include a series of application packages. For example, the application packages may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, device control service, etc.
[0061] The framework layer 102 provides application programming interfaces (APIs) and programming frameworks for the applications in the application layer. The application framework layer includes some predefined functions. For example, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, etc.
[0062] Among them, the window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc. The content provider is used to store and obtain data, and make this data accessible to applications. The data may include videos, images, audio, dialed and received calls, browsing history and bookmarks, phone book, etc. The view system includes visible controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a short message notification icon may include a view for displaying text and a view for displaying pictures. The phone manager is used to provide the communication function of the electronic device. For example, the management of call status (including connection, disconnection, etc.). The resource manager provides various resources for applications, such as localized strings, icons, pictures, layout files, video files, etc. The notification manager enables applications to display notification information in the status bar, can be used to convey notification-type messages, can automatically disappear after a short stay without user interaction. For example, the notification manager is used to notify the completion of a download, message reminder, 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 the notification of a background-running application, and can also be a notification that appears on the screen in the form of a dialogue window. For example, prompt text information in the status bar, emit a prompt tone, the electronic device vibrates, the indicator light flashes, etc.
[0063] The Android Runtime includes core libraries and a virtual machine. The Android runtime is responsible for the scheduling and management of the Android system. The core libraries consist of two parts: one part is the functional functions that need to be called by the Java language, and the other part is the core libraries of Android.
[0064] The application layer 101 and the framework layer 102 run in the virtual machine. The virtual machine executes the Java files of the application layer and the framework layer as binary files. The virtual machine is used to perform functions such as the management of object life cycles, stack management, thread management, security and exception management, and garbage collection.
[0065] The system libraries 103 can include multiple functional modules. For example, the surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.
[0066] Among them, the surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications. The media libraries support the playback and recording of multiple common audio and video formats, as well as static image files, etc. The media libraries can support multiple audio and video coding 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, etc. The 2D graphics engine is the drawing engine for 2D drawing.
[0067] The hardware abstraction layer 104 runs in the user space, encapsulates the kernel layer drivers, and provides call interfaces to the upper layer.
[0068] The kernel layer 105 is the layer between the hardware and the software. The kernel layer 105 at least includes display drivers, camera drivers, audio drivers, and sensor drivers.
[0069] The kernel layer 105 is the core of the operating system of the electronic device, the first layer of software expansion based on the hardware, provides the most basic functions of the operating system, is the basis for the operation of the operating system, and is responsible for managing the system's processes, memory, device drivers, files, and network systems, and determines the performance and stability of the system. For example, the kernel can determine the operation time of an application program for a certain part of the hardware.
[0070] The kernel layer 105 includes programs closely related to the hardware, such as interrupt handlers, device drivers, etc., and also includes basic, common, and frequently running modules, such as the clock management module, process scheduling module, etc., and also includes key data structures. The kernel layer can be set in the processor or solidified in the internal memory.
[0071] The hardware layer 106 includes the hardware of the electronic device, such as a display screen, buttons, a camera, etc.
[0072] Refer to Figure 5 As shown, it is a flowchart of a task management method provided by an embodiment of the present application. The method is applied to an electronic device, and the task management method includes:
[0073] S101, record the start execution time and end execution time of each execution of the task within the statistical window.
[0074] In an embodiment of the present application, the statistical window refers to a time window for statistical analysis of task load. After the electronic device is powered on and running, a task management process is created, and the timer starts timing for the statistical window. When the task management process detects that the processor starts to process a task, it marks the timing time of the timer. Taking task C as an example, the timer is used to record the start execution time of task C. When it detects that the processor finishes processing task C, it marks the timing time of the timer again to record the end execution time of task C. The statistical window can be set in advance according to requirements. For example, it can be 1 second, 3 seconds, 5 seconds, or other times.
[0075] In an embodiment of the present application, the task management process can create a task listener to monitor the thread that executes task C within the statistical window. When it monitors that the thread that executes task C is created, it uses the timer to record the creation time of the thread and takes the creation time of the thread as the start execution time of task C. When it monitors that the thread that executes task C is destroyed, it uses the timer to record the destruction time of the thread and records the destruction time of the thread as the end execution time of task C.
[0076] Refer to Figure 6 As shown, it is a schematic diagram of time nodes in the task execution process provided by an embodiment of the present application. For example, the statistical window is 5 seconds. The timer is used to time the statistical window. When the task listener monitors that the thread that executes task C is created, the timer is used to record the creation time of the thread as the start execution time of task C. When the task listener monitors that the thread that executes task C is destroyed, the timer is used to record the destruction time of the thread as the end execution time of task C. In an embodiment of the present application, the timing time of the timer can be the cumulative time starting from the start of the statistical window for timing, or it can be the system time, such as Beijing time.
[0077] S102, collect the frequency points when the processor executes the task.
[0078] In an embodiment of the present application, when the task management process detects that the processor starts to execute a task, it periodically collects the real-time processor frequency points according to a preset time period, thereby collecting multiple processor frequency points, and determines the maximum frequency point or the average frequency point of the multiple processor frequency points as the frequency point when the processor executes the task. For example, the preset time period can be 5 ms, 10 ms or other times.
[0079] In an embodiment of the present application, the real-time frequency point of the processor is automatically stored in the file / sys / devices / system / cpu / cpuX / cpufreq / scaling_cur_freq, where cpuX represents the processor core, and the task management process collects the real-time frequency point during the process of the processor executing the task by reading this file.
[0080] S103. Calculate the normalized execution duration of the task according to the start execution time, the end execution time, and the frequency point when the processor executes the task.
[0081] In an embodiment of the present application, the calculation formula for the normalized execution duration Taskrunningtime of the task according to the start execution time, the end execution time, and the frequency point when the processor executes the task is:
[0082]
[0083] In the calculation formula (1), delta (such as Figure 6 the delta shown in) is the difference between the end execution time and the start execution time of the task, which can represent the execution duration of the task, curfreq is the frequency point when the processor executes the task. For example, curfreq can be the maximum frequency point or the average frequency point of the multiple frequency points during the process of the processor executing the task collected, maxfreq is the theoretical maximum frequency point of the processor, such as 2.3 GHz, 2.8 GHz, 3.5 GHz or other frequency points, and capacity is the computing power value of the processor, such as 512, 1024, 2048 or other values.
[0084] S104. Determine the load within the window of the task according to the normalized execution duration of the task.
[0085] In an embodiment of the present application, the load within the window of the task is the load of the task within the statistical window. If the number of times the task is executed within the statistical window is multiple times, calculate the sum value of all the normalized execution durations when the task is executed multiple times within the statistical window to obtain the load within the window of the task. If the number of times the task is executed within the statistical window is once, determine the normalized execution duration when the task is executed within the statistical window as the load within the window of the task.
[0086] In an embodiment of the present application, when a computing task is executed multiple times within a statistical window, the sum of all normalized execution durations is calculated, and the formula for calculating the task's load within the window Taskloadwindow is:
[0087]
[0088] In the calculation formula (2), n is the total number of times the task is executed within a statistical window.
[0089] S105. Determine the load ratio of the task within the window according to the task's load within the window and the statistical window.
[0090] In an embodiment of the present application, the ratio between the load of the computing task within the window and the statistical window is calculated to obtain the load ratio of the task within the window Highloadratewindow, where the calculation formula is:
[0091]
[0092] In the calculation formula (3), Taskloadwindow is the load of the task within the window, and window is the duration of the statistical window.
[0093] S106. Determine whether the load ratio of the task within the window is greater than or equal to a preset threshold. If the load ratio of the task within the window is greater than or equal to the preset threshold, execute S107; if the load ratio of the task within the window is less than the preset threshold, it indicates that the task is a low-load task, and the process returns to execute S101.
[0094] In an embodiment of the present application, the preset threshold can be 80%, 90%, or other values.
[0095] S107. Determine that the task is a high-load task, and control the task according to a preset policy.
[0096] In an embodiment of the present application, if it is determined that the task is a high-load task, the task is controlled by means of core binding operation or setting uclamp (utilization clamping). Among them, the core binding operation is to bind the high-load task to the small-core processor, and the high-load task is processed by the small-core processor to avoid the large-core processor from processing too many high-load tasks. The method of setting uclamp is to set the utilization clamping parameter of the task according to the utilization clamping mechanism, so that the task is automatically executed by the small-core processor of the electronic device.
[0097] The usage rate clamping parameter includes tracking signals in two dimensions: CPU Utilization (CPU usage rate) and Task Utilization (task's usage rate of CPU). CPU Utilization is used to indicate the busyness of the CPU, and the kernel scheduler drives the CPU to adjust its frequency based on CPU Utilization. Task Utilization is used to indicate the usage rate of the task set by the user space for the CPU, indicating the execution priority of the task. Task Utilization can assist the kernel scheduler in performing CPU core selection operations. For example, task D is not a task in a critical scenario but is identified as a high-load task. The user space can lower the execution priority of task D by setting the Task Utilization of task D, so that the kernel scheduler schedules task D to a small-core processor for execution. Another example is that task E is identified as a low-load task but is a task in a critical scenario. The user space can increase the execution priority of task E by setting the Task Utilization of task E, so that the kernel scheduler schedules task E to a large-core processor for execution.
[0098] In an embodiment of the present application, the Task Utilization parameter is the range [util_min, util_max] of the CPU usage rate. By setting the util_max in the Task Utilization parameter of the high-load task to a smaller value, the execution priority of the high-load task is reduced, so that the kernel scheduler schedules the high-load task to a small-core processor for execution.
[0099] As an open ecosystem, the system of a smart phone allows users to download third-party applications from various channels. If the application version is abnormal or there are system bugs, etc., some abnormally high-load tasks will be generated. And a smart phone is a device sensitive to performance and power consumption. The generation of these abnormally high loads will introduce performance and power consumption problems such as competing with critical tasks for the large-core CPU and keeping the CPU running at a high frequency for a long time. Through the above embodiments of the present application, the normalized load of tasks within the statistical window can be determined, and whether a task is a high-load task can be identified based on the normalized load, thereby improving the accuracy of identifying high-load tasks. And when a task is identified as a high-load task, the high-load task can be controlled in time to avoid the high-load task affecting the execution of critical tasks.
[0100] In another embodiment of the present application, after determining that a task is a high-load task, it is also determined whether the high-load task is a critical task. If the high-load task is a critical task, there is no need to control the high-load task. If the high-load task is not a critical task, the high-load task is controlled.
[0101] In another embodiment of the present application, it is determined whether the high-load task is a task of a foreground application. If the high-load task is a task of a foreground application, the high-load task is determined to be a critical task; if the high-load task is not a task of a foreground application, the high-load task is determined not to be a critical task.
[0102] In another embodiment of the present application, it is determined whether the high-load task is a task of a perceivable scenario. If the high-load task is a task of a perceivable scenario, the high-load task is determined to be a critical task; if the high-load task is not a task of a perceivable scenario, the high-load task is determined not to be a critical task. A perceivable scenario refers to a scenario where the user interface of the electronic device changes.
[0103] In one embodiment, if a large number of tasks are running simultaneously in the electronic device system, counting the normalized loads of the large number of tasks within different statistical windows will generate a large amount of data, which may occupy more memory.
[0104] Refer to Figure 7 As shown, it is a flowchart of a task management method provided by another embodiment of the present application. The method is applied to an electronic device, and the task management method includes:
[0105] S201, record the start execution time and end execution time of each execution of the task per second within a preset time period.
[0106] In one embodiment of the present application, a task management process is created. The statistical window is set to 1 second through the task management process. Within the preset time period, the timer starts timing for the statistical window. When the task management process detects that the processor starts to execute a task, it marks the timing time of the timer and records the start execution time of the task. When it detects that the processor ends processing the task, it marks the timing time of the timer again and records the end execution time of the task, so as to record the start execution time and end execution time of each execution process of the task within 1 second. For example, the preset time period can be 10 seconds, 20 seconds, or other times.
[0107] S202, collect the frequency points when the processor of the electronic device executes a task.
[0108] S203, calculate the normalized execution duration of the task according to the start execution time, end execution time, and frequency points.
[0109] The specific implementation manners of S202 to S203 are the same as those of S102 to S103, and will not be elaborated here.
[0110] S204, determine the normalized load of the task per second within the preset time period according to the normalized execution duration of the task.
[0111] In an embodiment of the present application, if the number of times a task is executed per second is multiple, calculate the sum of all normalized execution durations when the task is executed multiple times per second to obtain the normalized load of the task per second. If the number of times a task is executed per second is one, determine the normalized execution duration when the task is executed per second as the normalized load of the task per second. Based on the normalized load of the task per second, obtain the normalized load of the task per second within a preset time period. For example, as Figure 8 shown, it is the normalized load of the task per second within 10 seconds.
[0112] S205, obtain the normalized load per second within a specified statistical window from the normalized load per second of the task within the preset time period.
[0113] For example, the specified statistical window is 3 seconds, 5 seconds, 10 seconds or other time. If the specified statistical window is 3 seconds and the preset time period is 10 seconds, obtain the normalized load per second in the first 3 seconds from the normalized load per second of the task within 10 seconds. Specifically, the normalized load in the first second is 0.22 seconds, the normalized load in the second second is 0 seconds, and the normalized load in the third second is 0.35 seconds.
[0114] S206, determine the actual normalized load of the task within the specified statistical window according to the corresponding relationship between the normalized load per second within the specified statistical window, the window load grading levels, and the statistical window and the actual normalized load.
[0115] Refer to Figure 9 shown, it is a schematic diagram of the corresponding relationship table between the window load grading levels, the statistical window, and the actual normalized load provided by an embodiment of the present application. In an embodiment of the present application, compare the normalized load per second within the specified statistical window with the corresponding relationship table between the window load grading levels, the statistical window, and the actual normalized load to determine the load grading per second within the specified statistical window. According to the load grading per second within the specified statistical window and the corresponding relationship table between the window load grading levels, the statistical window, and the actual normalized load, determine the actual normalized load corresponding to the load grading per second within the specified statistical window, and calculate the sum of the multiple actual normalized loads corresponding to the load grading per second within the specified statistical window to obtain the actual normalized load of the task within the specified statistical window.
[0116] For example, when the specified statistical window is 3 seconds, combined with Figure 8 it can be known that the normalized loads per second of the task within 3 seconds are 0.22 seconds (indicating that the normalized load of the task in the first second is 0.22 seconds), 0 (indicating that the normalized load of the task in the second second is 0 seconds), and 0.35 seconds (indicating that the normalized load of the task in the third second is 0.35 seconds). Combined with Figure 9It can be known that the load grading corresponding to 0.22 seconds in 1 second is 2, and the load grading corresponding to 0.35 seconds in 1 second is 3; the actual normalized load corresponding to 2 is 0.25 seconds, and the actual normalized load corresponding to 3 is 0.38 seconds. Then the actual normalized load of the task within 3 seconds is 0.25 seconds + 0.38 seconds = 0.63 seconds.
[0117] For another example, when the specified statistical window is 5 seconds, combined with Figure 8 It can be known that the normalized loads per second of the task within 5 seconds are 0.22 seconds, 0, 0.35 seconds, 0 (indicating that the normalized load of the task within the 4th second is 0 seconds), 0.6 seconds (indicating that the normalized load of the task within the 5th second is 0.6 seconds). Combined with Figure 9 It can be known that the load grading corresponding to 0.22 seconds in 1 second is 2, the load grading corresponding to 0.35 seconds in 1 second is 3, the load grading corresponding to 0.6 seconds in 1 second is 5, the actual normalized load corresponding to 2 is 0.25 seconds, the actual normalized load corresponding to 3 is 0.38 seconds, and the actual normalized load corresponding to 5 is 0.63 seconds. Then the actual normalized load of the task within 5 seconds is 0.25 seconds + 0.38 + 0.63 seconds = 1.26 seconds.
[0118] For yet another example, when the specified statistical window is 10 seconds, combined with Figure 8 It can be known that the normalized loads per second of the task within 10 seconds are 0.22 seconds, 0, 0.35 seconds, 0, 0.6 seconds, 0 (indicating that the normalized load of the task within the 7th second is 0 seconds), 0 (indicating that the normalized load of the task within the 8th second is 0 seconds), 0.2 seconds (indicating that the normalized load of the task within the 9th second is 0.2 seconds), 0 (indicating that the normalized load of the task within the 9th second is 0 seconds), 0.1 seconds (indicating that the normalized load of the task within the 10th second is 0.1 seconds). Combined with Figure 9 It can be known that the load grading corresponding to 0.22 seconds in 1 second is 2, the load grading corresponding to 0.35 seconds in 1 second is 3, the load grading corresponding to 0.6 seconds in 1 second is 5, the load grading corresponding to 0.2 seconds in 1 second is 2, the load grading corresponding to 0.1 seconds in 1 second is 1, the actual normalized load corresponding to 2 is 0.25 seconds, the actual normalized load corresponding to 3 is 0.38 seconds, the actual normalized load corresponding to 5 is 0.63 seconds, and the actual normalized load corresponding to 1 is 0.13 seconds. Then the actual normalized load of the task within 10 seconds is 0.25 seconds + 0.38 seconds + 0.63 + 0.25 seconds + 0.13 seconds = 1.64 seconds.
[0119] S207. Determine the load grade of the task within the specified statistical window according to the actual normalized load of the task within the specified statistical window, the window load grading level, and the corresponding relationship between the statistical window and the actual normalized load.
[0120] In an embodiment of the present application, the actual normalized load of a task within a specified statistical window is compared with a corresponding relationship table between the window load grading levels and the statistical window and the actual normalized load to determine the load level of the task within the specified statistical window.
[0121] For example, the actual normalized load of a task within a 3-second statistical window is 0.63 seconds. By referring to Figure 9 the corresponding relationship table between the window load grading levels and the statistical window and the actual normalized load, it can be known that the actual normalized load of the 3-second statistical window at load level 1 is 0.38 seconds, and the actual normalized load at load level 2 is 0.75 seconds. Since the actual normalized load of the task within the 3-second statistical window, which is 0.63 seconds, is greater than 0.38 seconds and less than 0.75 seconds, the load level of the task within the 3-second statistical window is 2.
[0122] Another example, the actual normalized load of a task within a 5-second statistical window is 1.26 seconds. By referring to Figure 9 the corresponding relationship table between the window load grading levels and the actual normalized load, it can be known that the actual normalized load of the 5-second statistical window at load level 2 is 1.25 seconds, and the actual normalized load at load level 3 is 1.88 seconds. Since the actual normalized load of the task within the 5-second statistical window, which is 1.26 seconds, is greater than 1.25 seconds and less than 1.88 seconds, the load level of the task within the 5-second statistical window is 3.
[0123] Yet another example, the actual normalized load of a task within a 10-second statistical window is 1.64 seconds. By referring to Figure 9 the corresponding relationship table between the window load grading levels and the actual normalized load, it can be known that the actual normalized load of the 10-second statistical window at load level 1 is 1.25 seconds, and the actual normalized load at load level 2 is 2.5 seconds. Since the actual normalized load of the task within the 10-second statistical window, which is 1.64 seconds, is greater than 1.25 seconds and less than 2.5 seconds, the load level of the task within the 10-second statistical window is 2.
[0124] Refer to Figure 10As shown, based on the normalized load per second of the task within 10 seconds, it can be determined that within the specified statistical window of 1 second, the window load classification level of the task in the 1st second is level 2, the window load classification level of the task in the 3rd second is level 3, the window load classification level of the task in the 5th second is level 5, the window load classification level of the task in the 8th second is level 2, and the window load classification level of the task in the 10th second is level 1; within the specified statistical window of 3 seconds, the window load classification level of the first 3-second task is level 2, the window load classification level of the second 3-second task is level 2, and the window load classification level of the third 3-second task is level 1; within the specified statistical window of 5 seconds, the window load classification level of the first 5-second task is level 3, and the window load classification level of the second 5-second task is level 1; within the specified statistical window of 10 seconds, the window load classification level of the task is level 2.
[0125] S208, determine whether the load level of the task within the specified statistical window is greater than or equal to the preset threshold level corresponding to the specified statistical window. If the load level of the task within the specified statistical window is greater than or equal to the preset threshold level corresponding to the specified statistical window, the process proceeds to S206; if the load level of the task within the specified statistical window is less than the preset threshold level corresponding to the specified statistical window, it indicates that the task is a low-load task, and the process returns to execute S201.
[0126] S209, determine that the task is a high-load task, and control the task according to the preset policy.
[0127] The specific implementation manner of S209 is the same as that of S107, and will not be elaborated here.
[0128] In the above embodiments of the present application, only the normalized load per second of the task within the preset time period needs to be recorded, and the load classification levels corresponding to different statistical windows can be determined through the corresponding relationship between the window load classification level, the statistical window, and the actual normalized load, without the need to calculate the load data of different statistical windows simultaneously, reducing the data storage overhead and the memory occupancy of the task management data.
[0129] The embodiments of the present application also provide an electronic device 100, refer to Figure 11As shown, the electronic device 100 may be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an Ultra-mobile Personal Computer (UMPC), a netbook, a cellular phone, a Personal Digital Assistant (PDA), an Augmented Reality (AR) device, a Virtual Reality (VR) device, an Artificial Intelligence (AI) device, a wearable device, a vehicle-mounted device, a smart home device, and / or a smart city device. The embodiments of the present application do not impose special restrictions on the specific type of the electronic device 100.
[0130] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a Universal Serial Bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a Subscriber Identification Module (SIM) card interface 195, 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 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.
[0131] It can be understood that the structure schematically shown in the embodiments of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0132] The processor 110 may include one or more processing units. For example, the processor 110 may include an Application Processor (AP), a modem processor, a Graphics Processing Unit (GPU), an Image Signal Processor (ISP), a controller, a video codec, a Digital Signal Processor (DSP), a baseband processor, and / or a Neural-network Processing Unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.
[0133] The controller can generate operation control signals according to the instruction operation code and timing signals to complete the control of fetching and executing instructions.
[0134] A memory may also be provided in the processor 110 for storing instructions and data. In an embodiment of the present application, the memory in the processor 110 is a cache memory. The memory can save the instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instructions or data again, it can directly call them from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0135] In an embodiment of the present application, the processor 110 may include one or more interfaces. The 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.
[0136] The I2C interface is a two-way synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In an embodiment of the present application, the processor 110 may include multiple groups of I2C buses. The processor 110 may be respectively coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces. For example, the processor 110 may be coupled to the touch sensor 180K through the I2C interface, enabling the processor 110 and the touch sensor 180K to communicate through the I2C bus interface to implement the touch function of the electronic device 100.
[0137] The I2S interface can be used for audio communication. In an embodiment of the present application, the processor 110 may include multiple groups of I2S buses. The processor 110 may be coupled to the audio module 170 through the I2S bus to implement communication between the processor 110 and the audio module 170. In an embodiment of the present application, the audio module 170 may transmit an audio signal to the wireless communication module 160 through the I2S interface to implement the function of answering a call through a Bluetooth headset.
[0138] The PCM interface can also be used for audio communication to sample, quantize, and encode analog signals. In an embodiment of the present application, the audio module 170 and the wireless communication module 160 may be coupled through the PCM bus interface. In an embodiment of the present application, the audio module 170 may also transmit an audio signal to the wireless communication module 160 through the PCM interface to implement the function of answering a call through a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
[0139] The UART interface is a general-purpose serial data bus for asynchronous communication. The bus can be a two-way communication bus. It converts the data to be transmitted between serial communication and parallel communication. In an embodiment of the present application, the UART interface is usually used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In an embodiment of the present application, the audio module 170 may transmit an audio signal to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.
[0140] The MIPI interface can be used to connect the processor 110 to peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a Camera Serial Interface (CSI), a Display Serial Interface (DSI), etc. In an embodiment of the present application, the processor 110 and the camera 193 communicate through the CSI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate through the DSI interface to implement the display function of the electronic device 100.
[0141] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or a data signal. In an embodiment of the present application, the GPIO interface can be used to connect the processor 110 to the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0142] The USB interface 130 is an interface that complies with the USB standard specification, and can specifically 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 electronic device 100, and can also be used to transfer data between the electronic device 100 and peripheral devices. It can also be used to connect a headset to play audio through the headset. The interface can also be used to connect to other electronic devices 100, such as AR devices, etc.
[0143] It can be understood that the interface connection relationships between the modules illustrated in the embodiments of the present invention are only illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0144] The charging management module 140 is used to receive a charging input from a charger. Among them, the charger can be a wireless charger or a wired charger. In some embodiments of wired charging, the charging management module 140 can receive the charging input from a wired charger through the USB interface 130. In some embodiments of wireless charging, the charging management module 140 can receive the wireless charging input through 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 electronic device 100 through the power management module 141.
[0145] 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 the inputs from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, the wireless communication module 160, etc. The power management module 141 can also be used to monitor parameters such as the battery capacity, the number of battery cycles, and the battery health status (leakage, impedance). In some other embodiments, the power management module 141 can also be disposed in the processor 110. In some other embodiments, the power management module 141 and the charging management module 140 can also be disposed in the same device.
[0146] The wireless communication function of the electronic device 100 can be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modulation and demodulation processor, and the baseband processor, etc.
[0147] The antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization rate of the antennas. For example: the antenna 1 can be multiplexed as the diversity antenna of the wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0148] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc. applied to the electronic device 100. The mobile communication module 150 can include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves by the antenna 1, filter, amplify, etc. the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves through the antenna 1 and radiate it out. In an embodiment of the present application, at least some functional modules of the mobile communication module 150 can be disposed in the processor 110. In an embodiment of the present application, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 can be disposed in the same device.
[0149] The modulation and demodulation processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. Subsequently, the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.), or displays an image or video through the display screen 194. In an embodiment of the present application, the modulation and demodulation processor may be an independent device. In other embodiments, the modulation and demodulation processor may be independent of the processor 110 and be disposed in the same device as the mobile communication module 150 or other functional modules.
[0150] The wireless communication module 160 may provide solutions for wireless communications applied to the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite systems (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering processing on the electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 160 may also receive the signals to be transmitted from the processor 110, perform frequency modulation and amplification on them, and convert them into electromagnetic waves through the antenna 2 for radiation.
[0151] In an embodiment of the present application, antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and antenna 2 is coupled to the wireless communication module 160, enabling the electronic device 100 to communicate with a network and other devices through wireless communication technologies. The wireless communication technologies 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 Global Positioning System (GPS), Global Navigation Satellite System (GLONASS), Beidou Navigation Satellite System (BDS), Quasi-Zenith Satellite System (QZSS), and / or Satellite Based Augmentation Systems (SBAS).
[0152] The electronic device 100 implements a display function through the GPU, the display screen 194, and the application processor, etc. The GPU is a microprocessor for task management, connected to 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.
[0153] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Miniled, a Microled, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In an embodiment of the present application, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0154] The electronic device 100 can implement the shooting function through the ISP, the camera 193, the video codec, the GPU, the display screen 194, and the application processor, etc.
[0155] The ISP is used to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, and light is transmitted through the lens to the camera photosensitive element, where the optical signal is converted into an electrical signal. The camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. The ISP can also optimize parameters such as the exposure and color temperature of the shooting scene. In an embodiment of the present application, the ISP can be provided in the camera 193.
[0156] The camera 193 is used to capture static images or videos. An object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV, etc. format. In an embodiment of the present application, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0157] The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy, etc.
[0158] The video codec is used to compress or decompress digital videos. The electronic device 100 can support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple coding formats, such as: Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0159] The NPU is a Neural-Network (NN) computing processor. By drawing on the structure of the biological neural network, such as the transmission pattern between human brain neurons, it can quickly process the input information and can also continuously self-learn. Through the NPU, applications such as intelligent cognition of the electronic device 100 can be realized, such as: image recognition, face recognition, voice recognition, text understanding, etc.
[0160] The internal memory 121 may include one or more Random Access Memories (RAM) and one or more Non-Volatile Memories (NVM).
[0161] The random access memory may include Static Random-Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDR SDRAM, for example, the fifth generation of DDR SDRAM is generally called DDR5 SDRAM), etc.;
[0162] The non-volatile memory may include disk storage devices and flash memory.
[0163] Flash memory can be classified into NOR Flash, NAND Flash, 3D NAND Flash, etc. according to the operating principle, into Single-Level Cell (SLC), Multi-Level Cell (MLC), Triple-Level Cell (TLC), Quad-Level Cell (QLC), etc. according to the number of potential levels of storage cells, and into Universal Flash Storage (UFS), embedded Multi Media Card (eMMC), etc. according to the storage specification.
[0164] The random access memory can be directly read and written by the processor 110, and can be used to store the operating system or executable programs (such as machine instructions) of other running programs, and can also be used to store data of users and application programs, etc.
[0165] The non-volatile memory can also store executable programs and data of users and application programs, etc., and can be pre-loaded into the random access memory for the processor 110 to directly read and write.
[0166] The external memory interface 120 can be used to connect to an external non-volatile memory to expand the storage capacity of the electronic device 100. The external non-volatile memory communicates with the processor 110 through the external memory interface 120 to implement the data storage function. For example, files such as music and videos are saved in the external non-volatile memory.
[0167] The internal memory 121 or the external memory interface 120 is used to store one or more computer programs. One or more computer programs are configured to be executed by the processor 110. One or more computer programs include a plurality of instructions. When the plurality of instructions are executed by the processor 110, the screen display detection method executed on the electronic device 100 in the above embodiments can be implemented to realize the screen display detection function of the electronic device 100.
[0168] The electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone interface 170D, and the application processor, etc. Such as music playback, recording, etc.
[0169] The audio module 170 is used to convert digital audio information into an analog audio signal for output, and is also used to convert an analog audio input into a digital audio signal. The audio module 170 can also be used for encoding and decoding audio signals. In an embodiment of the present application, the audio module 170 can be disposed in the processor 110, or a partial functional module of the audio module 170 can be disposed in the processor 110.
[0170] The speaker 170A, also known as the "loudspeaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or hands-free calls through the speaker 170A.
[0171] The receiver 170B, also known as the "earpiece", is used to convert an audio electrical signal into a sound signal. When the electronic device 100 answers a call or a voice message, the user can listen to the voice by holding the receiver 170B close to the ear.
[0172] The microphone 170C, also known as the "microphone" or "transmitter", is used to convert a sound signal into an electrical signal. When making a call or sending a voice message, the user can speak by bringing the mouth close to the microphone 170C to input the sound signal into the microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In some other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also implement a noise reduction function. In some other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify the sound source, and implement functions such as directional recording.
[0173] The headphone jack 170D is used to connect a wired headphone. The headphone jack 170D can be a USB interface 130, or a 3.5 mm Open Mobile Terminal Platform (OMTP) standard interface, or a Cellular Telecommunications Industry Association of the USA (CTIA) standard interface.
[0174] The keys 190 include a power-on key, volume keys, etc. The keys 190 can be mechanical keys or touch keys. The electronic device 100 can receive key inputs to generate key signal inputs related to the user settings and function controls of the electronic device 100.
[0175] The motor 191 can generate vibration prompts. The motor 191 can be used for incoming call vibration prompts and also for touch vibration feedback. For example, touch operations for different applications (such as taking pictures, audio playing, etc.) can correspond to different vibration feedback effects. For touch operations on different regions of the display screen 194, the motor 191 can also correspond to different vibration feedback effects. Different application scenarios (such as time reminder, receiving messages, alarm clock, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
[0176] The indicator 192 can be an indicator light and can be used to indicate the charging state, power change, and can also be used to indicate messages, missed calls, notifications, etc.
[0177] The SIM card interface 195 is used to connect the SIM card. The SIM card can be inserted into or removed from the SIM card interface 195 to achieve contact and separation from the electronic device 100. The electronic device 100 can support 1 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 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 electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communication. In an embodiment of the present application, the electronic device 100 uses an eSIM, that is, an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100. The embodiment of the present application also provides a computer storage medium, in which computer instructions are stored. When the computer instructions run on the electronic device 100, the electronic device 100 is caused to execute the above-related method steps to implement the task management method in the above embodiment.
[0178] The embodiment of the present application also provides a computer program product. When the computer program product runs on a computer, the computer is caused to execute the above-related steps to implement the task management method in the above embodiment.
[0179] In addition, the embodiment of the present application also provides a device, which can specifically be a chip, component or module. The device can include a processor and a memory connected to each other; wherein, the memory is used to store computer execution instructions. When the device runs, the processor can execute the computer execution instructions stored in the memory to cause the chip to execute the task management method in each of the above method embodiments.
[0180] Among them, the electronic device, computer storage medium, computer program product, or chip provided in this embodiment are all used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be elaborated here.
[0181] From the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and brevity of description, only the above division of each functional module is used as an example. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.
[0182] In several embodiments provided in this application, it should be understood that the disclosed device and method can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in electrical, mechanical or other forms.
[0183] The unit described as a separated component may or may not be physically separated. The component displayed as a unit may be a physical unit or multiple physical units, that is, it can be located in one place, or it can be distributed to multiple different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0184] In addition, each functional unit in various embodiments of this application can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0185] When an integrated unit is implemented in the form of 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 solution of the embodiments of the present 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. The software product is stored in a storage medium and includes several instructions for causing a device (which can be a single-chip microcomputer, a chip, etc.) or a processor to execute all or part of the steps of the methods of the embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks, or optical discs.
[0186] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and not to limit them. Although the present application has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present application can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present application.
Claims
1. A task management method, applied to an electronic device, characterized in that The method includes: Recording the start execution time and the end execution time of each execution of the task within the statistical window; Collecting the frequency points when the processor of the electronic device executes the task; Calculating the normalized execution duration of the task according to the start execution time, the end execution time, and the frequency points; Determining the in-window load of the task according to the normalized execution duration of the task; Determining the in-window load ratio of the task according to the in-window load of the task and the statistical window; If the in-window load ratio of the task is greater than or equal to a preset threshold, determining that the task is a high-load task, and controlling the task according to a preset policy.
2. The task management method according to claim 1, wherein The recording of the start execution time and the end execution time of each execution of the task within the statistical window includes: Creating a task listener, listening to the thread that executes the task within the statistical window through the task listener, recording the creation time of the thread as the start execution time, and recording the destruction time of the thread as the end execution time.
3. The task management method according to claim 1, wherein The collecting of the frequency points when the processor of the electronic device executes the task includes: During the execution of the task, collecting real-time processor frequency points at every preset time period; Determining the maximum frequency point or the average frequency point of the collected multiple processor frequency points as the frequency point when the processor executes the task.
4. The task management method according to claim 1, wherein The calculating of the normalized execution duration of the task according to the start execution time, the end execution time, and the frequency points includes: Calculating the difference between the end execution time and the start execution time to obtain the execution duration of the task; Calculating the product of the ratio between the execution duration of the task, the frequency points, and the theoretical maximum frequency point of the processor, and the computing power of the processor to obtain the normalized execution duration.
5. The task management method according to claim 1, characterized in that The determining of the in-window load of the task according to the normalized execution duration of the task includes: If the number of executions of the task within the statistical window is multiple times, calculating the sum value of all the normalized execution durations of the multiple executions of the task within the statistical window to obtain the in-window load of the task; or If the number of executions of the task within the statistical window is one time, determining the normalized execution duration of the task when it is executed within the statistical window as the in-window load of the task.
6. The task management method according to claim 1, wherein The determining of the in-window load ratio of the task according to the in-window load of the task and the statistical window includes: Calculating the ratio between the in-window load of the task and the statistical window to obtain the in-window load ratio of the task.
7. The task management method according to claim 1, characterized in that The controlling of the task according to a preset policy includes: Binding the task to the little core processor of the electronic device, and executing the task by the little core processor.
8. The task management method according to claim 1, wherein The controlling of the task according to a preset policy includes: Setting the usage clamping parameter of the task according to the usage clamping mechanism, so that the task is executed by the little core processor of the electronic device.
9. A task management method, applied to an electronic device, characterized in that, The method includes: Recording the start execution time and the end execution time of each execution of the task per second within a preset time period; Collect the frequency points when the processor of the electronic device executes the task; Calculate the normalized execution duration of the task according to the start execution time, the end execution time, and the frequency points; Determine the normalized load per second of the task within the preset time period according to the normalized execution duration of the task; Obtain the normalized load per second within the specified statistical window from the normalized load per second of the task within the preset time period, where the specified statistical window is less than or equal to the preset time period; Determine the actual normalized load of the task within the specified statistical window according to the normalized load per second of the task within the specified statistical window, the window load grading levels, and the correspondence between the statistical window and the actual normalized load; Determine the load level of the task within the specified statistical window according to the actual normalized load of the task within the specified statistical window, the window load grading levels, and the correspondence between the statistical window and the actual normalized load; If the load level of the task within the specified statistical window is greater than or equal to the preset threshold level corresponding to the specified statistical window, determine that the task is a high-load task and control the task according to a preset policy.
10. The task management method according to claim 9, characterized in that, The recording of the start execution time and the end execution time of each execution of the task per second within the preset time period includes: Create a task listener, listen to the thread that executes the task per second through the task listener, record the creation time of the thread as the start execution time of the task, and record the destruction time of the thread as the end execution time of the task.
11. The task management method according to claim 9, wherein The calculating of the normalized execution duration of the task according to the start execution time, the end execution time, and the frequency points includes: Calculate the difference between the end execution time and the start execution time to obtain the execution duration of the task; Calculate the product of the ratio of the execution duration of the task, the frequency points, and the theoretical maximum frequency of the processor, and the computing power of the processor to obtain the normalized execution duration.
12. The task management method according to claim 9, wherein The determining of the normalized load per second of the task within the preset time period according to the normalized execution duration of the task includes: If the task is executed multiple times per second, calculate the sum of all the normalized execution durations when the task is executed multiple times per second to obtain the normalized load of the task per second; or If the task is executed once per second, determine the normalized execution duration when the task is executed per second as the normalized load of the task per second.
13. The task management method according to claim 9, wherein The determining of the actual normalized load of the task within the specified statistical window according to the normalized load per second of the task within the specified statistical window, the window load grading levels, and the correspondence between the statistical window and the actual normalized load includes: Compare the normalized load per second of the task within the specified statistical window with the correspondence table of the window load grading levels and the correspondence between the statistical window and the actual normalized load to determine the load level of the task per second; Determine the actual normalized load corresponding to the load level of the task per second in the corresponding relationship table, and determine the sum value of multiple actual normalized loads as the actual normalized load of the task within the specified statistical window.
14. The task management method according to claim 13, wherein The determining the load level of the task within the specified statistical window according to the actual normalized load of the task within the specified statistical window, the window load classification level, and the corresponding relationship between the statistical window and the actual normalized load includes: Compare the actual normalized load of the task within the specified statistical window with the corresponding relationship table between the window load classification level and the statistical window and the actual normalized load to determine the load level of the task within the specified statistical window.
15. The task management method according to claim 9, characterized in that, The controlling the task according to a preset policy includes: Bind the task to the little core processor of the electronic device, and execute the task by the little core processor.
16. The task management method according to claim 9, wherein The controlling the task according to a preset policy includes: Set the usage rate clamping parameter of the task according to the usage rate clamping mechanism, so that the task is executed by the little core processor of the electronic device.
17. An electronic device, characterized in that, The electronic device includes a memory and a processor: Wherein, the memory is used for storing program instructions; The processor is used for reading and executing the program instructions stored in the memory. When the program instructions are executed by the processor, the electronic device executes the task management method according to any one of claims 1 to 16.
18. A chip, coupled to a memory in an electronic device, characterized in that, The chip is used for controlling the electronic device to execute the task management method according to any one of claims 1 to 16.
19. A computer storage medium, characterized in that, The computer storage medium stores program instructions. When the program instructions run on an electronic device, the processor of the electronic device executes the task management method according to any one of claims 1 to 16.
Citation Information
Cited By
Task management method and related device
EP4769141A1