A task processing method and an electronic device

By adjusting thread pool priority based on preset binding relationships and performance monitoring data in electronic devices, the problem of lag in camera applications under multi-task concurrency and heavy load is solved, and a more stable and smooth camera operation experience is achieved.

CN118467149BActive Publication Date: 2025-07-11HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311864934.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-29
Publication Date
2025-07-11
Estimated Expiration
2043-12-29

AI Technical Summary

Technical Problem

In the case of multi-task concurrency and heavy load, the camera application may experience lag and frame loss on the screen, affecting the user experience.

Method used

By determining the target thread pool based on preset binding relationships, adjusting thread priorities based on performance monitoring data, reasonably allocating system resources, and executing tasks in the task queue.

Benefits of technology

Improves the stability and fluency of camera applications and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118467149B_ABST
    Figure CN118467149B_ABST
Patent Text Reader

Abstract

An embodiment of the present application provides a task processing method, an electronic device, and a computer-readable storage medium. In this method, in response to a function trigger operation on a camera application, a task queue matching a target camera function is determined; based on a preset binding relationship, a target thread pool matching the task queue is determined; and tasks in the task queue are executed by using threads in the target thread pool, where the thread priorities in the target thread pool are adjustable. It is beneficial to achieve refined task processing and can effectively improve the stability and fluency of the camera application.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the technical field of terminals, and in particular, to a task processing method and an electronic device. Background Art

[0002] The operating system of an electronic device may encounter situations of multi-task concurrency and heavy load, which may cause tasks to fail to respond in a timely manner and result in application lag.

[0003] For example, when a user uses a camera application in a heavy-load scenario, the camera shooting interface may freeze, or frames may be dropped during video shooting, seriously affecting the user experience. Summary of the Invention

[0004] To solve the above technical problems, the present application provides a task processing method, an electronic device, and a computer-readable storage medium. In this method, based on a preset binding relationship, a target thread pool matching the task queue is determined, and the thread priorities in the target thread pool are adjustable. The threads in the target thread pool are used to execute the tasks in the task queue. Adjusting the thread priorities under different load states of system resources is beneficial to realizing the reasonable utilization of system resources and ensuring the smoothness and stability of the camera application.

[0005] In a first aspect, an embodiment of the present application provides a task processing method applied to an electronic device. The method includes: in response to a function trigger operation on a camera application, determining a task queue matching the target camera function; based on a preset binding relationship, determining a target thread pool matching the task queue; and using the threads in the target thread pool to execute the tasks in the task queue.

[0006] According to the embodiments of the present disclosure, it is beneficial to realize the refined processing of camera application tasks, beneficial to the rational allocation of computing resources, can effectively improve the stability and fluency of the camera application, and can effectively improve the user experience.

[0007] According to the first aspect, the thread priorities in the target thread pool are adjustable. The task processing method further includes: during the running of the camera application, obtaining performance monitoring data associated with the camera application; and adjusting the thread priorities in the target thread pool according to the performance monitoring data.

[0008] According to the first aspect, or any implementation of the above first aspect, adjusting the thread priority in the target thread pool according to the performance monitoring data includes: when the performance monitoring data indicates that there are dropped frames in the camera application, adjusting the thread priority in the target thread pool according to the functional operation characteristics of the target camera function. The functional operation characteristics include at least one of the following information of the target camera function: function type, functional operation platform, whether the function is perceivable, and function application frequency.

[0009] According to the first aspect, or any implementation of the above first aspect, adjusting the thread priority in the target thread pool according to the functional operation characteristics of the target camera function includes: when the function type indicates that the target camera function is a preset important function, increasing the thread priority in the target thread pool; and when the function type indicates that the target camera function is a preset non-important function, decreasing the thread priority in the target thread pool.

[0010] The preset important function can be a basic function that is easily perceivable by the camera application. When there are dropped frames in the camera application, increasing the thread priority for implementing the preset important function can effectively ensure the fluency and stability of the camera application.

[0011] According to the first aspect, or any implementation of the above first aspect, adjusting the thread priority in the target thread pool according to the functional operation characteristics of the target camera function includes: when the functional operation platform indicates that the target camera function runs in the foreground, increasing the thread priority in the target thread pool; and when the functional operation platform indicates that the target camera function runs in the background, decreasing the thread priority in the target thread pool.

[0012] When the functional operation platform indicates that the target camera function runs in the foreground, increasing the thread priority in the target thread pool can provide more computing resources for the target camera function and ensure the smooth implementation of the target camera function. When the functional operation platform indicates that the target camera function runs in the background, decreasing the thread priority in the target thread pool, since the camera application is in a state of less computing resource demand, by decreasing the thread priority in the target thread pool, it is beneficial to ensure the rational allocation of computing resources.

[0013] According to the first aspect, or any implementation manner of the above first aspect, adjusting the thread priority in the target thread pool according to the function running characteristics of the target camera function includes: when the function running characteristics indicate that the target camera function is a perceivable function, increasing the thread priority in the target thread pool; and when the function running characteristics indicate that the target camera function is a non-perceivable function, decreasing the thread priority in the target thread pool.

[0014] When the target camera function can be perceived by the user, increasing the thread priority in the target thread pool is beneficial to ensuring the stability of the implementation of the target camera function. When the target camera function is not easily perceived by the user, decreasing the thread priority in the target thread pool is beneficial to ensuring the smoothness of the implementation of other camera functions.

[0015] According to the first aspect, or any implementation manner of the above first aspect, adjusting the thread priority in the target thread pool according to the function running characteristics of the target camera function includes: when the function running characteristics indicate that the application frequency of the target camera function is higher than a first preset threshold, increasing the thread priority in the target thread pool; and when the function running characteristics indicate that the application frequency of the target camera function is lower than a second preset threshold, decreasing the thread priority in the target thread pool, where the first preset threshold is greater than or equal to the second preset threshold.

