Resource scheduling method and device and electronic equipment

Through thread wake-up relationship identification and dynamic update of the key thread list, the problem of insufficient supply of key thread resources in the operating system is solved, and better resource scheduling and system fluency are achieved.

CN119493637APending Publication Date: 2025-02-21HUAWEI TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202311023357.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-14
Publication Date
2025-02-21

AI Technical Summary

Technical Problem

In the operating system, the operation of the application depends on multiple related threads. Insufficient resource supply of key threads will lead to business lag, affect user experience, and it is difficult to meet the high resource supply of all threads at the same time.

Method used

Through thread wake-up relationship, the key thread is determined from the threads related to running tasks. The identification process does not rely on the subjective judgment of the application developer, and dynamically updates the list of key threads to achieve better scheduling of resources.

Benefits of technology

Accurately identify key threads related to running tasks, give priority to ensuring their resource supply, improve the real-time resource scheduling and system fluency, and improve user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119493637A_ABST
    Figure CN119493637A_ABST
Patent Text Reader

Abstract

The invention provides a resource scheduling method and device and electronic device.The method comprises the steps that when a first thread of an application is detected, in the ith period of the first thread, a key thread list corresponding to the ith period is obtained according to a thread wakeup relation, the key thread list comprises one or more key threads related to the first thread, and i is a natural number and is equal to 1, 2, 3, 4,...; and resource scheduling is carried out based on the key thread list corresponding to the ith period. According to the method, the device and the electronic equipment, the key thread related to the running task is determined from the threads related to the running task through the thread wakeup relation in the system, the recognition process of the key thread does not depend on subjective judgment of an application developer, the key thread related to the running task can be accurately recognized, and the recognition efficiency of the key thread is improved. And thus, resource supply can be preferentially guaranteed for the determined key thread, so that better scheduling of resources is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to the field of resource scheduling, and more specifically, to a method, device, and electronic device for resource scheduling. Background Art

[0002] In the operating system, the operation of applications depends on a large number of related threads. Taking the frame drawing scenario as an example, the execution process of the frame drawing service depends on multiple threads related to the frame drawing service. Among these threads, there are some key threads that directly affect the operation of the frame drawing service. When the resources of these key threads are insufficient, it will have a great impact on the operation of the service (for example, causing application freezes, etc.), thereby affecting the user experience.

[0003] Since system resources are limited, it is difficult to ensure that all threads are supplied with high resources at the same time. Therefore, how to identify which are the key threads has become a problem that needs to be solved urgently. Summary of the invention

[0004] The present application provides a method, device and electronic device for resource scheduling. Through this method, device or electronic device, a key thread related to a running task is determined from threads related to the running task in the system through thread wake-up relationships. The identification process of the key thread does not rely on the subjective judgment of the application developer, and can accurately identify the key thread related to the running task, and then can give priority to guaranteeing resource supply to the determined key thread, so as to achieve better resource scheduling.

[0005] In a first aspect, a method for resource scheduling is provided, the method comprising: when a first thread of an application is detected, in an i-th cycle of the first thread, according to a thread wake-up relationship, obtaining a key thread list corresponding to the i-th cycle, the key thread list including one or more key threads related to the first thread, wherein i is a natural number, i=1, 2, 3, 4, ...; performing resource scheduling based on the key thread list corresponding to the i-th cycle.

[0006] The critical thread related to the first thread may be understood as a thread having a critical impact on the running of the first thread.

[0007] It should be understood that the i-th cycle of the first thread refers to the i-th cycle of the first thread.

[0008] Among them, the first thread has multiple operating cycles, the i-th cycle of the first thread may refer to the i-th operating cycle of the first thread, or may refer to a specific number of operating cycles of the first thread (for example: every 3 operating cycles is 1 cycle of the first thread), and the time length of the operating cycle may be determined by the system.

[0009] The thread wake-up relationship has a corresponding relationship with the cycle of the first thread, and the thread wake-up relationship refers to the association relationship between the first thread and other threads. In the above description, the thread wake-up relationship refers to the thread wake-up relationship corresponding to the i-th cycle of the first thread.

[0010] In an embodiment of the present application, in the system, a critical thread related to a running task is determined from threads related to the running task through thread wake-up relationships. The identification process of the critical thread does not rely on the subjective judgment of the application developer, and can accurately identify the critical thread related to the running task, and then can prioritize resource supply for the determined critical thread to achieve better resource scheduling.

[0011] In combination with the first aspect, in a possible implementation, the method also includes: in the i+1th cycle of the first thread, updating the critical thread list corresponding to the i-th cycle to obtain the critical thread list corresponding to the i+1th cycle; and performing resource scheduling based on the critical thread list corresponding to the i+1th cycle.

[0012] In an embodiment of the present application, the key thread list is updated in each cycle of the first thread. By timely updating the key thread list, resource scheduling is made more real-time, thereby further improving the system's fluidity.

[0013] In combination with the first aspect, in a possible implementation method, in the i+1th cycle of the first thread, the critical thread list corresponding to the i+1th cycle is updated to obtain the critical thread list corresponding to the i+1th cycle, including: in the i+1th cycle of the first thread, according to the thread wake-up relationship, obtaining one or more second threads corresponding to the i+1th cycle; according to the one or more second threads corresponding to the i+1th cycle, updating the critical thread list corresponding to the i+1th cycle to obtain the critical thread list corresponding to the i+1th cycle.

[0014] In the above description, the thread wake-up relationship refers to the thread wake-up relationship corresponding to the (i+1)th cycle of the first thread, and the thread wake-up relationships corresponding to different cycles of the first thread may be different or the same.

[0015] In an embodiment of the present application, in each cycle of the first thread, one or more key threads corresponding to the cycle are determined based on the thread wake-up relationship corresponding to the cycle. This enables timely updating of the key thread list, making resource scheduling more real-time, thereby further improving the system's fluidity.

[0016] In combination with the first aspect, in a possible implementation, in the i-th cycle of the first thread, according to the thread wake-up relationship, a list of critical threads corresponding to the i-th cycle is obtained, including: in the i-th cycle of the first thread, according to the thread wake-up relationship, determining one or more second threads corresponding to the i-th cycle, wherein the second thread is a thread related to the first thread; determining the weight of each of the one or more second threads corresponding to the i-th cycle; and determining the list of critical threads corresponding to the i-th cycle from the one or more second threads corresponding to the i-th cycle according to the weight of each of the one or more second threads corresponding to the i-th cycle.

[0017] In an embodiment of the present application, weights are assigned to one or more threads related to the first thread, and a list of key threads is further determined based on the weights of these threads. The key thread identification process does not rely on the subjective judgment of the application developer, and can accurately identify the key threads related to the running tasks, and then prioritize resource supply for the determined key threads to achieve better resource scheduling.

[0018] In combination with the first aspect, in one possible implementation, before determining the weight of each second thread in one or more second threads corresponding to the i-th cycle, the method also includes: excluding first type threads in one or more second threads corresponding to the i-th cycle, the first type threads including high priority threads and / or reusable threads.

[0019] In an embodiment of the present application, before determining the critical thread list, threads that do not require performance guarantee can be excluded from other threads related to the first thread, so that the critical threads in the final critical thread list are all threads that actually have an impact on the running performance of the frame drawing thread and require performance guarantee, thereby avoiding misidentification of critical threads and unnecessary resource supply.

[0020] In combination with the first aspect, in a possible implementation method, determining the weight of each second thread in the one or more second threads corresponding to the i-th cycle includes: adding the one or more second threads corresponding to the i-th cycle to a candidate thread list to obtain the candidate thread list corresponding to the i-th cycle; increasing the weight values ​​of the one or more second threads corresponding to the i-th cycle by a first weight; and reducing the weight values ​​of all candidate threads in the candidate thread list corresponding to the i-th cycle by a second weight.

[0021] In one implementation, the above-mentioned weight is a weight value, and the weight values ​​of one or more second threads corresponding to the i-th cycle are respectively increased by a; the weight values ​​of all candidate threads in the candidate thread list corresponding to the i-th cycle are respectively reduced by b, where a is greater than 0 and b is greater than 0.

[0022] In the embodiment of the present application, weights are assigned to related threads, and the weights of related threads are adaptively adjusted when running to each frame of the first thread, providing a basis for dynamically updating the key thread list according to the changes in its weight.

[0023] In combination with the first aspect, in a possible implementation method, determining the critical thread list corresponding to the i-th cycle includes: determining the critical thread list corresponding to the i-th cycle by adding candidate threads whose weights are greater than a first weight threshold in the candidate thread list corresponding to the i-th cycle to the critical thread list.

[0024] In one implementation, the critical thread list corresponding to the i-th cycle is determined by adding candidate threads with weight values ​​greater than c in the candidate thread list corresponding to the i-th cycle to the critical thread list, where c is greater than 0.

[0025] In an embodiment of the present application, weights are assigned to relevant threads, and the weights of relevant threads are adaptively adjusted when running to each cycle of the first thread, and then the key thread list is dynamically updated according to the changes in their weights, so that the recognition results of the key threads are adapted to the changes in the running state of the first thread, thereby further improving the accuracy of key thread identification.

[0026] In combination with the first aspect, in a possible implementation method, according to one or more second threads corresponding to the i+1th cycle, the critical thread list corresponding to the i+1th cycle is updated to obtain the critical thread list corresponding to the i+1th cycle, including: according to the one or more second threads corresponding to the i+1th cycle, the candidate thread list corresponding to the i+1th cycle is updated to obtain the candidate thread list corresponding to the i+1th cycle, and the candidate thread list corresponding to the i+1th cycle includes the one or more second threads corresponding to the i+1th cycle; the weights of the one or more second threads corresponding to the i+1th cycle are increased by a first weight respectively; the weights of all candidate threads in the candidate thread list corresponding to the i+1th cycle are reduced by a second weight respectively; according to the weight of each candidate thread in the candidate thread list corresponding to the i+1th cycle, the critical thread list corresponding to the i+1th cycle is updated to obtain the critical thread list corresponding to the i+1th cycle.

[0027] In one implementation, the weight values ​​of one or more second threads corresponding to the i+1th cycle are respectively increased by a; the weight values ​​of all candidate threads in the candidate thread list corresponding to the i+1th cycle are respectively reduced by b; according to the weight value of each candidate thread in the candidate thread list corresponding to the i+1th cycle, the key thread list corresponding to the i-th cycle is updated to obtain the key thread list corresponding to the i+1th cycle, wherein a is greater than 0 and b is greater than 0.

[0028] In an embodiment of the present application, weights are assigned to relevant threads, and the weights of relevant threads are adaptively adjusted when running to each cycle of the first thread, thereby providing a basis for dynamically updating the key thread list according to the changes in their weights, so that the recognition results of the key threads are adapted to the changes in the running state of the first thread, thereby further improving the accuracy of key thread recognition.

[0029] In combination with the first aspect, in a possible implementation, before updating the candidate thread list corresponding to the i-th cycle according to one or more second threads corresponding to the i+1-th cycle, the method also includes: excluding first type threads from one or more second threads corresponding to the i+1-th cycle, the first type threads including high priority threads and / or reusable threads.

[0030] In an embodiment of the present application, in each cycle of the first thread, before determining the critical thread list, threads that do not require performance guarantee in other threads related to the first thread can be excluded, so that the critical threads in the critical thread list finally obtained are all threads that actually have an impact on the running performance of the frame drawing thread and require performance guarantee, thereby avoiding misidentification of critical threads and unnecessary resource supply.

[0031] In combination with the first aspect, in a possible implementation method, the key thread list corresponding to the i-th cycle is updated according to the weight of each candidate thread in the candidate thread list corresponding to the i+1th cycle, including: adding threads in the candidate thread list corresponding to the i+1th cycle whose weights are greater than a first weight threshold to the key thread list corresponding to the i-th cycle; and removing threads in the candidate thread list corresponding to the i+1th cycle whose weights are less than a second weight threshold from the key thread list corresponding to the i-th cycle, wherein the first weight threshold is greater than or equal to the second weight threshold.