[0016] According to the embodiments of the present disclosure, for a target camera function with a high application frequency, by increasing the thread priority, the user or system requirements can be responded to more quickly, improving the user experience. For a target camera function with a low application frequency, by decreasing the thread priority, energy consumption can be saved without affecting the camera application performance.

[0017] According to the first aspect, or any implementation manner of the above first aspect, the task processing method further includes: scheduling the CPU resources matching the target thread pool according to the performance monitoring data, where the CPU resources include at least one of the following parameters: CPU frequency point, the CPU core on which the thread runs, and whether to allow the execution of system actions.

[0018] According to the first aspect, or any implementation of the above first aspect, the task processing method further includes: during the operation of the camera application, obtaining real-time load data of the operating system of the electronic device; and according to the real-time load data, adjusting the thread priorities in the target thread pool and / or scheduling CPU resources matching the target thread pool, where the real-time load data includes at least one of the following parameters: the number of currently created threads, the processor idle ratio, the processor memory occupancy rate, and the CPU program occupancy rate.

[0019] According to an embodiment of the present disclosure, by dynamically adjusting the thread pool and CPU resources, the smoothness and stability of the camera application can be effectively ensured, which is beneficial to improving the user experience.

[0020] According to the first aspect, or any implementation of the above first aspect, the method further includes: adjusting the number of threads in the target thread pool according to the number of tasks in the task queue.

[0021] According to an embodiment of the present disclosure, it can be ensured that the thread pool can flexibly adapt to the workload when processing a large number of tasks, and at the same time, it can avoid wasting resources due to excessive thread creation.

[0022] According to the first aspect, or any implementation of the above first aspect, the adjusting the number of threads in the target thread pool according to the number of tasks in the task queue includes: when the number of tasks in the task queue reaches at least one target number for creating threads, creating a new thread in the target thread pool, where the target number is determined according to the core thread number in the target thread pool, the preset maximum thread number, and the length of the task queue.

[0023] According to the first aspect, or any implementation of the above first aspect, the method further includes: destroying an idle thread when there is an idle thread in the target thread pool whose idle duration is greater than a preset duration threshold.

[0024] According to an embodiment of the present disclosure, by destroying idle threads, the computing resources occupied by the idle threads can be used by other threads, programs, or applications, which is beneficial to improving the usage efficiency of system resources.

[0025] According to the first aspect, or any implementation of the above first aspect, the method further includes: monitoring the running duration of each thread in the target thread pool for executing the current task; and creating a new thread in the target thread pool when the running duration indicates that there is a thread running overtime.

[0026] According to an embodiment of the present disclosure, resource waste caused by waiting for timeout threads can be effectively avoided, which is beneficial to improving the task processing efficiency and ensuring the smooth implementation of the camera function.

[0027] According to the first aspect, or any one of the implementation manners of the above first aspect, the determining the task queue matching the target camera function in response to the function trigger operation on the camera application includes: in response to detecting the function trigger operation, determining the perception algorithm for implementing the target camera function; and decomposing the perception algorithm into at least one task to obtain the task queue composed of the at least one task.

[0028] According to the first aspect, or any one of the implementation manners of the above first aspect, the perception algorithm has a preset algorithm priority, and the method further includes: during the running of the camera application, acquiring performance monitoring data associated with the camera application; and adjusting the algorithm priority of the perception algorithm according to the performance monitoring data.

[0029] The perception algorithm matching the target camera function has a preset algorithm priority, and the algorithm priority can affect the speed at which the perception algorithm obtains GPU resources. Specifically, a higher-priority algorithm is more likely to obtain GPU resources faster. In practical applications, the algorithm priority of the perception algorithm can be set according to the real-time requirements of the application scenario.

[0030] According to the first aspect, or any one of the implementation manners of the above first aspect, the perception algorithm has a preset algorithm priority, and the binding relationship between the task queue and the target thread pool is determined according to the algorithm priority and the thread priority.

[0031] Exemplarily, a perception algorithm with a higher algorithm priority can be bound to a thread pool with a higher thread priority, and a perception algorithm with a lower algorithm priority can be bound to a thread pool with a lower thread priority.

[0032] According to the first aspect, or any one of the implementation manners of the above first aspect, the binding relationship can also be determined according to the number of threads in the thread pool and the length of the task queue.

[0033] Second aspect, embodiments of the present application provide an electronic device, including: one or more processors, a memory, and one or more computer programs, wherein the one or more computer programs are stored on the memory, and when the computer programs are executed by the one or more processors, the electronic device is caused to perform the following steps: in response to a function trigger operation on a camera application, determine a task queue matching a target camera function; based on a preset binding relationship, determine a target thread pool matching the task queue; and use threads in the target thread pool to execute tasks in the task queue.

[0034] The second aspect and any implementation manner of the second aspect respectively correspond to the first aspect and any implementation manner of the first aspect. For the technical effects corresponding to the second aspect and any implementation manner of the second aspect, reference may be made to the technical effects corresponding to the first aspect and any implementation manner of the first aspect described above, and details are not described herein again.

[0035] Third aspect, embodiments of the present application provide a computer-readable medium for storing a computer program, where the computer program includes instructions for performing the method in the first aspect or any possible implementation manner of the first aspect.

[0036] Fourth aspect, embodiments of the present application provide a computer program, where the computer program includes instructions for performing the method in the first aspect or any possible implementation manner of the first aspect.

[0037] Fifth aspect, embodiments of the present application provide a chip, which includes a processing circuit and transceiver pins. Wherein, the transceiver pins and the processing circuit communicate with each other through an internal connection path, and the processing circuit executes the method in the first aspect or any possible implementation manner of the first aspect to control a receiving pin to receive a signal and control a sending pin to send a signal. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 To exemplarily show a schematic diagram of an application scenario;

[0039] Figure 2 To exemplarily show a schematic diagram of the structure of an electronic device;

[0040] Figure 3 To exemplarily show a software structure block diagram of an electronic device;

[0041] Figure 4 To show a flowchart of a task processing process provided by an embodiment of the present application;

[0042] Figure 5 To show a schematic diagram of a task queue and a thread pool provided by an embodiment of the present application;

[0043] Figure 6 It is a schematic diagram of the process of a task processing provided by an embodiment of the present application;

[0044] Figure 7 It is another schematic diagram of the process of a task processing provided by an embodiment of the present application. Specific embodiments

[0045] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts belong to the scope of protection of the present application.

[0046] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone.

[0047] The terms "first" and "second" in the description and claims of the embodiments of the present application are used to distinguish different objects, rather than to describe a specific order of the objects. For example, the first target object and the second target object are used to distinguish different target objects, rather than to describe a specific order of the target objects.

[0048] In the embodiments of the present application, words such as "exemplarily" or "for example" are used to give examples, illustrations or explanations. Any embodiment or design solution described as "exemplarily" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or having more advantages than other embodiments or design solutions. Exactly speaking, using words such as "exemplarily" or "for example" is intended to present relevant concepts in a specific way.

[0049] In the description of the embodiments of the present application, unless otherwise specified, the meaning of "a plurality of" refers to two or more. For example, a plurality of processing units refers to two or more processing units; a plurality of systems refers to two or more systems.

[0050] Before explaining the technical solutions of the embodiments of the present application, first, the application scenarios of the embodiments of the present application will be described in conjunction with the accompanying drawings. As Figure 1 shown is a schematic diagram of an application scenario provided by an embodiment of the present application. As Figure 1As shown, in response to a trigger operation for photographing the target object 101, the electronic device captures and displays an image 102 within a preset range, which may be, for example, the shooting range of the camera of the electronic device. In the case of multi-task concurrency or heavy load in the operating system of the electronic device, the camera application's photographing interface may experience lag (as indicated by 103), affecting the user experience.

[0051] An embodiment of the present application provides a task processing method applied to an electronic device. The electronic device determines a target camera function triggered by the user and a task queue matching the target camera function in response to a function trigger operation on the camera application by the user. The electronic device determines a target thread pool matching the task queue based on a preset binding relationship and uses the threads in the target thread pool to execute the tasks in the task queue. By using the bound thread pool to execute camera application tasks, the priorities of the threads in the thread pool can be adjusted, which can effectively ensure the smooth execution of camera tasks and is conducive to ensuring the stability and fluency of the camera application.

[0052] As Figure 2 As shown is a schematic structural diagram of the electronic device 100. Optionally, the electronic device 100 may be referred to as a terminal or a terminal device. The electronic device 100 may be a terminal device with a photographing function, and the specific product form may be a smart terminal, such as a mobile phone, a tablet, a DV, a video camera, a camera, a portable computer, a notebook computer, a smart speaker, etc., products equipped with a camera. Specifically, the functional modules involved in the present application may be deployed on the DSP chip of the relevant device, specifically an application program or software therein. Through software installation or upgrade, and through the cooperation of hardware calls, a task processing function can be provided, aiming to improve the fluency and stability of the camera application operation.

[0053] It should be understood that Figure 2 The electronic device 100 shown is only an example of an electronic device, and the electronic device 100 may have more or fewer components than those shown in the figure, may combine two or more components, or may have different component configurations. Figure 2 The various components shown can be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application-specific integrated circuits.

[0054] 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 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. Among them, the sensor module 180 may include a pressure sensor, a gyroscope sensor, an acceleration sensor, a temperature sensor, a motion sensor, a barometric pressure sensor, a magnetic sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc.

[0055] 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 memory, 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.

[0056] Among them, the controller may be the nerve center and command center of the electronic device 100. The controller may generate operation control signals according to the instruction operation code and timing signal to complete the control of fetching and executing instructions.

[0057] A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory.

[0058] The USB interface 130 is an interface that conforms to the USB standard specification. Specifically, it may be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc.

[0059] The charging management module 140 is used to receive a charging input from a charger. The charger can be a wireless charger or a wired charger. While charging the battery 142, the charging management module 140 can also supply power to the electronic device through the power management module 141. 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 inputs from the battery 142 and / or the charging management module 140 and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, the wireless communication module 160, etc.

[0060] 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.

[0061] 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.

[0062] The mobile communication module 150 can provide solutions for wireless communications such as 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.

[0063] The wireless communication module 160 can provide solutions for wireless communications applied to the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc.

[0064] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technologies.

[0065] The electronic device 100 realizes the display function through a GPU, a display screen 194, an application processor, etc. The processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.

[0066] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.

[0067] The electronic device 100 can realize the shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, etc.

[0068] 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 passes through the lens and is transmitted to the camera photosensitive element. The optical signal is converted into an electrical signal, and 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 some embodiments, the ISP may be provided in the camera 193.

[0069] The camera 193 is used to capture still 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 format such as RGB or YUV. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.

[0070] Among them, the camera 193 can be located in the edge area of the electronic device, and can be an under-screen camera or a retractable camera. The camera 193 may include a rear camera and may also include a rear camera. The specific position and form of the camera 193 in the embodiments of the present application are not limited. The electronic device 100 may include cameras with one or more focal lengths. For example, cameras with different focal lengths may include telephoto cameras, wide-angle cameras, ultra-wide-angle cameras, or panoramic cameras, etc.