[0032] In one implementation, threads with weight values ​​greater than c in the candidate thread list corresponding to the i+1th cycle are added to the critical thread list corresponding to the i-th cycle; threads with weight values ​​less than d in the candidate thread list corresponding to the i+1th cycle are removed from the critical thread list corresponding to the i-th cycle, where c≥d>0.

[0033] In an embodiment of the present application, weights are assigned to relevant threads, and the weights of relevant threads are adaptively adjusted when running to each cycle of the first thread, and then the key thread list is dynamically updated according to the changes in their weights, so that the recognition results of the key threads are adapted to the changes in the running state of the first thread, thereby further improving the accuracy of key thread identification.

[0034] In combination with the first aspect, in a possible implementation method, resource scheduling is performed based on the critical thread list corresponding to the i-th cycle, including: increasing the resource supply to the threads in the critical thread list corresponding to the i-th cycle, and reducing the resource supply to the threads outside the critical thread list corresponding to the i-th cycle; or resource scheduling is performed based on the critical thread list corresponding to the i+1th cycle, including: increasing the resource supply to the threads in the critical thread list corresponding to the i+1th cycle, and reducing the resource supply to the threads outside the critical thread list corresponding to the i+1th cycle.

[0035] In an embodiment of the present application, after determining the critical thread list of the first thread, targeted resource supply is performed on the threads in the critical thread list, which can improve the rationality of resource allocation and the timeliness and effectiveness of resource supply, thereby ensuring the operating efficiency of the first thread.

[0036] In combination with the first aspect, in a possible implementation manner, the method further includes: supplying resources to the threads in the critical thread list in different levels.

[0037] In an embodiment of the present application, the key threads in the key thread list are graded according to their weights, and different weight intervals correspond to different resource scheduling levels, thereby realizing graded resource supply control for the key threads, which can make the resource supply more closely matched with the actual needs of the threads and make the resource scheduling more reasonable, thereby improving the running performance of the first thread and avoiding the waste of system resources to a certain extent.

[0038] In combination with the first aspect, in a possible implementation, when i is less than or equal to a first cycle threshold, the first weight is equal to a1; when i is greater than the first cycle threshold, the first weight is equal to a2, wherein a1>a2>0.

[0039] In an embodiment of the present application, by increasing the weights of candidate threads identified in the first few cycles of the first thread, these candidate threads can reach the recognition threshold of key threads more quickly, thereby enabling the system to identify key threads more quickly and improving the timeliness of resource scheduling.

[0040] In combination with the first aspect, in a possible implementation manner, the first thread is a frame drawing thread.

[0041] In one implementation, the duration of one cycle of the frame drawing thread may be the duration corresponding to the frame drawing thread drawing one frame of image.

[0042] Optionally, the first thread is a frame drawing thread of a third-party application.

[0043] In the embodiment of the present application, applying the solution of the present application to a frame drawing scenario (such as a frame drawing scenario of a third-party application) can improve the running performance of the frame drawing thread, thereby improving the fluency of the system drawing process.

[0044] In a second aspect, a device for resource scheduling is provided, which includes: an acquisition module, which is used to, when a first thread of an application is detected, obtain a key thread list corresponding to the i-th cycle of the first thread according to the thread wake-up relationship, wherein the key thread list includes one or more key threads related to the first thread, wherein i is a natural number, i=1, 2, 3, 4, ...; a resource scheduling module, which is used to perform resource scheduling based on the key thread list corresponding to the i-th cycle.

[0045] The critical thread related to the first thread may be understood as a thread having a critical impact on the running of the first thread.

[0046] Among them, the first thread has multiple operating cycles, the i-th cycle of the first thread may refer to the i-th operating cycle of the first thread, or may refer to a specific number of operating cycles of the first thread (for example: every 3 operating cycles is 1 cycle of the first thread), and the time length of the operating cycle may be determined by the system.

[0047] The thread wake-up relationship has a corresponding relationship with the cycle of the first thread, and the thread wake-up relationship refers to the association relationship between the first thread and other threads. In the above description, the thread wake-up relationship refers to the thread wake-up relationship corresponding to the i-th cycle of the first thread.

[0048] In an embodiment of the present application, in the system, a critical thread related to a running task is determined from threads related to the running task through thread wake-up relationships. The identification process of the critical thread does not rely on the subjective judgment of the application developer, and can accurately identify the critical thread related to the running task, and then can prioritize resource supply for the determined critical thread to achieve better resource scheduling.

[0049] In combination with the second aspect, in a possible implementation method, the device also includes: an update module, which is used to update the critical thread list corresponding to the i+1th cycle of the first thread in the i+1th cycle to obtain the critical thread list corresponding to the i+1th cycle; the resource scheduling module is also used to: perform resource scheduling based on the critical thread list corresponding to the i+1th cycle.

[0050] In an embodiment of the present application, the key thread list is updated in each cycle of the first thread. By timely updating the key thread list, resource scheduling is made more real-time, thereby further improving the system's fluidity.

[0051] In combination with the second aspect, in a possible implementation method, the update module is specifically used to: in the i+1th cycle of the first thread, according to the thread wake-up relationship, obtain one or more second threads corresponding to the i+1th cycle; according to the one or more second threads corresponding to the i+1th cycle, update the critical thread list corresponding to the i+1th cycle to obtain the critical thread list corresponding to the i+1th cycle.

[0052] In the above description, the thread wake-up relationship refers to the thread wake-up relationship corresponding to the (i+1)th cycle of the first thread, and the thread wake-up relationships corresponding to different cycles of the first thread may be different or the same.

[0053] In an embodiment of the present application, in each cycle of the first thread, one or more key threads corresponding to the cycle are determined based on the thread wake-up relationship corresponding to the cycle. This enables timely updating of the key thread list, making resource scheduling more real-time, thereby further improving the system's fluidity.

[0054] In combination with the second aspect, in a possible implementation method, the acquisition module is specifically used to: in the i-th cycle of the first thread, determine one or more second threads corresponding to the i-th cycle based on the thread wake-up relationship, wherein the second thread is a thread related to the first thread; determine the weight of each of the one or more second threads corresponding to the i-th cycle; and determine a list of critical threads corresponding to the i-th cycle from the one or more second threads corresponding to the i-th cycle based on the weight of each of the one or more second threads corresponding to the i-th cycle.

[0055] In an embodiment of the present application, weights are assigned to one or more threads related to the first thread, and a list of key threads is further determined based on the weights of these threads. The key thread identification process does not rely on the subjective judgment of the application developer, and can accurately identify the key threads related to the running tasks, and then prioritize resource supply for the determined key threads to achieve better resource scheduling.

[0056] In combination with the second aspect, in a possible implementation, the device also includes: a preprocessing module, used to exclude first type threads from one or more second threads corresponding to the i-th cycle, and the first type threads include high priority threads and / or reusable threads.

[0057] In an embodiment of the present application, before determining the critical thread list, threads that do not require performance guarantee can be excluded from other threads related to the first thread, so that the critical threads in the final critical thread list are all threads that actually have an impact on the running performance of the frame drawing thread and require performance guarantee, thereby avoiding misidentification of critical threads and unnecessary resource supply.

[0058] In combination with the second aspect, in a possible implementation method, the acquisition module is also specifically used to: add one or more second threads corresponding to the i-th period to the candidate thread list to obtain the candidate thread list corresponding to the i-th period; increase the weight values ​​of one or more second threads corresponding to the i-th period by a first weight; and reduce the weight values ​​of all candidate threads in the candidate thread list corresponding to the i-th period by a second weight.

[0059] In one implementation, the above-mentioned weight is a weight value, and the weight values ​​of one or more second threads corresponding to the i-th cycle are respectively increased by a; the weight values ​​of all candidate threads in the candidate thread list corresponding to the i-th cycle are respectively reduced by b, where a is greater than 0 and b is greater than 0.

[0060] In the embodiment of the present application, weights are assigned to related threads, and the weights of related threads are adaptively adjusted when running to each frame of the first thread, providing a basis for dynamically updating the key thread list according to the changes in its weight.

[0061] In combination with the second aspect, in a possible implementation, the acquisition module is further specifically used to: determine the critical thread list corresponding to the i-th cycle by adding candidate threads whose weights in the candidate thread list corresponding to the i-th cycle are greater than a first weight threshold to the critical thread list.

[0062] In one implementation, the critical thread list corresponding to the i-th cycle is determined by adding candidate threads with weight values ​​greater than c in the candidate thread list corresponding to the i-th cycle to the critical thread list, where c is greater than 0.

[0063] In an embodiment of the present application, weights are assigned to relevant threads, and the weights of relevant threads are adaptively adjusted when running to each cycle of the first thread, and then the key thread list is dynamically updated according to the changes in their weights, so that the recognition results of the key threads are adapted to the changes in the running state of the first thread, thereby further improving the accuracy of key thread identification.

[0064] In combination with the second aspect, in a possible implementation method, the update module is further specifically used to: update the candidate thread list corresponding to the i+1 cycle according to the one or more second threads corresponding to the i+1 cycle, to obtain the candidate thread list corresponding to the i+1 cycle, the candidate thread list corresponding to the i+1 cycle including the one or more second threads corresponding to the i+1 cycle; increase the weight values ​​of the one or more second threads corresponding to the i+1 cycle by the first weight respectively; reduce the weight values ​​of all candidate threads in the candidate thread list corresponding to the i+1 cycle by the second weight respectively; update the key thread list corresponding to the i+1 cycle according to the weight of each candidate thread in the candidate thread list corresponding to the i+1 cycle, to obtain the key thread list corresponding to the i+1 cycle.

[0065] In one implementation, the weight values ​​of one or more second threads corresponding to the i+1th cycle are respectively increased by a; the weight values ​​of all candidate threads in the candidate thread list corresponding to the i+1th cycle are respectively reduced by b; according to the weight value of each candidate thread in the candidate thread list corresponding to the i+1th cycle, the key thread list corresponding to the i-th cycle is updated to obtain the key thread list corresponding to the i+1th cycle, wherein a is greater than 0 and b is greater than 0.

[0066] In an embodiment of the present application, weights are assigned to relevant threads, and the weights of relevant threads are adaptively adjusted when running to each cycle of the first thread, thereby providing a basis for dynamically updating the key thread list according to the changes in their weights, so that the recognition results of the key threads are adapted to the changes in the running state of the first thread, thereby further improving the accuracy of key thread recognition.

[0067] In combination with the second aspect, in a possible implementation, the preprocessing module is further used to: exclude first type threads from one or more second threads corresponding to the (i+1)th cycle, where the first type threads include high priority threads and / or reusable threads.

[0068] In an embodiment of the present application, in each cycle of the first thread, before determining the critical thread list, threads that do not require performance guarantee in other threads related to the first thread can be excluded, so that the critical threads in the critical thread list finally obtained are all threads that actually have an impact on the running performance of the frame drawing thread and require performance guarantee, thereby avoiding misidentification of critical threads and unnecessary resource supply.

[0069] In combination with the second aspect, in a possible implementation method, the update module is also specifically used to: add threads in the candidate thread list corresponding to the i+1th cycle whose weight values ​​are greater than a first weight threshold to the key thread list corresponding to the i-th cycle; remove threads in the candidate thread list corresponding to the i+1th cycle whose weight values ​​are less than a second weight threshold from the key thread list corresponding to the i-th cycle, wherein the first weight threshold is greater than or equal to the second weight threshold.

[0070] In one implementation, threads with weight values ​​greater than c in the candidate thread list corresponding to the i+1th cycle are added to the critical thread list corresponding to the i-th cycle; threads with weight values ​​less than d in the candidate thread list corresponding to the i+1th cycle are removed from the critical thread list corresponding to the i-th cycle, where c≥d>0.