[0071] The external memory interface 120 can be used to connect to an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement the data storage function.

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

[0073] The electronic device 100 can implement audio functions through the audio module 170 and the application processor, etc. For example, music playback, recording, etc.

[0074] 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 to encode and decode audio signals. In some embodiments, the audio module 170 can be disposed in the processor 110, or some functional modules of the audio module 170 can be disposed in the processor 110.

[0075] The touch sensor, also known as the "touch panel". The touch sensor can be disposed on the display screen 194, and the touch sensor and the display screen 194 form a touch screen, also known as the "touch screen". The touch sensor is used to detect touch operations acting on it or nearby. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194.

[0076] The pressure sensor is used to sense pressure signals and can convert the pressure signals into electrical signals. In some embodiments, the pressure sensor can be disposed on the display screen 194. The electronic device 100 can also calculate the touch position according to the detection signal of the pressure sensor.

[0077] The gyroscope sensor can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., the x, y, and z axes) can be determined by the gyroscope sensor.

[0078] The acceleration sensor can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes). When the electronic device 100 is stationary, the acceleration sensor can detect the magnitude and direction of gravity. The acceleration sensor can also be used to identify the posture of the electronic device and is applied to applications such as horizontal and vertical screen switching and pedometers.

[0079] The button 190 includes a power-on button (or power button), volume buttons, etc. The button 190 can be a mechanical button or a touch button. The electronic device 100 can receive button inputs and generate key signal inputs related to the user settings and function control of the electronic device 100.

[0080] The software system of the electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservices architecture, or cloud architecture. In the embodiments of the present invention, the Android system with a layered architecture is taken as an example to exemplarily illustrate the software structure of the electronic device 100.

[0081] As Figure 3 For the software structure block diagram of the electronic device 100 shown exemplarily, the layered architecture of the electronic device 100 divides the software into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely the application layer, application framework layer, Android runtime, system layer, and kernel layer.

[0082] The application layer may include a series of application packages. As Figure 3 shown, the application packages may include applications such as cameras, galleries, videos, and WLAN. The application layer may also include a system perception module, and the system perception module includes preset configuration information. The preset configuration information, for example, includes information such as the algorithm priority of the perception algorithms associated with the camera application, the number of threads in the created thread pool, thread priorities, and the CPU cores on which the threads run.

[0083] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the applications in the application layer, including various components and services to support developers' Android development. The application framework layer includes some predefined functions. As Figure 3As shown in the figure, the application framework layer may include a window manager, a content provider, a notification manager, a resource manager, a CPU load detection module, a CPU resource scheduling module, an application performance monitoring module, an application service module, etc.

[0084] 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.

[0085] The content provider is used to store and obtain data, and make this data accessible to application programs. The data may include videos, images, audio, dialed and received calls, browsing history and bookmarks, phone books, etc.

[0086] The resource manager can provide various resources for application programs, such as localized strings, icons, pictures, layout files, video files, and so on.

[0087] The notification manager enables application programs to display notification information in the status bar. It can be used to convey notification-type messages, which can automatically disappear after a short stay without user interaction. For example, notification information is used to inform that the download is complete, message reminders, etc. Notification information can also be notifications that appear in the system top status bar in the form of charts or scroll bar texts, such as notifications of background-running application programs, and can also be notifications that appear in the form of a dialogue window on the screen. For example, prompt text information is displayed in the status bar, a prompt sound is emitted, the electronic device vibrates, the indicator light flashes, etc.

[0088] The CPU load detection module is used to detect the CPU load information of the electronic device. The CPU load information may include, for example, the number of CPU core frequency points, the current maximum operating frequency of the CPU, the current minimum operating frequency of the CPU, the CPU usage rate and other information. The CPU load information is used to indicate the load situation of the CPU, and the CPU load information can be read from the kernel scheduling module.

[0089] The CPU resource scheduling module is used to perform CPU load scheduling according to the CPU load information and the performance monitoring data of the application. The CPU load scheduling includes, for example, operations such as CPU frequency modulation and CPU core switching.

[0090] The application performance monitoring module is used to obtain the performance monitoring data when the application is running. For example, it is used to obtain information such as the frame rate, network activity, startup duration, response duration, and photo saving duration when the camera application is running. The application service module is used to determine the task processing strategy when the application is running according to the performance monitoring data when the application is running, and according to the preset configuration information in the system perception module.

[0091] The system layer includes system libraries and the Android Runtime. The system libraries can include multiple functional modules, such as an image rendering library, an image composition library, function libraries, and media libraries, etc. The Android Runtime includes core libraries and a virtual machine, and the Android Runtime is responsible for the scheduling and management of the Android system. The core libraries contain 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. The application layer and the application framework layer run in the virtual machine, and the virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0092] It can be understood that Figure 3 The components included in the illustrated system framework layer, system libraries, and runtime layer do not constitute a specific limitation on the electronic device 100. In some 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.

[0093] The kernel layer is the layer between the hardware and the above software layer. The kernel layer includes at least a display driver, a camera driver, and a sensor driver. The hardware may include devices such as a camera, a display screen, a microphone, a processor, and a memory.

[0094] Next, in combination with Figure 4 the flowchart shown, the task processing process will be schematically described. As Figure 4 shown, the task processing process may include operations S101 to S103.

[0095] Operation S101, the electronic device determines a task queue that matches the target camera function in response to a function trigger operation on the camera application.

[0096] Operation S102, the electronic device determines a target thread pool that matches the task queue based on a preset binding relationship.