[0071] In an embodiment of the present application, weights are assigned to relevant threads, and the weights of relevant threads are adaptively adjusted when running to each cycle of the first thread, and then the key thread list is dynamically updated according to the changes in their weights, so that the recognition results of the key threads are adapted to the changes in the running state of the first thread, thereby further improving the accuracy of key thread identification.

[0072] In combination with the second aspect, in one possible implementation method, the resource scheduling module is specifically used to: increase the resource supply to the threads in the critical thread list corresponding to the i-th cycle, and reduce the resource supply to the threads outside the critical thread list corresponding to the i-th cycle; or perform resource scheduling based on the critical thread list corresponding to the i+1th cycle, including: increase the resource supply to the threads in the critical thread list corresponding to the i+1th cycle, and reduce the resource supply to the threads outside the critical thread list corresponding to the i+1th cycle.

[0073] In an embodiment of the present application, after determining the critical thread list of the first thread, targeted resource supply is performed on the threads in the critical thread list, which can improve the rationality of resource allocation and the timeliness and effectiveness of resource supply, thereby ensuring the operating efficiency of the first thread.

[0074] In conjunction with the second aspect, in a possible implementation, the resource scheduling module is further specifically configured to: supply resources to the threads in the critical thread list in different levels.

[0075] In an embodiment of the present application, the key threads in the key thread list are graded according to their weights, and different weight intervals correspond to different resource scheduling levels, thereby realizing graded resource supply control for the key threads, which can make the resource supply more closely matched with the actual needs of the threads and make the resource scheduling more reasonable, thereby improving the running performance of the first thread and avoiding the waste of system resources to a certain extent.

[0076] In combination with the second aspect, in a possible implementation, when i is less than or equal to a first cycle threshold, the first weight is equal to a1; when i is greater than the first cycle threshold, the first weight is equal to a2, wherein a1>a2>0.

[0077] In an embodiment of the present application, by increasing the weights of candidate threads identified in the first few cycles of the first thread, these candidate threads can reach the recognition threshold of key threads more quickly, thereby enabling the system to identify key threads more quickly and improving the timeliness of resource scheduling.

[0078] In conjunction with the second aspect, in a possible implementation manner, the first thread is a frame drawing thread.

[0079] In one implementation, the duration of one cycle of the frame drawing thread may be the duration corresponding to the frame drawing thread drawing one frame of image.

[0080] Optionally, the first thread is a frame drawing thread of a third-party application.

[0081] In the embodiment of the present application, applying the solution of the present application to a frame drawing scenario (such as a frame drawing scenario of a third-party application) can improve the running performance of the frame drawing thread, thereby improving the fluency of the system drawing process.

[0082] In a third aspect, an electronic device is provided, comprising a memory and a processor, wherein the memory is used to store computer program code, and the processor is used to execute the computer program code stored in the memory to implement the method in the above-mentioned first aspect or any possible implementation of the first aspect, or to implement the above-mentioned second aspect or any possible implementation of the second aspect.

[0083] In a fourth aspect, a computer-readable storage medium is provided, which stores a computer program or instruction. When the computer program or instruction is executed, it implements the method in the first aspect or any possible implementation of the first aspect, or implements the method in the second aspect or any possible implementation of the second aspect.

[0084] In a fifth aspect, a chip is provided, in which instructions are stored. When the chip is executed on a device, the chip executes the method in the first aspect or any possible implementation of the first aspect, or executes the method in the second aspect or any possible implementation of the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0085] Figure 1 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application;

[0086] Figure 2It is a software structure block diagram of an electronic device provided in an embodiment of the present application;

[0087] Figure 3 is a schematic flow chart of an existing resource scheduling method;

[0088] Figure 4 This is a schematic diagram of the relationship between threads provided in an embodiment of the present application;

[0089] Figure 5 is a schematic flow chart of a resource scheduling method provided in an embodiment of the present application;

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

[0091] Figure 7 is a schematic flow chart of another resource scheduling method provided in an embodiment of the present application;

[0092] Figure 8 is a schematic flow chart of another resource scheduling method provided in an embodiment of the present application;

[0093] Fig. 9 is a schematic flow chart of another resource scheduling method provided in an embodiment of the present application;

[0094] Fig.10 is a schematic flow chart of another resource scheduling method provided in an embodiment of the present application;

[0095] Fig.11 is a schematic diagram of a key thread identification process provided by an embodiment of the present application;

[0096] Fig.12 It is a functional module diagram of a resource scheduling device provided in an embodiment of the present application;

[0097] Fig.13 It is a system architecture diagram corresponding to a resource scheduling method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0098] The technical solution in the present application will be described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments.

[0099] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "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 mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "plurality" or "multiple" refers to two or more than two.

[0100] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.

[0101] The terms used in the following embodiments are only for the purpose of describing specific embodiments, and are not intended to be used as limitations on the present application. As used in the specification and the appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include expressions such as "one or more", unless there is a clear contrary indication in the context. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" refer to one, two or more. The term "and / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist; for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship.

[0102] References to "one embodiment" or "some embodiments" etc. described in this specification mean that a particular feature, structure or characteristic described in conjunction with the embodiment is included in one or more embodiments of the present application. Thus, the phrases "one embodiment", "some embodiments", "another embodiment", "some other embodiments", etc. appearing in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.

[0103] The method provided in the embodiments of the present application can be applied to electronic devices equipped with an operating system, such as mobile phones, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), etc. The embodiments of the present application do not impose any restrictions on the specific types of electronic devices.

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

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

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

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

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

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

[0110] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 may be 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, so that the processor 110 communicates with the touch sensor 180K through the I2C bus interface, thereby realizing the touch function of the electronic device 100.

[0111] The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to achieve communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 via the I2S interface to achieve the function of answering a call through a Bluetooth headset.

[0112] The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface to realize the function of answering calls via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.

[0113] The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally 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 some embodiments, the audio module 170 can 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.

[0114] The MIPI interface can be used to connect the processor 110 with 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 some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate via the DSI interface to implement the display function of the electronic device 100.

[0115] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 193, the display 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.

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

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

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

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

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

[0121] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0122] 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 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process 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 for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0123] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.

[0124] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0125] 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 technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).

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

[0127] 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 or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.

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

[0129] ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193.

[0130] The camera 193 is used to capture still images or videos. The 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 passes the electrical signal to the ISP to be converted 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 or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.

[0131] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.

[0132] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0133] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.

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

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

[0136] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0137] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.

[0138] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.

[0139] The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be received by placing the receiver 170B close to the human ear.

[0140] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to microphone 170C to input the sound signal into microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In 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, realize directional recording function, etc.

[0141] The earphone interface 170D is used to connect a wired earphone and 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.

[0142] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be set on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 194, the electronic device 100 detects the touch operation intensity according to the pressure sensor 180A. The electronic device 100 can also calculate the touch position according to the detection signal of the pressure sensor 180A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.

[0143] The gyro sensor 180B 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., x, y, and z axes) can be determined by the gyro sensor 180B. The gyro sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyro sensor 180B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyro sensor 180B can also be used for navigation and somatosensory game scenes.

[0144] The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.

[0145] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip leather case. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip cover according to the magnetic sensor 180D. Then, according to the detected opening and closing state of the leather case or the opening and closing state of the flip cover, the flip cover can be automatically unlocked.

[0146] The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in all directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It 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.

[0147] The distance sensor 180F is used to measure the distance. The electronic device 100 can measure the distance by infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focusing.

[0148] The proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The light emitting diode may be an infrared light emitting diode. The electronic device 100 emits infrared light outward through the light emitting diode. The electronic device 100 uses a photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. The electronic device 100 can use the proximity light sensor 180G to detect that the user holds the electronic device 100 close to the ear to talk, so as to automatically turn off the screen to save power. The proximity light sensor 180G can also be used in leather case mode and pocket mode to automatically unlock and lock the screen.

[0149] The ambient light sensor 180L is used to sense the ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touches.

[0150] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to implement fingerprint unlocking, access application locks, fingerprint photography, fingerprint call answering, etc.

[0151] The temperature sensor 180J is used to detect temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 reduces the performance of a processor located near the temperature sensor 180J to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 due to low temperature. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 performs a boost on the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.

[0152] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor can pass 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. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.

[0153] The bone conduction sensor 180M can obtain a vibration signal. In some embodiments, the bone conduction sensor 180M can obtain a vibration signal of a vibrating bone block of the vocal part of the human body. The bone conduction sensor 180M can also contact the human pulse to receive a blood pressure beat signal. In some embodiments, the bone conduction sensor 180M can also be set in an earphone and combined into a bone conduction earphone. The audio module 170 can parse out a voice signal based on the vibration signal of the vibrating bone block of the vocal part obtained by the bone conduction sensor 180M to realize a voice function. The application processor can parse the heart rate information based on the blood pressure beat signal obtained by the bone conduction sensor 180M to realize a heart rate detection function.

[0154] The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. The electronic device 100 may receive key input and generate key signal input related to user settings and function control of the electronic device 100.

[0155] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.

[0156] Indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.

[0157] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195. 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, and the like. 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 communications. In some embodiments, the electronic device 100 uses an embedded SIM (eSIM) card, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.

[0158] It should be understood that the phone card in the embodiments of the present application includes but is not limited to a SIM card, an eSIM card, a universal subscriber identity module (USIM), a universal integrated circuit card (UICC), and the like.

[0159] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.

[0160] Figure 2 1 is a software structure diagram of the electronic device 100 of the embodiment of the present application. The layered architecture divides the software into several layers, 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, the application framework layer, the Android runtime (Android runtime) and the system library, and the kernel layer. The application layer can include a series of application packages.

[0161] like Figure 2 As shown, the application package may include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.

[0162] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0163] like Figure 2 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.

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

[0165] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

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

[0167] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including connecting, hanging up, etc.).

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

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

[0170] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.

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

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

[0173] The system library may include multiple functional modules, such as surface manager, media libraries, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0174] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.

[0175] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0176] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0177] A 2D graphics engine is a drawing engine for 2D drawings.

[0178] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.

[0179] It should be understood that the technical solutions in the embodiments of the present application can be used in Android, IOS, Hongmeng and other systems.

[0180] In the operating system, when an application is running, a large number of threads will be created to handle related services. Taking the frame drawing scenario as an example, during the execution of the frame drawing service, multiple threads related to the frame drawing service will be created. Among these threads related to the frame drawing service, there are some key threads, such as threads responsible for drawing and rendering. The running speed of these threads related to the frame drawing service directly affects the main logic execution of the frame drawing service and the speed of frame drawing. When the resource supply of these threads related to the frame drawing service is insufficient, it may cause the application to respond slowly or even freeze, thereby affecting the user experience.

[0181] Therefore, if the resource supply of the key threads related to the task can be guaranteed, the performance experience of the operating system can be greatly improved. In addition, during the execution of the task, among the multiple threads related to the task, there are also some non-critical threads. These non-critical threads have little impact on the execution of the task and can be delayed. Since the resources of the operating system are limited, it is difficult to make all threads get a high supply at the same time. Therefore, it is possible to reduce the resource supply to these non-critical threads while providing sufficient resources to the key threads.

[0182] Therefore, how to identify which are the critical threads has become a problem that needs to be solved urgently.

[0183] For example, Figure 3 FIG. 3 is a schematic flow chart of an existing resource scheduling method 300. Figure 3 As shown, the method 300 includes:

[0184] S301: The application developer determines the importance of multiple threads related to the current business based on his / her own experience.

[0185] Specifically, the application developer determines which threads are more important in the running process of the current business based on the understanding of the application running status and the operating system, and thus subjectively determines the importance of multiple threads related to the current business.

[0186] S302: Perform resource scheduling according to the importance of multiple threads related to the current business.

[0187] Specifically, resource scheduling of these threads is achieved by adjusting the priorities of multiple threads related to the current business, grouping multiple threads related to the current business, and the like.

[0188] In this method, the identification of key threads depends on the subjective judgment of application developers, which inevitably leads to omissions or misidentifications. In addition, the method requires developers to have high knowledge in the field of operating systems, which makes the developer experience unfriendly. In addition, application developers can only identify key threads within the application. When the application is running in the operating system, the key threads outside the application that the application depends on cannot be identified. In addition, during the operation of the application, the key threads related to the application running tasks may change. Relying on manual identification cannot timely identify the updates of the key threads, which makes the resource scheduling strategy mismatched with actual needs.

[0189] In view of this, the present application provides a method, device and electronic device for resource scheduling. In the method, during the application running process, according to the actual occurrence probability and influence of the thread related to the running task during the running process, the key thread related to the running task is determined from the threads related to the running task. The identification process of the key thread is completed in the system through the identification algorithm, which does not rely on the subjective judgment of the application developer. Through this method, device and electronic device, the key thread related to the running task can be accurately identified, and then the resource supply can be prioritized for the determined key thread to achieve better resource scheduling, thereby improving the running speed and performance of the running task.

[0190] For example, Figure 4 A schematic diagram of the relationship between threads provided in an embodiment of the present application is shown.

[0191] like Figure 4 As shown, the relationship between threads in the system is often tree-like or mesh-like. Not all threads in the tree-like or mesh-like threads have an impact on the running performance of the current task. Figure 4 (a) in FIG. 1 shows multiple threads related to the current task of the application. Among the multiple threads, the thread that has a greater impact on the running performance of the current task is Figure 4 In (a), the solid circle indicates that among the multiple threads, the thread that has no impact or little impact on the running performance of the current task is Figure 4 In (a), the dotted circle is used; through the resource scheduling method provided in the embodiment of the present application, the threads that have no effect or little effect on the running performance of the current task among the multiple threads related to the current task of the application can be filtered out, thereby obtaining the following Figure 4 The key threads shown in (b) are identified, and then the resource scheduling strategy is determined to increase the resource supply to these key threads in a targeted manner.

[0192] For example, Figure 5 FIG. 5 is a schematic flow chart of a resource scheduling method 500 provided in an embodiment of the present application. Figure 5 As shown, the method 500 includes:

[0193] S501: Identify a first thread of an application.

[0194] In some embodiments, the first thread is identified by inserting a stub in a function that needs to be called during the running of the first thread.

[0195] In some other embodiments, the first thread is identified by identifying the identification information of the first thread.

[0196] Among them, stubbing refers to inserting probes into the program on the basis of ensuring the logical integrity of the original program. The probes collect information in the code (the method itself, method parameter values, return values, etc.), and insert code segments at specific locations of the program to collect dynamic context information when the program is running.

[0197] S502: Obtain a key thread list through a thread wakeup relationship, where the key thread list includes one or more key threads related to the first thread.

[0198] The one or more critical threads related to the first thread may be understood as one or more threads having a critical impact on the running of the first thread.

[0199] In one implementation, the running process of the first thread corresponds to multiple cycles (running cycles). In each cycle of the first thread, a list of key threads corresponding to the current cycle is obtained through a thread wake-up relationship; or, in every few cycles of the first thread, a list of key threads corresponding to the current few cycles is obtained through a thread wake-up relationship.

[0200] Herein, step S502 occurs in the system kernel.

[0201] It should be understood that the thread wake-up relationship corresponding to different periods of the first thread may be different, that is, the thread wake-up relationship has a corresponding relationship with the period of the first thread, and the thread wake-up relationship refers to the association relationship between the first thread and other threads. The association relationship between the first thread and other threads can be found in Figure 4 and Figure 4 In the description part, the thread wakeup relationship can be obtained directly from the system.