[0097] Operation S103, the electronic device uses the threads in the target thread pool to execute the tasks in the task queue.

[0098] Next, example examples of the operations of the task processing process of this embodiment will be described.

[0099] Operation S101, the electronic device determines a task queue that matches the target camera function in response to a function trigger operation on the camera application.

[0100] Taking the application service module in an electronic device as the execution entity as an example, the application service module determines a perception algorithm for implementing the target camera function in response to a function trigger operation on the camera application. The target camera function includes any camera function triggered by the user. Camera functions include, for example, functions such as taking pictures, recording videos, portrait recognition, smile detection, motion capture, and scene recognition. The camera function can be implemented based on a perception algorithm. The perception algorithm includes, for example, a face recognition algorithm, a subject detection algorithm, an expression recognition algorithm, a scene segmentation algorithm, and an object tracking algorithm. Exemplarily, the scene segmentation algorithm is used to segment an image into multiple regions, and different regions may correspond to different scenes or objects. The scene segmentation algorithm can be used for functions such as background blurring and intelligent photo retouching.

[0101] The application service module decomposes the perception algorithm into at least one task to obtain a task queue composed of at least one task. A task is the basic unit of algorithm execution. In multi-threaded programming, different tasks can be assigned to different threads for execution to achieve parallel task processing and speed up the task completion speed.

[0102] Operation S102, the electronic device determines a target thread pool that matches the task queue based on a preset binding relationship.

[0103] The application service module determines a target thread pool that matches the task queue based on a preset binding relationship. The number of threads, thread priorities, and CPU cores on which the threads in the target thread pool run are adjustable. The perception algorithm that matches the target camera function has a preset algorithm priority. The algorithm priority can affect the speed at which the perception algorithm obtains GPU resources. Specifically, a higher-priority algorithm is more likely to obtain GPU resources faster. In practical applications, the algorithm priority of the perception algorithm can be set according to the real-time requirements of the application scenario. For example, a higher priority can be set for algorithms with high real-time requirements such as the face recognition algorithm and the subject detection algorithm.

[0104] The binding relationship between the task queue and the target thread pool can be determined according to the algorithm priority and the thread priority. Exemplarily, a perception algorithm with a higher algorithm priority can be bound to a thread pool with a higher thread priority, and a perception algorithm with a lower algorithm priority can be bound to a thread pool with a lower thread priority. In addition, the binding relationship can also be determined according to the number of threads in the thread pool and the length of the task queue. The length of the task queue can be indicated by the number of tasks in the task queue, for example.

[0105] Operation S103, the electronic device uses the threads in the target thread pool to execute the tasks in the task queue.

[0106] The operating system utilizes the threads in the target thread pool to execute the tasks in the task queue. Exemplarily, when the task queue type is a serial task queue, the operating system can utilize an idle thread in the target thread pool to execute the tasks in the task queue. When the task queue type is a parallel task queue, the operating system can utilize n idle threads in the target thread pool to execute the tasks in the task queue, and the maximum value of n is the number of tasks in the task queue.

[0107] In an example manner, during the running of the camera application, the application performance monitoring module can be used to obtain the performance monitoring data associated with the camera application. Through the application service module, the thread priorities in the target thread pool can be adjusted according to the performance monitoring data associated with the camera application.

[0108] The performance monitoring data includes, for example, information such as the frame rate, startup duration, response duration, and photo saving duration during the running of the camera application. When the performance monitoring data indicates that there are dropped frames in the camera application, the application service module adjusts the thread priorities in the target thread pool according to the function running characteristics of the target camera function. The function running characteristics include at least one of the following information of the target camera function: function type, function running platform, whether the function is perceivable, and function application frequency.

[0109] Exemplarily, when the function type indicates that the target camera function is a preset important function, the application service module can increase the thread priorities in the target thread pool. When the function type indicates that the target camera function is a preset non-important function, the application service module can decrease the thread priorities in the target thread pool. The preset important functions include, for example, the face recognition function, the subject detection function, etc., and the preset non-important functions include, for example, the smile detection function, the environment recognition function, etc. The preset important functions can be the basic functions that are easily perceivable by the camera application. When there are dropped frames in the camera application, increasing the thread priorities for the threads used to implement the preset important functions can effectively ensure the fluency and stability of the camera application.

[0110] When the function running platform indicates that the target camera function is running in the foreground, the application service module can increase the thread priorities in the target thread pool. When the function running platform indicates that the target camera function is running in the background, the application service module can decrease the thread priorities in the target thread pool.

[0111] Exemplarily, the function running platform indicates whether the target camera function is displayed on the user interface of the electronic device. The function running platform includes the foreground and the background. The foreground is, for example, the part of the electronic device where the user directly interacts, including the graphical user interface or the command interface, etc. The background is, for example, the part that runs behind the user interface of the electronic device, and the user does not directly participate in the implementation of the camera function.

[0112] When the function running platform indicates that the target camera function is running in the foreground, increasing the thread priority in the target thread pool can provide more computing resources for the target camera function and ensure the smooth implementation of the target camera function. When the function running platform indicates that the target camera function is running in the background, decreasing the thread priority in the target thread pool is beneficial to ensuring the rational allocation of computing resources because the camera application is in a state of less demand for computing resources.

[0113] Adjusting the thread priority according to the function running platform is conducive to the refined processing of tasks, can effectively improve the stability and smoothness of the camera application, and is beneficial to improving the user experience.

[0114] When the function running feature indicates that the target camera function is a perceivable function, the application service module can increase the thread priority in the target thread pool. When the function running feature indicates that the target camera function is a non-perceivable function, the application service module can decrease the thread priority in the target thread pool.