[0202] The thread wake-up relationship is directly obtained from the system, for example, the thread wake-up relationship can be obtained by calling other functional modules of the operating system (such as the following Fig.12 The interface of the wake-up relationship acquisition module 1230 shown in FIG. 1 is used to obtain the wake-up relationship.

[0203] S503: Targeted resource supply is performed for each thread in the key thread list.

[0204] In some embodiments, resource provisioning to threads in the critical thread list is increased, while resource provisioning to non-critical threads (ie, threads not in the critical thread list) is reduced.

[0205] Optionally, the first thread may be a frame drawing thread, and the duration of one cycle of the first thread may be the duration corresponding to the frame drawing thread drawing one frame of image; in addition, the first thread may also be any other thread, which is not limited in the present application.

[0206] In an embodiment of the present application, in the system, a critical thread related to a running task is determined from threads related to the running task through thread wake-up relationships. The identification process of the critical thread does not rely on the subjective judgment of the application developer, and can accurately identify the critical thread related to the running task, and then can prioritize resource supply for the determined critical thread to achieve better resource scheduling.

[0207] For example, Figure 6 FIG. 6 is a schematic flow chart of another resource scheduling method 600 provided in an embodiment of the present application. Figure 6 As shown, the method 600 includes:

[0208] S601: Identify a first thread of an application.

[0209] Explanation of step S601 Figure 5 The explanation of S501 in the illustrated embodiments is the same and will not be repeated here for the sake of brevity.

[0210] S602: In the i-th cycle of the first thread, obtain a key thread list corresponding to the i-th cycle through the thread wake-up relationship, where the key thread list includes one or more key threads related to the first thread, where an initial value of i is 1, and i is a positive integer greater than or equal to 1.

[0211] Specifically, it can be described as: in the i-th cycle of the first thread, the key thread list corresponding to the i-th cycle is obtained through the thread wake-up relationship corresponding to the i-th cycle, and the key thread list includes one or more key threads related to the first thread.

[0212] Among them, the first thread has multiple operating cycles, the i-th cycle of the first thread may refer to the i-th operating cycle of the first thread, or may refer to a specific number of operating cycles of the first thread (for example: every 3 operating cycles is 1 cycle of the first thread), and the time length of the operating cycle may be determined by the system.

[0213] Regarding the explanation of step S602 Figure 5 The explanation of S502 in the illustrated embodiment is similar and will not be repeated here for the sake of brevity.

[0214] S603: Targeted resource supply is provided to each thread in the key thread list corresponding to the i-th cycle. When the i-th cycle of the first thread ends and the i+1-th cycle begins, let i=i+1 and return to step S602, where i is a natural number, i=1, 2, 3, 4, ...

[0215] In some embodiments, resource supply to threads in the critical thread list corresponding to the i-th cycle is increased, while resource supply to non-critical threads (ie, threads not in the critical thread list corresponding to the i-th cycle) is reduced.

[0216] In an embodiment of the present application, in each cycle of the first thread, one or more key threads corresponding to the cycle are determined based on the thread wake-up relationship corresponding to the cycle. This enables timely updating of the key thread list, making resource scheduling more real-time, thereby further improving the system's fluidity.

[0217] For example, Figure 7 FIG. 7 is a schematic flow chart of another resource scheduling method 700 provided in an embodiment of the present application. Figure 7 As shown, the method 700 includes:

[0218] S701: Identify the first thread of the application.

[0219] Explanation of step S701 Figure 5 The explanation of S501 in the illustrated embodiments is the same and will not be repeated here for the sake of brevity.

[0220] S702: In the i-th cycle of the first thread, obtain one or more second threads corresponding to the i-th cycle through the thread wake-up relationship, where the second thread refers to a thread related to the first thread.

[0221] It should be understood that the i-th cycle of the first thread refers to the i-th cycle of the first thread.

[0222] The one or more key threads related to the first thread may be understood as one or more threads that have an impact on the running of the first thread.

[0223] In one implementation, the running process of the first thread corresponds to multiple cycles (running cycles). In each cycle of the first thread, one or more second threads corresponding to the current cycle are obtained through the thread wake-up relationship; or, in every few cycles of the first thread, one or more second threads corresponding to the current few cycles are obtained through the thread wake-up relationship.

[0224] Herein, step S702 occurs in the system kernel.

[0225] It should be understood that the thread wake-up relationship corresponding to different periods of the first thread may be different, that is, the thread wake-up relationship has a corresponding relationship with the period of the first thread, and the thread wake-up relationship refers to the association relationship between the first thread and other threads. The association relationship between the first thread and other threads can be found in Figure 4 and Figure 4In the description part, the thread wakeup relationship can be obtained directly from the system.

[0226] The thread wake-up relationship is directly obtained from the system, for example, the thread wake-up relationship can be obtained by calling other functional modules of the operating system (such as the following Fig.12 The interface of the wake-up relationship acquisition module 1230 shown in FIG. 1 is used to obtain the wake-up relationship.

[0227] S703: Determine a critical thread list corresponding to the i-th period from the one or more second threads corresponding to the i-th period according to the weights of the one or more second threads corresponding to the i-th period.

[0228] Specifically, the weight of each of the one or more second threads corresponding to the i-th cycle is determined according to the frequency of each of the one or more second threads corresponding to the i-th cycle corresponding to the i-th cycle of the first thread, wherein the i-th cycle of the first thread includes the i-th cycle and i-1 cycles before the i-th cycle of the first thread.

[0229] In an example, the first thread runs to the third cycle, the second thread A is a thread related to the first thread in both the first cycle and the third cycle, and is not a thread related to the first thread in the second cycle, the second thread B is a thread related to the first thread only in the third cycle, and is not a thread related to the first thread in the first cycle and the second cycle, then, the second thread A corresponds to the first cycle and the third cycle, and the frequency of the second thread A corresponding to the three cycles of the first thread is 2 / 3, the second thread B only corresponds to the third cycle, and the frequency of the second thread B corresponding to the three cycles of the first thread is 1 / 3, then in the third cycle of the first thread, the weight of the second thread A is greater than the weight of the second thread B.

[0230] In some embodiments, when the weight of a second thread C among the one or more second threads reaches a first weight threshold, the second thread C is included in the critical thread list.

[0231] Similarly, when the weight of the second thread D in the critical thread list is less than the second weight threshold, the second thread D is removed from the critical thread list.

[0232] It should be understood that step S703 is executed when the first thread runs to each cycle, that is, as the number of cycles of the first thread increases (i.e., the increase of i), the frequency of each second thread in one or more second threads corresponding to the i cycles of the first thread may change, and then its weight will also change, and finally the dynamic update of the key thread list is realized. S704: Targeted resource supply is performed for each thread in the key thread list corresponding to the i-th cycle. When the i-th cycle of the first thread ends and starts to run at the i+1 cycle, set i=i+1 and return to step S702.

[0233] In some embodiments, the resource supply to threads in the critical thread list corresponding to the i-th cycle is increased, while the resource supply to non-critical threads is reduced.

[0234] In an embodiment of the present application, a critical thread related to the running task is determined from threads related to the running task through an identification algorithm (weight algorithm) in the system. The identification process of the critical thread does not rely on the subjective judgment of the application developer, and can accurately identify the critical thread related to the running task, and then can prioritize resource supply for the determined critical thread to achieve better resource scheduling; and, critical threads are identified in each cycle of the running task, and critical threads are determined based on the probability and impact of the threads related to the running task appearing in multiple cycles, which can improve the stability of critical thread identification and achieve timely updating of critical threads.

[0235] For example, taking the first thread as a frame drawing thread, Figure 8 FIG. 8 is a schematic flow chart of another resource scheduling method 800 provided in an embodiment of the present application. Figure 8 As shown, the method 800 includes:

[0236] S801: Identify the frame drawing thread of the application.

[0237] Taking the frame drawing scenario of a third-party application as an example, the frame drawing thread of the application can be identified by inserting a stub in the queuebuffer function.

[0238] Among them, the queuebuffer function is a function used to transfer drawing frame data. The call of the queuebuffer function is a necessary process in the frame drawing process. It should be understood that each frame corresponds to a queuebuffer function. When it is necessary to draw an image, the queuebuffer function is called to obtain and transfer the drawing elements corresponding to the current frame.

[0239] In other words, the queuebuffer function is usually used in third-party application frame drawing scenarios (for example, image rendering scenarios). It is specifically used to obtain the drawing elements corresponding to the current frame by performing drawing logic calculations on the current frame, and pass the drawing elements corresponding to the current frame to the system driver so that the system driver can further perform drawing operations on the current frame.

[0240] Among them, stub insertion refers to inserting probes into the program on the basis of ensuring the integrity of the original program logic, collecting information in the code (method itself, method parameter values, return values, etc.) through the probe, inserting code segments at specific locations of the program, and thus collecting dynamic context information when the program is running. For example, in this embodiment, by inserting stubs in the queuebuffer function, when an event occurs to call the queuebuffer function to obtain the drawing element corresponding to the current frame, the frame drawing thread of the application can be identified.

[0241] Among them, a thread is the smallest unit that the operating system can schedule operations. It is contained in a process and is the actual operation unit in the process. A thread refers to a single sequential control flow in a process. A process can have multiple threads running concurrently, and each thread executes different tasks in parallel. A frame drawing thread refers to a thread used to perform frame drawing operations.

[0242] In one example, the application is located in a first chat interface. When the application receives a first message, the interface changes to a second chat interface. The first chat interface and the second chat interface can be regarded as two frames of the application, and the thread used to draw these two frames in the system is the frame drawing thread.

[0243] S802: In the i-th frame of the frame drawing thread (which can also be described as: when the frame drawing thread is used to draw the i-th frame), obtain one or more second threads corresponding to the i-th frame through the thread wake-up relationship, where the second thread refers to a thread related to the frame drawing thread, wherein i is a positive integer greater than or equal to 1, and the initial value of i is 1.

[0244] The one or more second threads related to the frame drawing thread may be understood as one or more threads that have an impact on the running of the frame drawing thread.

[0245] Specifically, the frame drawing thread corresponds to a plurality of frames. In each frame of the frame drawing thread, one or more second threads related to the frame drawing thread corresponding to the current frame are obtained through the thread wake-up relationship.

[0246] Specifically, in the i-th frame of the frame drawing thread, one or more second threads corresponding to the i-th frame are obtained through the thread wake-up relationship corresponding to the i-th frame.

[0247] The thread wake-up relationship in this step corresponds to the frame drawing thread, which refers to the association relationship between the frame drawing thread and other threads. The association relationship between the frame drawing thread and other threads can be found in Figure 4 and Figure 4 In the description part, the thread wakeup relationship can be obtained directly from the system.

[0248] Optionally, different frames of the frame drawing thread correspond to different thread wake-up relationships, that is, the thread wake-up relationship has a corresponding relationship with the frames of the frame drawing thread.

[0249] The thread wake-up relationship is directly obtained from the system, for example, the thread wake-up relationship can be obtained by calling other functional modules of the operating system (such as the following Fig.12 The interface of the wake-up relationship acquisition module 1230 shown in FIG. 1 is used to obtain the wake-up relationship.

[0250] In this step, one or more second threads related to the running of the frame drawing thread are identified through the thread wake-up relationship, so that other threads that actually affect the running of the frame drawing thread can be accurately queried.

[0251] S803: Determine one or more candidate threads corresponding to the i-th frame from the one or more second threads corresponding to the i-th frame. Specifically, screen the one or more second threads corresponding to the i-th frame, remove threads of the first type from the one or more second threads corresponding to the i-th frame, and then obtain one or more candidate threads corresponding to the i-th frame.

[0252] In some embodiments, a first type of thread refers to a thread that is not related to the performance guarantee of a frame drawing thread. The first type of thread may include a real-time (RT) thread that has a high priority in terms of supply capability, a binder thread that can be reused by other modules in the system, and a kworker thread that can be reused by other modules in the system. In addition, the first type of thread may also include other threads that are not related to the performance guarantee of a frame drawing thread (for example, other threads that can be reused by other modules in the system), which is not limited in the present application.

[0253] The system may directly determine whether the thread is a first type of thread according to the task type.

[0254] Through this step, the key threads in the final key thread list can be threads that actually affect the running performance of the frame drawing thread and require performance guarantee, which can avoid misidentification of key threads and unnecessary resource supply.

[0255] S804: Update the candidate thread list according to one or more candidate threads corresponding to the i-th frame.

[0256] In some embodiments, when i=1, an empty candidate thread list is created, and one or more candidate threads corresponding to the i-th frame are all added to the candidate thread list to obtain an updated candidate thread list (which can also be described as the candidate thread list corresponding to the i-th frame), wherein the updated candidate thread list does not specifically refer to the candidate thread list corresponding to a certain frame, but refers to the candidate thread list obtained by the most recent update.

[0257] In some other embodiments, when i is greater than 1, threads among one or more candidate threads corresponding to the i-th frame that do not exist in the candidate thread list (which can also be described as the candidate thread list corresponding to the i-1-th frame) are added to the candidate thread list (which can also be described as the candidate thread list corresponding to the i-1-th frame) to obtain an updated candidate thread list (which can also be described as the candidate thread list corresponding to the i-th frame).

[0258] S805: Increase the weights of one or more candidate threads corresponding to the i-th frame in the updated candidate thread list by a first weight respectively.

[0259] In one implementation, the weight is represented by a weight value, and this step can be replaced by: adding a to the weight values ​​of one or more candidate threads corresponding to the i-th frame in the updated candidate thread list, where a>0.

[0260] In some embodiments, the value of a can be 2.

[0261] In another implementation, after the weights of one or more candidate threads corresponding to the i-th frame are respectively increased by the first weight, the candidate thread list is updated according to the candidate thread list corresponding to the i-th frame.

[0262] It should be understood that the weights of one or more candidate threads determined from one or more second threads obtained from the current frame (i-th frame) are increased by the first weights respectively.

[0263] The candidate thread list includes one or more candidate threads obtained in the current frame (i-th frame); and also includes one or more candidate threads obtained in all frames before the current frame (i-th frame).

[0264] S806: Reduce the weights of all candidate threads in the updated candidate thread list by a second weight respectively.

[0265] In one implementation, the weight is represented by a weight value, and this step can be replaced by: subtracting b from the weight values ​​of all candidate threads in the updated candidate thread list, where b>0.

[0266] In some embodiments, the value of b may be 1.

[0267] In one example, the present frame (the i-th frame) is the 3rd frame, the candidate thread list corresponding to the 2nd frame includes 10 candidate threads, the third frame corresponds to 5 candidate threads, and 3 of the 5 candidate threads do not exist in the candidate thread list corresponding to the 2nd frame, then the 3 candidate threads are added to the candidate thread list corresponding to the 2nd frame to obtain an updated candidate thread list (i.e., the candidate thread list corresponding to the 3rd frame), and the updated candidate thread list includes 13 candidate threads; wherein, the process of determining the weights of the threads in the updated candidate thread list is: increasing the weight values ​​of the 5 candidate threads corresponding to the third frame in the updated candidate thread list by a first weight (for example, adding a respectively), and reducing the weights of all the candidate threads in the updated candidate thread list by a second weight (for example, subtracting b respectively).

[0268] It should be noted that when thread A in the candidate thread list is added to the critical thread list, thread A still exists in the candidate thread list and participates in the weight change process together with other candidate threads in the candidate thread list; when the weight of thread A in the candidate thread list changes, the weight of thread A in the critical thread list changes synchronously.

[0269] By analogy, when the frame drawing thread draws each frame, the weights of the candidate threads in the candidate thread list may change, so that the weights of threads that appear frequently in multiple frames can be gradually increased, thereby accurately identifying key threads.

[0270] S807: Add threads in the updated candidate thread list whose weights are greater than a first weight threshold to the critical thread list, and remove threads in the critical thread list whose weights are less than a second weight threshold from the critical thread list, wherein the first weight threshold is greater than or equal to the second weight threshold.

[0271] In one implementation, the weight is represented by a weight value, and this step can be replaced by: adding threads with weight values ​​greater than c in the updated candidate thread list to the critical thread list, and removing threads with weight values ​​less than d in the critical thread list from the critical thread list, where c≥d>0.

[0272] In one example, the present frame (i-th frame) is the third frame, the candidate thread list corresponding to the second frame includes 10 candidate threads, the third frame corresponds to 5 candidate threads, and 3 of the 5 candidate threads do not exist in the candidate thread list corresponding to the second frame, then the 3 candidate threads are added to the candidate thread list corresponding to the second frame to obtain an updated candidate thread list (i.e., the candidate thread list corresponding to the third frame), and the updated candidate thread list includes 13 candidate threads; wherein, the process of determining the weights of the threads in the updated candidate thread list is: increasing the weights of the 5 candidate threads corresponding to the third frame in the updated candidate thread list by a first weight (for example, adding a respectively), and reducing the weights of all the candidate threads in the updated candidate thread list by a second weight (for example, subtracting b respectively); and then updating the critical thread list based on the weights of the 13 candidate threads in the updated candidate thread list, and the specific updating process is: including threads in the updated candidate thread list whose weights are greater than a first weight threshold (for example, greater than c) in the critical thread list, and removing threads in the critical thread list whose weights are less than a second weight threshold (for example, less than d) from the critical thread list.

[0273] In some embodiments, the value of c can be 10.

[0274] The value of d is less than or equal to c. For example, the value of d may be 5.

[0275] It should be understood that the "frame" described in the embodiments of the present application is a single image picture that is the smallest unit in the image animation, which is equivalent to each frame of a movie film. A frame is a still picture, and continuous frames form an animation, such as a TV image.

[0276] In one example, the application is located in a first chat interface. When the application receives a first message, the interface changes to a second chat interface, wherein the first chat interface and the second chat interface can be regarded as two frames of the application.

[0277] It should be understood that in the embodiments of the present application, a third-party application refers to an application created by a developer, and the application is not the manufacturer of the device running the application or the owner of the website providing the application. For example, a third-party application can be an application downloaded and installed by a user from an application store or a web page, or an application received and installed by a user from an installation package, etc.; the drawing frame scene of the application refers to the drawing and rendering scene of the display interface corresponding to the application, for example, the drawing and rendering of the chat interface of a chat application, the drawing and rendering of the game interface of a game application, etc.

[0278] It should also be understood that the embodiments of the present application are described using the application frame drawing scenario as an example, but this does not limit the usage scenario of the solution of the present application. The solution of the present application can also be used in the running process of other threads.

[0279] S808: Targeted resource supply is performed for each thread based on the key thread list. When the frame drawing thread finishes the i-th cycle and starts to run in the i+1th cycle, i=i+1 is assigned, and the process returns to step S802.

[0280] Specifically, the resource supply to the threads in the critical thread list is increased, and the resource supply to the non-critical threads is reduced, so that the system resources are tilted toward the critical threads, thereby ensuring the operation of the critical threads, and further ensuring the operation of the frame drawing threads affected by the critical threads.

[0281] It should be understood that after the drawing of the current frame is completed, when the drawing of the next frame begins, step S802 is re-executed, that is, steps S802 to S808 will be executed in each frame in which the frame drawing thread runs, so that a stable key thread call chain can be obtained, and the stability of key thread identification is improved. The weights of candidate threads and key threads are adjusted in each frame, and dynamic adjustment of the weights of candidate threads and key threads can be achieved, so that the key thread list can be updated in time.

[0282] In an embodiment of the present application, a critical thread related to a running task is determined from threads related to the running task through an identification algorithm (weight algorithm) in the system. The identification process of the critical thread does not rely on the subjective judgment of the application developer, and can accurately identify the critical thread related to the running task, thereby enabling priority to guarantee resource supply for the determined critical thread to achieve better resource scheduling; and, critical threads are identified in each frame of the running task, and critical threads are determined based on the probability and influence of threads related to the running task in multiple frames, which can improve the stability of critical thread identification and enable timely updating of critical threads; in addition, by assigning weights to threads and adaptively adjusting the thread weights in each frame, the critical thread list is dynamically updated according to changes in their weights, so that the identification results of the critical threads are adapted to changes in the running status of the frame drawing threads, further improving the accuracy of key thread identification.

[0283] For example, taking the first thread as a frame drawing thread, Fig. 9 FIG. 9 is a schematic flow chart of another resource scheduling method 900 provided in an embodiment of the present application. Fig. 9 As shown, the method 900 includes:

[0284] Steps S901 to S904 and Figure 8Steps S801 to S804 in the illustrated embodiment are the same and will not be described again for brevity.

[0285] S905: Determine whether the value of i is less than m. If so, execute step S905; if not, execute step S906.

[0286] The value of m can be any positive integer from 1 to 10, for example, any value from 3, 5, and 7.

[0287] S906: Add e to the weight values ​​of one or more candidate threads corresponding to the i-th frame in the updated candidate thread list.

[0288] Among them, the value of e is greater than the value of a.

[0289] In some embodiments, the value of e can be 3.

[0290] In another implementation, after adding e to the weight values ​​of one or more candidate threads corresponding to the i-th frame, the candidate thread list is updated according to the candidate thread list corresponding to the i-th frame.

[0291] S907: Add a to the weight values ​​of one or more candidate threads corresponding to the i-th frame in the updated candidate thread list.

[0292] In some embodiments, the value of a can be 2.

[0293] In another implementation, after adding a to the weight values ​​of one or more candidate threads corresponding to the i-th frame, the candidate thread list is updated according to the candidate thread list corresponding to the i-th frame.

[0294] Steps S908 to S910 and Figure 8 Steps S806 to S808 in the illustrated embodiment are the same and will not be described again for brevity.

[0295] In an embodiment of the present application, in a specific scenario (for example, the first few cycles of the first thread, the first identification of a key thread, etc.), the weight value of the candidate threads identified in the cycle corresponding to the scenario can be further improved, so that these candidate threads can reach the identification threshold of the key thread more quickly, thereby enabling the system to identify the key thread more quickly and improve the timeliness of resource scheduling.

[0296] For example, taking the first thread as a frame drawing thread, Fig.10 FIG. 1 is a schematic flow chart of another resource scheduling method 1000 provided in an embodiment of the present application. Fig.10 As shown, the method 1000 includes:

[0297] Steps S1001 to S1007 and Figure 8 Steps S801 to S807 in the illustrated embodiment are the same and will not be described again for brevity.

[0298] S1008: For each thread in the key thread list, resources are supplied to it according to the weight value interval corresponding to its weight value. When the i-th cycle of the frame drawing thread ends and it starts to run in the i+1th cycle, i=i+1 is assigned and the process returns to step S1002.

[0299] In some embodiments, multiple weight value intervals are created according to the numerical values ​​of the weight values, and the multiple weight value intervals correspond one-to-one to multiple resource scheduling levels. The larger the weight value of the weight value interval, the higher the corresponding resource scheduling level. For example: the interval with a weight value of fg corresponds to the first level, the interval with a weight value of hi corresponds to the second level, and the interval with a weight value of jk corresponds to the third level. The resource supply of the first level is higher than that of the second level, and the resource supply of the second level is higher than that of the third level. The size relationship of the weight values ​​f, g, h, i, j, and k is: f>g>h>i>j>k.

[0300] In one implementation, the value of k may be less than or equal to the value of d.

[0301] In another implementation, the value of k may be less than or equal to the value of c.

[0302] Among them, the values ​​of f, g, h, i, j, and k can be determined according to the distribution range of the weight values ​​of the threads in the key thread list; they can also be determined by the system based on the resource supply capacity of the system; this application does not limit this.

[0303] In other embodiments, all key threads in the key thread list are sorted in descending order according to their weight values, and all sorted key threads are divided into multiple weight value intervals, and the multiple weight value intervals are corresponded one by one to multiple resource scheduling levels. The larger the weight value of the weight value interval, the higher the corresponding resource scheduling level. For example, the candidate threads with weight values ​​sorted as 1-A1 correspond to the first level, the candidate threads with weight values ​​sorted as A1-A2 correspond to the second level, and the candidate threads with weight values ​​sorted as A2-A3 correspond to the third level, wherein the resource supply of the first level is higher than that of the second level, and the resource supply of the second level is higher than that of the third level.

[0304] Among them, the values ​​of A1, A2, and A3 can be determined according to the distribution range of the weight values ​​of the threads in the critical thread list; they can also be determined according to the number of threads in the critical thread list; they can also be determined by the system based on the system's resource supply capabilities; this application does not limit this.

[0305] It should be understood that after the drawing of the current frame is completed, when the drawing of the next frame begins, step S1002 is re-executed, that is, steps S1002 to S1008 will be executed in each frame corresponding to the frame drawing thread, so that a stable key thread call chain can be obtained, and the stability of key thread identification is improved. The weight value of the thread will be adjusted in each frame, and the weight value of the thread in the candidate thread list can be dynamically adjusted, so that the key thread list can be updated in time.

[0306] In an embodiment of the present application, after identifying the key threads and determining the key thread list, the key threads in the key thread list are graded according to their weight values, and different weight value intervals correspond to different resource scheduling levels, thereby realizing graded resource supply control for the key threads, which can make the resource supply more closely matched with the actual needs of the threads, make the resource scheduling more reasonable, thereby improving the task running performance of the application, and avoiding the waste of system resources to a certain extent.

[0307] For example, Fig.11 A schematic diagram of a key thread identification process provided by an embodiment of the present application is shown.

[0308] like Fig.11 As shown, the process of identifying the key thread may include the following steps:

[0309] (1) When a first thread of an application is identified, one or more second threads related to the first thread corresponding to the i-th cycle of the first thread are obtained according to the thread wake-up relationship.

[0310] In one example, one or more second threads related to the first thread corresponding to the i-th cycle include: 1.ui, app, Chrome ChildIOT, Thread-1, kworker, RenderThread, 1.raster, surfaceflinger, binder, <…>, Compositor, timer1, uc.service, <…>.

[0311] (2) Determine one or more candidate threads corresponding to the i-th cycle from one or more second threads related to the first thread corresponding to the i-th cycle.

[0312] In an example, one or more second threads corresponding to the i-th period are first screened to obtain a preliminary screening filter group, including: 1.ui, Chrome ChildIOT, Thread-1, kworker, 1.raster, <…>, Compositor, timer1, uc.service, <…>; then the threads in the preliminary screening filter group are further screened to obtain one or more candidate threads corresponding to the i-th period: 1.ui, Chrome ChildIOT, Thread-1, 1.raster, Compositor, uc.service, <…>.

[0313] (3) Add one or more candidate threads corresponding to the i-th cycle to the candidate thread group.

[0314] If i is greater than 1, the candidate thread group includes one or more candidate threads corresponding to the i-th cycle, and also includes candidate threads corresponding to each cycle before the i-th cycle.

[0315] In some embodiments, in step (3), the weight values ​​of one or more candidate threads corresponding to the i-th cycle are increased by a, and then added to the candidate thread group; then the weight values ​​of all threads in the candidate thread group are reduced by b.

[0316] In other embodiments, after one or more candidate threads corresponding to the i-th cycle are added to the candidate thread group, the weight values ​​of the one or more candidate threads corresponding to the i-th cycle are increased by a respectively; then the weight values ​​of all threads in the candidate thread group are decreased by b respectively.

[0317] (4) Determine the key thread group based on the weight value of each thread in the candidate thread group.

[0318] In some embodiments, threads with weight values ​​greater than c in the candidate thread group are included in the critical thread group, and threads with weight values ​​less than d in the critical thread group are removed from the critical thread group.

[0319] In one example, the key thread groups determined from the candidate thread groups include: 1.ui, Chrome ChildIOT, Thread-1, 1.raster, Compositor, <…>.

[0320] For example, Fig.12 FIG. 1 is a schematic diagram showing the functional modules of a resource scheduling device 1200 provided in an embodiment of the present application. Fig.12 As shown, the device 1200 includes:

[0321] The identification module 1210 is configured to identify a first thread of an application.

[0322] In some embodiments, the identification module 1210 identifies the first thread by inserting a stub in a function that needs to be called during the execution of the first thread.

[0323] In some other embodiments, the identification module 1210 identifies the first thread by identifying the identification information of the first thread.

[0324] Among them, stubbing refers to inserting probes into the program on the basis of ensuring the logical integrity of the original program. The probes collect information in the code (the method itself, method parameter values, return values, etc.), and insert code segments at specific locations of the program to collect dynamic context information when the program is running.

[0325] The wakeup relationship acquisition module 1220 is used to acquire the thread wakeup relationship.

[0326] Specifically, the wakeup relationship acquisition module 1220 is used to acquire the thread wakeup relationship corresponding to the i-th cycle in the i-th cycle of the first thread.

[0327] It should be understood that the thread wake-up relationship corresponding to different periods of the first thread may be different, that is, the thread wake-up relationship has a corresponding relationship with the period of the first thread, and the thread wake-up relationship refers to the association relationship between the first thread and other threads. The association relationship between the first thread and other threads can be found in Figure 4 and Figure 4 Description section.

[0328] The key thread acquisition module 1230 is used to acquire a key thread list according to the thread wakeup relationship, where the key thread list includes one or more key threads related to the first thread.

[0329] The one or more critical threads related to the first thread may be understood as one or more threads having a critical impact on the running of the first thread.

[0330] In one implementation, the running process of the first thread corresponds to multiple cycles (running cycles). In each running cycle of the first thread, a list of key threads corresponding to the current running cycle is obtained through a thread wake-up relationship; or, in every few running cycles of the first thread, a list of key threads corresponding to the current few running cycles is obtained through a thread wake-up relationship.

[0331] That is, the key thread acquisition module 1230 is specifically used to acquire the key thread list corresponding to the i-th period through the thread wake-up relationship corresponding to the i-th period.

[0332] The key thread management module 1240 is used to provide targeted resources to each thread in the key thread list.

[0333] In some embodiments, the critical thread management module 1240 is used to increase the resource supply to the threads in the critical thread list, and to reduce the resource supply to the non-critical threads (ie, threads not in the critical thread list).

[0334] Optionally, the first thread may be a frame drawing thread, and the duration of one cycle of the first thread may be the duration corresponding to the frame drawing thread drawing one frame of image; in addition, the first thread may also be any other thread, which is not limited in the present application.

[0335] Among them, the identification module 1210 is located in the application layer of the operating system, the wake-up relationship acquisition module 1220 is located in the kernel layer of the operating system, and the key thread acquisition module 1230 and the key thread management module 1240 are located in the system library of the operating system.

[0336] In an embodiment of the present application, a critical thread related to the running task is determined from threads related to the running task through an identification algorithm (weight value algorithm) in the system. The identification process of the critical thread does not rely on the subjective judgment of the application developer, and can accurately identify the critical thread related to the running task, and then prioritize resource supply for the determined critical thread to achieve better resource scheduling.

[0337] For example, taking the first thread as a frame drawing thread, Fig.13 FIG. 1 shows a system architecture diagram corresponding to a resource scheduling method provided in an embodiment of the present application. Fig.13 As shown, the system architecture includes: a frame drawing thread identification module 1310, a scene identification module 1320, an information integration module 1330, a wake-up relationship acquisition module 1340, a key thread acquisition module 1350, a key thread management module 1360, and a driver 1370, wherein the frame drawing thread identification module 1310 and the scene identification module 1320 can be located in the application layer, the information integration module 1330 can be located in the service layer (native layer), the key thread acquisition module 1350 and the key thread management module 1360 can be located in the system library (for example, Huawei intelligent service: hwsched service), and the wake-up relationship acquisition module 1340 and the driver 1370 (for example, HISI VIO 2.0) can be located in the kernel layer.

[0338] Specifically:

[0339] The frame drawing thread identification module 1310 is used to identify the frame drawing thread of the application.

[0340] In some embodiments, the frame drawing thread of the application is identified by instrumenting the queuebuffer function.

[0341] Among them, the queuebuffer function is a function used to transfer drawing frame data. The call of the queuebuffer function is a necessary process in the frame drawing process. It should be understood that each frame corresponds to a queuebuffer function. When it is necessary to draw an image, the queuebuffer function is called to obtain and transfer the drawing elements corresponding to the current frame.

[0342] In other words, the queuebuffer function is usually used in third-party application frame drawing scenarios (for example, image rendering scenarios). It is specifically used to obtain the drawing elements corresponding to the current frame by performing drawing logic calculations on the current frame, and pass the drawing elements corresponding to the current frame to the system driver so that the system driver can further perform drawing operations on the current frame.

[0343] Among them, the explanation of the instrumentation and frame drawing threads is in Figure 8 A detailed explanation is given in S801 in the illustrated embodiment, and for the sake of brevity, it will not be repeated here.

[0344] The scene recognition module 1320 is used to recognize the scene of the application frame.

[0345] The information integration module 1330 serves as an interaction medium between the frame drawing thread identification module 1310 and the scene identification module 1320 of the application layer and the key thread identification module 1350 and the key thread management module 1360 of the system library.

[0346] In some embodiments, the information integration module 1330 is located in the surfaceflinger module.

[0347] The surfaceflinger module refers to the module responsible for managing and rendering the application interface in the operating system.

[0348] The wakeup relationship acquisition module 1340 is used to acquire thread wakeup relationships.

[0349] Specifically, the wakeup relationship acquisition module 1340 is used to acquire the thread wakeup relationship corresponding to the i-th frame when the frame drawing thread draws the i-th frame.

[0350] It should be understood that the corresponding thread wake-up relationship may be different when the frame drawing thread draws different frames, that is, the thread wake-up relationship has a corresponding relationship with the frame of the frame drawing thread. The thread wake-up relationship refers to the association relationship between the frame drawing thread and other threads. The association relationship between the frame drawing thread and other threads can be found in Figure 4 and Figure 4 Description section.

[0351] The key thread acquisition module 1350 is used to acquire one or more second threads corresponding to the i-th frame in the i-th frame of the frame drawing thread (which can also be described as: when the frame drawing thread proceeds to drawing the i-th frame) through the thread wake-up relationship, where the second thread refers to a thread related to the frame drawing thread, wherein i is a positive integer greater than or equal to 1, and the initial value of i is 1.

[0352] The one or more second threads related to the frame drawing thread may be understood as one or more threads that have an impact on the running of the frame drawing thread.

[0353] Specifically, the frame drawing thread corresponds to multiple frames. In each frame of the frame drawing thread, the key thread acquisition module 1350 acquires one or more second threads related to the frame drawing thread corresponding to the current frame through the thread wake-up relationship.

[0354] Specifically, in the i-th frame of the frame drawing thread, the key thread acquisition module 1350 acquires one or more second threads corresponding to the i-th frame through the thread wake-up relationship corresponding to the i-th frame.

[0355] The thread wake-up relationship in this step corresponds to the frame drawing thread, which refers to the association relationship between the frame drawing thread and other threads. The association relationship between the frame drawing thread and other threads can be found in Figure 4 and Figure 4 Description section.

[0356] Optionally, different frames of the frame drawing thread correspond to different thread wake-up relationships, that is, the thread wake-up relationship has a corresponding relationship with the frames of the frame drawing thread.

[0357] In this step, the key thread acquisition module 1350 identifies one or more second threads related to the running of the frame drawing thread through the thread wakeup relationship, and can accurately query other threads that actually affect the running of the frame drawing thread.

[0358] The key thread acquisition module 1350 is further configured to determine one or more candidate threads corresponding to the i-th frame from the one or more second threads corresponding to the i-th frame. Specifically, the key thread acquisition module 1350 screens the one or more second threads corresponding to the i-th frame, removes threads of the first type from the one or more second threads corresponding to the i-th frame, and then obtains one or more candidate threads corresponding to the i-th frame.

[0359] In some embodiments, a first type of thread refers to a thread that is not related to the performance guarantee of a frame drawing thread. The first type of thread may include a real-time (RT) thread that has a high priority in terms of supply capability, a binder thread that can be reused by other modules in the system, and a kworker thread that can be reused by other modules in the system. In addition, the first type of thread may also include other threads that are not related to the performance guarantee of a frame drawing thread (for example, other threads that can be reused by other modules in the system), which is not limited in the present application.

[0360] The system may directly determine whether the thread is a first type of thread according to the task type.

[0361] Through this step, the key threads in the key thread list finally obtained can be threads that actually affect the running performance of the frame drawing thread, thereby avoiding misidentification of key threads and unnecessary resource supply.

[0362] The key thread acquisition module 1350 is further configured to update the candidate thread list according to one or more candidate threads corresponding to the i-th frame.

[0363] In some embodiments, when i=1, an empty candidate thread list is created, and one or more candidate threads corresponding to the i-th frame are all added to the candidate thread list to obtain an updated candidate thread list (which can also be described as the candidate thread list corresponding to the i-th frame), wherein the updated candidate thread list does not specifically refer to the candidate thread list corresponding to a certain frame, but refers to the candidate thread list obtained by the most recent update.

[0364] In some other embodiments, when i is greater than 1, threads among one or more candidate threads corresponding to the i-th frame that do not exist in the candidate thread list (which can also be described as the candidate thread list corresponding to the i-1-th frame) are added to the candidate thread list (which can also be described as the candidate thread list corresponding to the i-1-th frame) to obtain an updated candidate thread list (which can also be described as the candidate thread list corresponding to the i-th frame).

[0365] The key thread acquisition module 1350 is further configured to add a to the weight values ​​of one or more candidate threads corresponding to the i-th frame in the updated candidate thread list.

[0366] In some embodiments, the value of a can be 2.

[0367] In another implementation, the key thread acquisition module 1350 adds a to the weight values ​​of one or more candidate threads corresponding to the i-th frame, and then updates the candidate thread list according to the candidate thread list corresponding to the i-th frame.

[0368] It should be understood that: the weight values ​​of one or more candidate threads determined from one or more second threads obtained from the current frame (i-th frame) are added with a respectively.

[0369] The candidate thread list includes one or more candidate threads obtained in the current frame (i-th frame); and also includes one or more candidate threads obtained in all frames before the current frame (i-th frame).

[0370] The key thread acquisition module 1350 is further configured to reduce the weight values ​​of all candidate threads in the updated candidate thread list by b.

[0371] In some embodiments, the value of b may be 1.

[0372] In an example, the present frame (the i-th frame) is the 3rd frame, the candidate thread list corresponding to the 2nd frame includes 10 candidate threads, the third frame corresponds to 5 candidate threads, and 3 of the 5 candidate threads do not exist in the candidate thread list corresponding to the 2nd frame, then the 3 candidate threads are added to the candidate thread list corresponding to the 2nd frame to obtain an updated candidate thread list (i.e., the candidate thread list corresponding to the 3rd frame), and the updated candidate thread list includes 13 candidate threads; wherein, the process of determining the weight values ​​of the threads in the updated candidate thread list is: adding a to the weight values ​​of the 5 candidate threads corresponding to the third frame in the updated candidate thread list, and subtracting b from the weight values ​​of the 13 candidate threads in the updated candidate thread list.

[0373] It should be noted that when thread A in the candidate thread list is added to the critical thread list, thread A still exists in the candidate thread list and participates in the weight value change process together with other candidate threads in the candidate thread list; when the weight value of thread A in the candidate thread list changes, the weight value of thread A in the critical thread list changes synchronously.

[0374] By analogy, when the frame drawing thread draws each frame, the weight values ​​of the candidate threads in the candidate thread list may change, so that the weight values ​​of threads that appear frequently in multiple frames can be gradually increased, thereby accurately identifying key threads.

[0375] The key thread acquisition module 1350 is further configured to add threads with weight values ​​greater than c in the updated candidate thread list to the key thread list, and remove threads with weight values ​​less than d in the key thread list from the key thread list.

[0376] In an example, the present frame (the i-th frame) is the 3rd frame, the candidate thread list corresponding to the 2nd frame includes 10 candidate threads, the third frame corresponds to 5 candidate threads, and 3 of the 5 candidate threads do not exist in the candidate thread list corresponding to the 2nd frame, then the 3 candidate threads are added to the candidate thread list corresponding to the 2nd frame to obtain an updated candidate thread list (i.e., the candidate thread list corresponding to the 3rd frame), and the updated candidate thread list includes 13 candidate threads; wherein, the process of determining the weight values ​​of the threads in the updated candidate thread list is: adding a to the weight values ​​of the 5 candidate threads corresponding to the third frame in the updated candidate thread list, respectively, and subtracting b from the weight values ​​of all the candidate threads in the updated candidate thread list; and then updating the critical thread list based on the weight values ​​of the 13 candidate threads in the updated candidate thread list, and the specific updating process is: adding threads with weight values ​​greater than c in the updated candidate thread list to the critical thread list, and removing threads with weight values ​​less than d in the critical thread list from the critical thread list.

[0377] In some embodiments, the value of c can be 10.

[0378] The value of d is less than or equal to c. For example, the value of d may be 5.

[0379] It should be understood that the "frame" described in the embodiments of the present application is a single image picture that is the smallest unit in the image animation, which is equivalent to each frame of a movie film. A frame is a still picture, and continuous frames form an animation, such as a TV image.

[0380] In one example, the application is located in a first chat interface. When the application receives a first message, the interface changes to a second chat interface, wherein the first chat interface and the second chat interface can be regarded as two frames of the application.

[0381] It should also be understood that the embodiments of the present application are described using the application frame drawing scenario as an example, but this does not limit the use scenario of the device of the present application. The device of the present application can also be used in the running process of other threads.

[0382] The key thread management module 1360 is used to provide targeted resources to each thread in the key thread list.

[0383] The key thread management module 1360 is further used to provide resources to each thread in the key thread list according to the weight value interval corresponding to the weight value.

[0384] In some embodiments, resource provisioning to threads in a critical thread list is increased while resource provisioning to non-critical threads is reduced.

[0385] In an embodiment of the present application, a critical thread related to a running task is determined from threads related to the running task through an identification algorithm (weight value algorithm) in the system. The identification process of the critical thread does not rely on the subjective judgment of the application developer, and can accurately identify the critical thread related to the running task, thereby enabling priority to guarantee resource supply for the determined critical thread to achieve better resource scheduling; and, critical threads are identified in each frame of the running task, and critical threads are determined based on the probability and influence of the threads related to the running task appearing in multiple frames, which can improve the stability of critical thread identification and enable timely updating of critical threads; in addition, by assigning weight values ​​to threads, and adaptively adjusting the weight values ​​of threads in each frame, the critical thread list is dynamically updated according to changes in their weight values, so that the identification results of the critical threads are adapted to changes in the running state of the first thread, further improving the accuracy of critical thread identification.

[0386] One or more of the modules or units described herein can be implemented by software, hardware or a combination of the two. When any of the above modules or units are implemented in software, the software exists in the form of computer program instructions and is stored in a memory, and a processor can be used to execute the program instructions and implement the above method flow. The processor may include but is not limited to at least one of the following: a central processing unit (CPU), a microprocessor, a digital signal processor (DSP), a microcontroller (MCU), or an artificial intelligence processor and other types of computing devices that run software, each computing device may include one or more cores for executing software instructions to perform operations or processing. The processor may be built into an SoC (system on chip) or an application specific integrated circuit (ASIC), or it may be an independent semiconductor chip. In addition to the core used to execute software instructions for operations or processing in the processor, necessary hardware accelerators may be further included, such as a field programmable gate array (FPGA), a PLD (programmable logic device), or a logic circuit that implements a dedicated logic operation.

[0387] When the modules or units described in this document are implemented in hardware, the hardware can be any one or any combination of a CPU, a microprocessor, a DSP, an MCU, an artificial intelligence processor, an ASIC, a SoC, an FPGA, a PLD, a dedicated digital circuit, a hardware accelerator, or a non-integrated discrete device, which can run the necessary software or be independent of the software to execute the above method flow.

[0388] When the modules or units described herein are implemented using software, they can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, a computer, a server, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server, or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state drive (SSD)), etc.

[0389] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0390] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0391] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0392] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0393] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0394] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage media include: 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 disks.

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

Claims

1. A resource scheduling method, characterized in that: The method comprises: When a first thread of an application is detected, in an i-th cycle of the first thread, according to a thread wake-up relationship, a key thread list corresponding to the i-th cycle is obtained, wherein the key thread list includes one or more key threads related to the first thread, wherein i is a natural number, i=1, 2, 3, 4, ...; Resource scheduling is performed based on the critical thread list corresponding to the i-th period.

2. The method according to claim 1, characterized in that The method further comprises: In the (i+1)th cycle of the first thread, the key thread list corresponding to the (i+1)th cycle is updated to obtain the key thread list corresponding to the (i+1)th cycle; Resource scheduling is performed based on the critical thread list corresponding to the (i+1)th cycle.

3. The method according to claim 2, characterized in that The step of updating the key thread list corresponding to the i-th cycle in the i+1th cycle of the first thread to obtain the key thread list corresponding to the i+1th cycle includes: In the (i+1)th cycle of the first thread, obtaining one or more second threads corresponding to the (i+1)th cycle according to the thread wake-up relationship; According to the one or more second threads corresponding to the (i+1)th cycle, the key thread list corresponding to the (i+1)th cycle is updated to obtain the key thread list corresponding to the (i+1)th cycle.

4. The method according to any one of claims 1 to 3, characterized in that The step of obtaining, in the i-th cycle of the first thread, a list of key threads corresponding to the i-th cycle according to the thread wake-up relationship includes: In an i-th cycle of the first thread, determining one or more second threads corresponding to the i-th cycle according to the thread wake-up relationship, wherein the second threads are threads related to the first thread; Determine a weight of each second thread in the one or more second threads corresponding to the i-th cycle; According to the weight of each second thread in the one or more second threads corresponding to the i-th period, a critical thread list corresponding to the i-th period is determined from the one or more second threads corresponding to the i-th period.