[0115] When the target camera function can be perceived by the user, increasing the thread priority in the target thread pool is beneficial to ensuring the stability of the implementation of the target camera function. The perceivable functions of the camera application include, for example, photo preview function, face recognition function, gesture recognition function, and autofocus function, etc. When the target camera function is not easily perceived by the user, decreasing the thread priority in the target thread pool is beneficial to ensuring the smoothness of the implementation of other camera functions. The non-perceivable functions do not directly involve the perception of the environment or user behavior by the camera application, and include, for example, intelligent scene recognition function, dynamic range optimization function, ambient light sensing function, etc.

[0116] When the function running feature indicates that the application frequency of the target camera function is higher than the first preset threshold, the application service module can increase the thread priority in the target thread pool. When the function running feature indicates that the application frequency of the target camera function is lower than the second preset threshold, the application service module can decrease the thread priority in the target thread pool, and the first preset threshold is greater than or equal to the second preset threshold.

[0117] An example way is to use the CPU resource scheduling module to schedule the CPU resources matching the target thread pool according to the performance monitoring data during the operation of the camera application. The CPU resources include at least one of the following parameters: CPU frequency point, the CPU core on which the thread runs, and whether to allow the execution of system actions.

[0118] Exemplarily, when the performance monitoring data indicates that there are dropped frames in the camera application during operation, the CPU resource scheduling module may perform at least one of the following operations according to the functional operation characteristics of the target camera function: adjusting the CPU core on which the threads in the target thread pool run, adjusting the CPU frequency point, and determining whether to execute a system action matching the target camera function.

[0119] The CPU frequency point refers to the working frequency of the CPU, usually in GHz (gigahertz). The CPU core on which the thread runs refers to the physical CPU core on which the thread runs, which may include large cores and small cores. System actions in the Android system can be pre-defined operations or events that can be triggered by an application or the system itself to start, stop, or execute interactions between applications.

[0120] In another example, during the operation of the camera application, the CPU load detection module is used to obtain the real-time load data of the operating system of the electronic device. The CPU resource scheduling module is used to adjust the thread priorities in the target thread pool and / or schedule the CPU resources matching the target thread pool according to the real-time load data. The real-time load data includes at least one of the following parameters: the number of currently created threads, the processor idle ratio, the processor memory occupancy rate, and the CPU program occupancy ratio. For example, the CPU resource scheduling module schedules resources such as the CPU frequency point allocated to the camera application, the CPU core on which the threads in the thread pool run, whether to allow the execution of system actions, and the remaining memory.

[0121] The application service module can adjust the number of threads in the target thread pool according to the number of tasks in the task queue. Exemplarily, when the number of tasks reaches at least one target number for creating a thread, a new thread is created in the target thread pool. The target number is determined according to the core thread number in the target thread pool, the preset maximum thread number, and the length of the task queue. The core thread number can be the default value of the electronic device, for example, the core number of the CPU of the electronic device, and the core thread number is, for example, 2.

[0122] The step size can be determined according to the core thread number in the target thread pool, the preset maximum thread number, and the length of the task queue. The step size is used to represent the task growth amount required to create a new thread. When the number of tasks in the task queue increases by at least one step size, the application service module creates a new thread in the thread pool.

[0123] Exemplarily, the step size step = Length / (N_max - N_core), where Length represents the length of the task queue, and Length can be indicated by, for example, the number of tasks in the task queue. N_max represents the preset maximum number of threads, and N_core represents the number of core threads. For example, the number of core threads N_core is 2, the preset maximum number of threads N_max is 12, the length of the task queue Length is 100, and the step size step is 10. That is, when the number of tasks in the task queue increases by at least one 10, the application service module creates a new thread in the thread pool, and the number of threads in the thread pool needs to be less than or equal to the preset maximum number of threads.

[0124] The application service module can also monitor the running duration of each thread in the target thread pool when executing the current task. In the case where the running duration indicates that a thread is running overtime, the application service module can create a new thread in the target thread pool. Additionally, in the case where there are idle threads in the target thread pool with an idle duration greater than the preset duration threshold, the application service module can destroy the idle threads.

[0125] Figure 5 Schematically shows a schematic diagram of the task queue and the thread pool, as Figure 5 shown, the tasks to be executed by the camera application include Task 1, Task 2,..., Task 10. When the operating system of the electronic device processes the tasks to be executed by the camera application, Task 1, Task 2,..., Task 6 are stored in Task Queue 1, and Task 7, Task 8, Task 9, Task 10 are stored in Task Queue 2. Task Queue 1 and Task Queue 2 are used to implement different camera functions. There is a preset binding relationship between Task Queue 1 and Thread Pool 1, and Thread 1 in Thread Pool 1 is used to execute the tasks stored in Task Queue 1. There is a preset binding relationship between Task Queue 2 and Thread Pool 2, and Threads 3 and 4 in Thread Pool 2 are used to execute the tasks stored in Task Queue 1.

[0126] Figure 6 Schematically shows a schematic diagram of a task processing process, as Figure 6 shown, the process of camera task processing includes, for example, operations S201 to S204.

[0127] Operation S201, the electronic device responds to the function trigger operation of the camera application and confirms the triggered target camera function. There may be more than one triggered target camera function. For example, after the camera application is started, the triggered target camera functions may include, for example, face recognition function, subject detection function, ambient light detection function, etc.

[0128] Operation S202, the electronic device loads a configuration file. The camera function can be implemented by a perception algorithm, and the configuration file includes a preset algorithm priority that matches the perception algorithm. The algorithm priority can affect the speed at which the perception algorithm obtains GPU resources. Specifically, a higher-priority algorithm is more likely to obtain GPU resources faster.