5. The method according to claim 4, characterized in that Before determining the weight of each second thread in the one or more second threads corresponding to the i-th cycle, the method further includes: A first type of thread in the one or more second threads corresponding to the i-th cycle is excluded, where the first type of thread includes a high priority thread and / or a reusable thread.

6. The method according to claim 4 or 5, characterized in that: The determining the weight of each second thread in the one or more second threads corresponding to the i-th cycle includes: Adding one or more second threads corresponding to the i-th period to a candidate thread list to obtain a candidate thread list corresponding to the i-th period; Increasing the weights of one or more second threads corresponding to the i-th period by the first weight respectively; The weights of all candidate threads in the candidate thread list corresponding to the i-th period are respectively reduced by the second weight.

7. The method according to claim 6, characterized in that The determining of the key thread list corresponding to the i-th cycle includes: The critical thread list corresponding to the i-th period is determined by adding candidate threads whose weights in the candidate thread list corresponding to the i-th period are greater than a first weight threshold into the critical thread list.

8. The method according to claim 3, characterized in that The updating of the key thread list corresponding to the i-th cycle according to the one or more second threads corresponding to the i+1-th cycle to obtain the key thread list corresponding to the i+1-th cycle includes: Update the candidate thread list corresponding to the i-th period according to the one or more second threads corresponding to the i+1-th period, to obtain the candidate thread list corresponding to the i+1-th period, wherein the candidate thread list corresponding to the i+1-th period includes the one or more second threads corresponding to the i+1-th period; Increasing the weights of one or more second threads corresponding to the (i+1)th cycle by the first weight respectively; Reducing the weights of all candidate threads in the candidate thread list corresponding to the (i+1)th cycle by a second weight respectively; According to the weight of each candidate thread in the candidate thread list corresponding to the (i+1)th cycle, the key thread list corresponding to the (i+1)th cycle is updated to obtain the key thread list corresponding to the (i+1)th cycle.