[0129] Operation S203, the electronic device constructs a task queue for implementing the target camera function. Exemplarily, the electronic device decomposes the perception algorithm into at least one task to obtain a task queue composed of at least one task.

[0130] In operation S204, the electronic device uses multi-threading to execute tasks. The operating system of the electronic device has multiple thread pools pre-created, and the number of threads, thread priorities, and CPU cores on which the threads run in each thread pool can be adjusted. There is a preset binding relationship between the thread pool and the camera function. The electronic device determines the target thread pool that matches the task queue based on the preset binding relationship, and uses the threads in the target thread pool to execute the tasks in the task queue.

[0131] Figure 7 Schematically shows a schematic diagram of another task processing process, as Figure 7 shown, the thread pool management object is used to manage thread pool resources, such as for managing thread pool 1, thread pool 2,..., thread pool n. Taking thread pool 1 as an example, the thread pool management object creates a preset number of threads in thread pool 1 and sets the thread priority and the CPU core on which the thread runs. The task management object is used to manage the task queue, such as for managing task queue 1, task queue 2,..., task queue n.

[0132] There is a preset binding relationship between the thread pool and the task queue. For example, there is a binding relationship between thread pool 1 and task queue 1, and the tasks stored in task queue 1 can be executed by the threads in thread pool 1. During the task execution process, the thread pool management object monitors the thread pool status. When there are idle threads in the thread pool, the thread pool management object reclaims the thread resources. For example, when there are idle threads in the thread pool whose idle duration is greater than the preset duration threshold, the thread pool management object destroys the corresponding idle threads. When there is serious queuing during the task execution process, the thread pool management object creates new threads and uses the new threads to participate in task execution. After the tasks in task queue 1 are completed, the thread pool management object reclaims the thread resources in thread pool 1.

[0133] It can be understood that, in order to implement the above functions, the electronic device includes the corresponding hardware and / or software modules for executing each function. Combining the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the way of hardware or computer software driving the hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered to exceed the scope of the present application.

[0134] All the relevant content of each step involved in the above method embodiments can be cited to the function description of the corresponding function module, and will not be repeated here.

[0135] This embodiment also provides an electronic device, including: one or more processors, a memory, and one or more computer programs, wherein the one or more computer programs are stored on the memory, and when the computer programs are executed by the one or more processors, the electronic device is caused to execute the following steps: in response to a function trigger operation for a camera application, determining a task queue matching a target camera function; based on a preset binding relationship, determining a target thread pool matching the task queue; and using the threads in the target thread pool to execute the tasks in the task queue. The thread priorities in the target thread pool are adjustable.

[0136] This embodiment also provides a computer storage medium, in which computer instructions are stored, and when the computer instructions run on an electronic device, the electronic device is caused to execute the above related method steps to implement the task processing method in the above embodiment.

[0137] This embodiment also provides a computer program product, which when running on a computer, causes the computer to execute the above related steps to implement the task processing method in the above embodiment.

[0138] In addition, an embodiment of the present application also provides a device, which may specifically be a chip, a component or a module. The device may include a processor and a memory connected to each other; wherein, the memory is used to store computer execution instructions, and when the device runs, the processor may execute the computer execution instructions stored in the memory to cause the chip to execute the task processing method in each of the above method embodiments.

[0139] 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 repeated here.

[0140] From the description of the above embodiments, those skilled in the art can understand that for the convenience and brevity of description, only the division of the above function modules is used as an example. In actual applications, the above functions can be allocated to different function modules according to needs, that is, the internal structure of the device is divided into different function modules to complete all or part of the functions described above.

[0141] 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 coupling or direct coupling or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in electrical, mechanical or other forms.

[0142] The units described as separate components may or may not be physically separated. The components displayed as units may be one physical unit or multiple physical units, that is, they can be located in one place, or they 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.

[0143] In addition, in each embodiment of this application, the functional units 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 units can be implemented in the form of hardware or in the form of software functional units.

[0144] Any content of each embodiment of this application, as well as any content of the same embodiment, can be freely combined. Any combination of the above content is within the scope of this application.

[0145] When the 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 this technical solution, can be embodied in the form of a software product. This 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 various embodiments of the present application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks, or optical discs that can store program codes.

[0146] The embodiments of the present application have been described above in conjunction with the accompanying drawings. However, the present application is not limited to the above specific implementation manners. The above specific implementation manners are merely illustrative and not restrictive. Those of ordinary skill in the art, under the inspiration of the present application and without departing from the purpose of the present application and the scope protected by the claims, can also make many forms, all of which fall within the protection scope of the present application.