9. The method according to claim 8, characterized in that Before updating the candidate thread list corresponding to the i-th period according to the one or more second threads corresponding to the i+1-th period, the method further includes: A first type of thread in the one or more second threads corresponding to the (i+1)th cycle is excluded, where the first type of thread includes a high priority thread and / or a reusable thread.

10. The method according to claim 8 or 9, characterized in that: The updating of the key thread list corresponding to the i-th period according to the weight of each candidate thread in the candidate thread list corresponding to the i+1-th period includes: Adding threads whose weights are greater than a first weight threshold in the candidate thread list corresponding to the i+1th cycle to the key thread list corresponding to the ith cycle; The threads in the candidate thread list corresponding to the (i+1)th cycle whose weights are less than a second weight threshold are removed from the key thread list corresponding to the i-th cycle, wherein the first weight threshold is greater than or equal to the second weight threshold.

11. The method according to any one of claims 1 to 10, characterized in that The resource scheduling based on the key thread list corresponding to the i-th period includes: Increase the resource supply to the threads in the critical thread list corresponding to the i-th cycle, and reduce the resource supply to the threads outside the critical thread list corresponding to the i-th cycle; or The resource scheduling based on the key thread list corresponding to the (i+1)th cycle includes: The resource supply to the threads in the critical thread list corresponding to the (i+1)th cycle is increased, and the resource supply to the threads outside the critical thread list corresponding to the (i+1)th cycle is reduced.

12. The method according to claim 11, characterized in that The method further comprises: Resources are supplied to the threads in the critical thread list in different levels.

13. The method according to any one of claims 6 to 10, characterized in that When i is less than or equal to the first cycle threshold, the first weight is equal to a1; when i is greater than the first cycle threshold, the first weight is equal to a2, wherein a1>a2>0.

14. The method according to any one of claims 1 to 13, characterized in that The first thread is a frame drawing thread.

15. A resource scheduling device, characterized in that: The device comprises: an acquisition module, configured to, when a first thread of an application is detected, acquire, in an i-th cycle of the first thread, a key thread list corresponding to the i-th cycle according to a thread wake-up relationship, wherein the key thread list includes one or more key threads related to the first thread, wherein i is a natural number, i=1, 2, 3, 4, ...; The resource scheduling module is used to perform resource scheduling based on the key thread list corresponding to the i-th period.

16. The device according to claim 15, characterized in that The device also includes: An updating module, configured to obtain a key thread list corresponding to an i+1th period by updating the key thread list corresponding to the i-th period in the i+1th period of the first thread; The resource scheduling module is also used for: Resource scheduling is performed based on the critical thread list corresponding to the (i+1)th cycle.

17. The device according to claim 16, characterized in that The update module is specifically used for: In the (i+1)th cycle of the first thread, obtaining one or more second threads corresponding to the (i+1)th cycle according to the thread wake-up relationship; According to the one or more second threads corresponding to the (i+1)th cycle, the key thread list corresponding to the (i+1)th cycle is updated to obtain the key thread list corresponding to the (i+1)th cycle.

18. The device according to any one of claims 15 to 17, characterized in that The acquisition module is specifically used for: In an i-th cycle of the first thread, determining one or more second threads corresponding to the i-th cycle according to the thread wake-up relationship, wherein the second threads are threads related to the first thread; Determine a weight of each second thread in the one or more second threads corresponding to the i-th cycle; According to the weight of each second thread in the one or more second threads corresponding to the i-th period, a critical thread list corresponding to the i-th period is determined from the one or more second threads corresponding to the i-th period.

19. The device according to claim 18, characterized in that The device also includes: The preprocessing module is used to exclude first-type threads from one or more second threads corresponding to the i-th period, where the first-type threads include high-priority threads and / or reusable threads.

20. The device according to claim 18 or 19, characterized in that The acquisition module is also specifically used for: Adding one or more second threads corresponding to the i-th period to a candidate thread list to obtain a candidate thread list corresponding to the i-th period; Increasing the weights of one or more second threads corresponding to the i-th period by the first weight respectively; The weight values ​​of all candidate threads in the candidate thread list corresponding to the i-th period are respectively reduced by the second weight.

21. The device according to claim 20, characterized in that The acquisition module is also specifically used for: The critical thread list corresponding to the i-th period is determined by adding candidate threads whose weights in the candidate thread list corresponding to the i-th period are greater than a first weight threshold into the critical thread list.

22. The device according to claim 17, characterized in that The update module is also specifically used for: Update the candidate thread list corresponding to the i-th period according to the one or more second threads corresponding to the i+1-th period, and obtain the candidate thread list corresponding to the i+1-th period, wherein the candidate thread list corresponding to the i+1-th period includes the one or more second threads corresponding to the i+1-th period; Increasing the weights of one or more second threads corresponding to the (i+1)th cycle by the first weight respectively; Reducing the weights of all candidate threads in the candidate thread list corresponding to the (i+1)th cycle by a second weight respectively; According to the weight of each candidate thread in the candidate thread list corresponding to the (i+1)th cycle, the key thread list corresponding to the (i+1)th cycle is updated to obtain the key thread list corresponding to the (i+1)th cycle.

23. The device according to claim 22, characterized in that The preprocessing module is also used for: A first type of thread in the one or more second threads corresponding to the (i+1)th cycle is excluded, where the first type of thread includes a high priority thread and / or a reusable thread.

24. The device according to claim 22 or 23, characterized in that The update module is also specifically used for: Adding threads whose weights are greater than a first weight threshold in the candidate thread list corresponding to the i+1th cycle to the key thread list corresponding to the ith cycle; The threads in the candidate thread list corresponding to the (i+1)th cycle whose weights are less than a second weight threshold are removed from the key thread list corresponding to the i-th cycle, wherein the first weight threshold is greater than or equal to the second weight threshold.

25. The device according to any one of claims 15 to 24, characterized in that The resource scheduling module is specifically used for: Improving the resource supply to threads in the critical thread list corresponding to the i-th cycle, while reducing the resource supply to threads outside the critical thread list corresponding to the i-th cycle; or The resource scheduling based on the key thread list corresponding to the (i+1)th cycle includes: The resource supply to the threads in the critical thread list corresponding to the (i+1)th cycle is increased, and the resource supply to the threads outside the critical thread list corresponding to the (i+1)th cycle is reduced.

26. The device according to claim 25, characterized in that The resource scheduling module is also specifically used for: Resources are supplied to the threads in the critical thread list in different levels.

27. The device according to any one of claims 20 to 24, characterized in that When i is less than or equal to the first cycle threshold, the first weight is equal to a1; when i is greater than the first cycle threshold, the first weight is equal to a2, wherein a1>a2>0.

28. The device according to any one of claims 15 to 27, characterized in that The first thread is a frame drawing thread.

29. An electronic device, characterized in that: include: one or more processors; one or more memories; and one or more computer programs, wherein the one or more computer programs are stored in the one or more memories, and the one or more computer programs include instructions, which, when executed by the one or more processors, cause the electronic device to perform the method as described in any one of claims 1 to 14.

30. A computer-readable storage medium, characterized in that: The storage medium stores a program or an instruction, and when the program or the instruction is executed, the method according to any one of claims 1 to 14 is implemented.

31. A chip, characterized in that: include: one or more processors; One or more memories, the one or more processors are coupled to the one or more memories, and are configured to read and execute instructions in the one or more memories to perform the method according to any one of claims 1 to 14.

Citation Information

Cited By

  • Resource scheduling method and apparatus, and electronic device

    EP4726545A1

  • Resource scheduling method and apparatus, and electronic device

    WO2025036044A1