[0147] The steps of the methods or algorithms described in connection with the disclosed content of the embodiments of the present application can be implemented in a hardware manner or by a processor executing software instructions. The software instructions can be composed of corresponding software modules. The software modules can be stored in a random access memory (RAM), flash memory, read-only memory (ROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, mobile hard disks, compact disc read-only memories (CD-ROMs), or any other form of storage medium well-known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC.

[0148] Those skilled in the art should be able to realize that in one or more of the above examples, the functions described in the embodiments of the present application can be implemented by hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. The computer-readable medium includes computer storage media and communication media, where the communication media includes any medium that facilitates the transfer of a computer program from one place to another. The storage media can be any available medium that can be accessed by a general-purpose or special-purpose computer.

[0149] The embodiments of the present application have been described above in conjunction with the accompanying drawings. However, the present application is not limited to the above specific embodiments. The above specific embodiments are merely illustrative and not restrictive. Under the inspiration of the present application, those of ordinary skill in the art can also make many forms without departing from the purpose of the present application and the scope protected by the claims, and all of them fall within the protection scope of the present application.

Claims

1. A task processing method, applied to an electronic device, characterized in that, The method includes: responding to a function trigger operation on a camera application to determine a task queue matching a target camera function; determining a target thread pool matching the task queue based on a preset binding relationship; and executing tasks in the task queue by using threads in the target thread pool; wherein, the responding to a function trigger operation on a camera application to determine a task queue matching a target camera function includes: responding to the function trigger operation to determine a perception algorithm for implementing the target camera function; and decomposing the perception algorithm into at least one task to obtain the task queue composed of the at least one task; the perception algorithm has a preset algorithm priority, and the binding relationship between the task queue and the target thread pool is determined according to the algorithm priority and the thread priority; the thread priority in the target thread pool is adjustable, and the method further includes: during the running of the camera application, obtaining performance monitoring data associated with the camera application; adjusting the thread priority in the target thread pool and the algorithm priority of the perception algorithm according to the performance monitoring data.

2. The method according to claim 1, wherein The adjusting the thread priority in the target thread pool according to the performance monitoring data includes: when the performance monitoring data indicates that there are dropped frames in the camera application, adjusting the thread priority in the target thread pool according to the function running characteristics of the target camera function, wherein, the function running characteristics include at least one of the following information of the target camera function: function type, function running platform, whether the function is perceivable, and function application frequency.

3. The method according to claim 2, characterized in that, The adjusting the thread priority in the target thread pool according to the function running characteristics of the target camera function includes: when the function type indicates that the target camera function is a preset important function, raising the thread priority in the target thread pool; and when the function type indicates that the target camera function is a preset non-important function, lowering the thread priority in the target thread pool.

4. The method according to claim 2, wherein The adjusting the thread priority in the target thread pool according to the function running characteristics of the target camera function includes: when the function running platform indicates that the target camera function runs in the foreground, raising the thread priority in the target thread pool; and when the function running platform indicates that the target camera function runs in the background, lowering the thread priority in the target thread pool.

5. The method according to claim 2, wherein The adjusting the thread priority in the target thread pool according to the function running characteristics of the target camera function includes: when the function running characteristics indicate that the target camera function is a perceivable function, raising the thread priority in the target thread pool; and when the function running characteristics indicate that the target camera function is a non-perceivable function, lowering the thread priority in the target thread pool.

6. The method according to claim 2, wherein Adjusting the thread priority in the target thread pool according to the function operation characteristics of the target camera function includes: When the function operation characteristics indicate that the application frequency of the target camera function is higher than a first preset threshold, increasing the thread priority in the target thread pool; and When the function operation characteristics indicate that the application frequency of the target camera function is lower than a second preset threshold, decreasing the thread priority in the target thread pool, wherein the first preset threshold is greater than or equal to the second preset threshold.

7. The method according to claim 1, characterized in that, The method further includes: Scheduling the CPU resources matching the target thread pool according to the performance monitoring data, wherein the CPU resources include at least one of the following parameters: CPU frequency point, the CPU core on which the thread runs, and whether to allow the execution of system actions.

8. The method according to claim 1, wherein The method further includes: During the operation of the camera application, obtaining the real-time load data of the operating system of the electronic device; and Adjusting the thread priority in the target thread pool and / or scheduling the CPU resources matching the target thread pool according to the real-time load data, wherein the real-time load data includes at least one of the following parameters: The number of currently created threads, the processor idle ratio, the processor memory occupancy rate, and the CPU program occupancy ratio.

9. The method according to claim 1, wherein The method further includes: Adjusting the number of threads in the target thread pool according to the number of tasks in the task queue.

10. The method according to claim 9, characterized in that, The adjusting the number of threads in the target thread pool according to the number of tasks in the task queue includes: When the number of tasks reaches at least one target number for creating threads, creating new threads in the target thread pool, wherein the target number is determined according to the number of core threads in the target thread pool, the preset maximum number of threads, and the length of the task queue.

11. The method according to claim 1, wherein The method further includes: When there are idle threads in the target thread pool whose idle duration is greater than a preset duration threshold, destroying the idle threads.

12. The method according to claim 1, characterized in that, The method further includes: Monitoring the running duration of each thread in the target thread pool for executing the current task; and When the running duration indicates that there is a thread running overtime, creating new threads in the target thread pool.

13. The method according to claim 1, wherein The binding relationship can also be determined according to the number of threads in the thread pool and the length of the task queue.

14. An electronic device, characterized in that, including: One or more processors, a memory, and one or more computer programs, wherein the one or more computer programs are stored on the memory, and when the computer programs are executed by the one or more processors, the electronic device is caused to perform the following steps: In response to a function trigger operation for a camera application, determining a task queue matching a target camera function; Based on a preset binding relationship, determining a target thread pool matching the task queue; and Using the threads in the target thread pool to execute the tasks in the task queue; wherein the determining a task queue matching a target camera function in response to a function trigger operation for a camera application includes: In response to the function trigger operation, determine a perception algorithm for implementing the target camera function; and Decompose the perception algorithm into at least one task to obtain the task queue composed of the at least one task; The perception algorithm has a preset algorithm priority, and the binding relationship between the task queue and the target thread pool is determined according to the algorithm priority and the thread priority; The adjustable thread priority in the target thread pool further includes: During the running of the camera application, obtain performance monitoring data associated with the camera application; According to the performance monitoring data, adjust the thread priority in the target thread pool and the algorithm priority of the perception algorithm.

15. A computer-readable storage medium, characterized in that, It includes a computer program, which when running on an electronic device, causes the electronic device to execute the task processing method according to any one of claims 1 to 13.

Citation Information

Patent Citations

  • Task processing method and device

    CN112905326A

  • Thread management method and device

    CN113535251A