Resource supply method, electronic equipment and computer readable storage medium
By identifying the target thread and other threads of the target business scenario, determining the key thread based on the thread wake-up relationship, and adjusting the resource supply, the problem of misidentification and missed identification of key threads in the existing technology is solved, and the response speed and response speed of electronic equipment are improved. fluency.
Patent Information
- Application Number
- CN202310909938.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-21
- Publication Date
- 2025-01-21
AI Technical Summary
The existing key thread recognition methods are prone to misidentification and misidentification, resulting in system lag and slow response speed of electronic devices.
By identifying the target thread of the target business scenario, other threads are identified based on the thread wake-up relationship, and the thread of the target business scenario is determined as a key thread, and its resource supply is adjusted to reduce the probability of misidentification and missed identification.
Accurately identify key threads, reduce system freezes and slow response times, and improve user experience.
Smart Images

Figure CN119336482A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electronic equipment, and in particular to a resource supply method, an electronic device and a computer-readable storage medium. Background Art
[0002] The response speed and fluency of electronic devices are closely related to the user experience. Generally speaking, the faster the response speed and the higher the fluency of the electronic device, the better the user experience.
[0003] When users use electronic devices, in order to ensure the smoothness and response speed of the electronic devices, the electronic devices usually need to use resource scheduling strategies to reasonably schedule resources such as the central processing unit (CPU), memory, graphics processing unit (GPU), and input / output (I / O) to ensure the resource supply of key threads so that the electronic devices can respond and output in a timely and effective manner.
[0004] Currently, when identifying key threads, electronic devices can identify the user interface (UI) thread and render thread of the foreground application as key threads, or they can identify key threads through a pre-set thread name whitelist. However, these key thread identification methods are prone to misidentification and missed identification, which in turn causes problems such as system freezes and slow response speeds in electronic devices, affecting the user experience. Summary of the invention
[0005] The embodiments of the present application provide a resource supply method, an electronic device, and a computer-readable storage medium, which can solve the problem that the existing key thread identification method is prone to misidentification and missed identification, which in turn causes the electronic device to freeze and respond slowly.
[0006] In a first aspect, an embodiment of the present application provides a resource supply method, in which, if an electronic device is in a target business scenario, after determining a target thread of the target business scenario, the electronic device identifies other threads of the target business scenario through a thread wake-up relationship based on the target thread, and determines part or all of the threads of the target business scenario as key threads, wherein the threads of the target business scenario include the target thread of the target business scenario and other threads of the target business scenario; and adjusts the resource supply of the key thread, wherein the adjusted resource supply is stronger than the resource supply before the adjustment. The target thread is a thread for outputting data.
[0007] As can be seen from the above, the embodiment of the present application first identifies the target thread of the target business scenario, and then derives other threads of the target business scenario based on the target thread and the thread wake-up relationship, and determines some or all of the threads of the target business scenario as key threads. In this way, in the case of thread name update, thread name synchronization, third-party application business upgrade and system version upgrade, the key thread can be accurately identified based on the relatively fixed target thread, reducing the probability of misidentification and missed identification of the key thread, thereby reducing the occurrence of problems such as system freezes and slow response speeds, and improving user experience.
[0008] In a possible implementation manner of the first aspect, the electronic device may determine, according to a first corresponding relationship, that a thread corresponding to the target business scenario is a target thread. The first corresponding relationship is a corresponding relationship between a business scenario and a thread.
[0009] In a possible implementation of the first aspect, the target business scenario is a display business scenario, an audio business scenario, or an input business scenario. For example, when a user uses a mobile phone to watch a short video application and continuously slides the video with his hands, the display business scenario, the audio business scenario, and the input business scenario are all involved. At this time, for each target business scenario, the key thread is accurately identified through the target thread, and resources are supplied to the key thread on this basis, ensuring that the mobile phone can respond to the output in a timely and effective manner, the device operation fluency and response speed are faster, and the user experience is higher.
[0010] In a possible implementation of the first aspect, the target business scenario may be a business scenario including producers and consumers, such as a display business scenario; or it may be a business scenario that does not include producers and consumers. For a target business scenario including consumers and producers, the corresponding target thread may include a target thread of the producer and a target thread of the consumer. At this time, the electronic device may determine other threads of the producer of the target business scenario through a thread wake-up relationship based on the target thread of the producer; and determine other threads of the consumer of the target business scenario through a thread wake-up relationship based on the target thread of the consumer. Among them, the other threads of the target business scenario include other threads of the producer and other threads of the consumer. In this way, for a target business scenario including producers and consumers, other threads of the producer and other threads of the consumer are determined based on the target thread of the producer and the target thread of the consumer, respectively, to ensure the identification of relevant threads involved in the target business scenario.
[0011] In a possible implementation manner of the first aspect, the electronic device may adjust the resource supply of each key thread according to the resource adjustment mode of each key thread.
[0012] In a possible implementation of the first aspect, after the electronic device accurately identifies the critical thread through the target thread and the thread wake-up relationship, the resource supply of the critical thread can be adjusted. In the process of adjusting the resource supply according to the resource adjustment method, the electronic device can create an associated scheduling group including all critical threads, and supply resources in units of the critical scheduling group. That is, after determining the first resource supply amount of the associated scheduling group, the resource supply of the critical thread is adjusted according to the resource adjustment method of the critical thread according to the first resource supply amount for each critical thread of the associated scheduling group. In this way, the resource supply guarantee for the relevant threads involved in the target business scenario is performed in groups, which can reduce the probability of system freezes caused by priority flipping and other phenomena, and further improve the user experience.
[0013] In a possible implementation of the first aspect, if the target business scenario is a business scenario including producers and consumers, the frame rates of the producers and consumers may be inconsistent. At this time, when supplying resources in units of associated scheduling groups, in order to avoid resource waste due to oversupply of resources as much as possible, when determining the resource supply of the associated scheduling group, the electronic device can first obtain the first frame rate of the producer and the second frame rate of the consumer, and then determine the first target frame rate, which is the lower frame rate between the first frame rate and the second frame rate, and finally determine the first resource supply corresponding to the first target frame rate according to the second corresponding relationship, and then determine the resource supply of the associated scheduling group. The second corresponding relationship is the corresponding relationship between the frame rate and the resource supply.
[0014] After determining the resource supply of the associated scheduling group according to the dynamic frame rate, the electronic device adjusts the resource supply of the key thread according to the first resource supply of the resource adjustment method. In this way, when guaranteeing the resource supply of the relevant threads involved in the target business scenario in units of the associated scheduling group, a decision is made based on the frame rates of the producer and consumer sides to provide different resource supply amounts at different frame rates, that is, to provide different resource supply strengths, which can not only improve the fluency under high frame rates, but also avoid resource waste caused by oversupply of resources as much as possible.
[0015] In a possible implementation of the first aspect, if the target business scenario is a business scenario including producers and consumers, the frame rates of producers and consumers may be inconsistent. At this time, when the electronic device performs resource supply operations on the key thread, the third frame rate of the producer and the fourth frame rate of the consumer can be obtained first, and then the second target frame rate can be determined. The second target frame rate is the lower frame rate between the third frame rate and the fourth frame rate; finally, for each key thread, according to the third corresponding relationship of the key thread, the resource supply amount corresponding to the second target frame rate is determined as the second resource supply amount, and according to the second resource supply amount, according to the resource adjustment method of the key thread, the resource supply of the key thread is adjusted, and the third corresponding relationship is the correspondence between the frame rate and the resource supply amount. In this way, decisions are made in combination with the frame rates on both sides of the producer and consumer to provide different resource supply amounts at different frame rates, that is, to provide different resource supply strengths, which can not only improve the fluency under high frame rate conditions, but also avoid resource waste caused by excessive resource supply as much as possible.
[0016] In a possible implementation of the first aspect, the resource adjustment method includes at least one of the following: increasing scheduling priority, increasing memory allocation priority, I / O bandwidth guarantee, increasing the probability of switching to medium cores and / or large cores, and increasing device frequency.
[0017] In a second aspect, an embodiment of the present application provides a resource supply method, in which an electronic device determines a key thread; obtains a fifth frame rate of the producer and a sixth frame rate of the consumer; determines a third target frame rate, which is a lower frame rate between the fifth frame rate and the sixth frame rate; based on each key thread, according to a fourth corresponding relationship of the key thread, determines that the resource supply corresponding to the third target frame rate is a third resource supply, and according to the third resource supply and according to the resource adjustment method of the key thread, adjusts the resource supply of the key thread, the fourth corresponding relationship being the corresponding relationship between the frame rate and the resource supply.
[0018] As can be seen from the above, the embodiment of the present application makes decisions based on the frame rates of both the producer and consumer sides to provide different resource supply amounts at different frame rates, that is, to provide different resource supply intensities. This can not only improve the smoothness under high frame rate conditions, but also avoid resource waste due to oversupply of resources as much as possible.
[0019] In a possible implementation of the second aspect, after determining the key threads, the electronic device may also create an associated scheduling group including all the key threads. At this time, the resource supply of the associated scheduling group may be determined first, and then the resource supply of each key thread in the associated scheduling group may be adjusted according to the resource supply. In this way, by supplying resources in groups, the probability of system freezes caused by priority flipping and other phenomena may be reduced, further improving the user experience.
[0020] In a third aspect, an embodiment of the present application provides an electronic device, including:
[0021] A scene recognition module, used to recognize the business scene of the electronic device;
[0022] A key thread identification module is used to determine the target thread of the target business scenario if the electronic device is in the target business scenario, where the target thread is a thread for outputting data; based on the target thread, identify other threads of the target business scenario through thread wake-up relationships; determine some or all threads of the target business scenario as key threads, where the threads of the target business scenario include the target thread of the target business scenario and other threads of the target business scenario;
[0023] The resource supply module is used to adjust the resource supply of the key thread, wherein the resource supply after the adjustment is stronger than the resource supply before the adjustment.
[0024] In a possible implementation manner of the third aspect, the key thread identification module is specifically used to: determine, according to a first corresponding relationship, a thread corresponding to a target business scenario as a target thread, where the first corresponding relationship is a corresponding relationship between a business scenario and a thread.
[0025] In a possible implementation manner of the third aspect, the target service scenario is a display service scenario, an audio service scenario, or an input service scenario.
[0026] In a possible implementation manner of the third aspect, if the target business scenario is a business scenario including a producer and a consumer, the target thread includes a target thread of the producer and a target thread of the consumer;
[0027] The key thread identification module is specifically used for: based on the target thread of the producer, determining other threads of the producer of the target business scenario through the thread wake-up relationship; based on the target thread of the consumer, determining other threads of the consumer of the target business scenario through the thread wake-up relationship; wherein, the other threads of the target business scenario include other threads of the producer and other threads of the consumer.
[0028] In a possible implementation manner of the third aspect, the resource supply module is specifically configured to: adjust the resource supply of each key thread according to the resource adjustment mode of each key thread.
[0029] In a possible implementation of the third aspect, the resource supply module is specifically used to: create an associated scheduling group including all critical threads; determine a first resource supply amount of the associated scheduling group; and adjust the resource supply of the critical thread according to the first resource supply amount and the resource adjustment method of the critical thread for each critical thread of the associated scheduling group.
[0030] In a possible implementation of the third aspect, if the target business scenario is a business scenario including producers and consumers, the resource supply module is specifically used to: obtain a first frame rate of the producer and a second frame rate of the consumer; determine a first target frame rate, which is a lower frame rate between the first frame rate and the second frame rate; and determine, based on a second corresponding relationship, that the amount of resources corresponding to the first target frame rate is a first resource supply amount, and the second corresponding relationship is a corresponding relationship between the frame rate and the resource supply amount.
[0031] In a possible implementation of the third aspect, if the target business scenario is a business scenario including producers and consumers, the resource supply module is specifically used to: obtain a third frame rate of the producer and a fourth frame rate of the consumer; determine a second target frame rate, which is a lower frame rate between the third frame rate and the fourth frame rate; for each key thread, according to the third corresponding relationship of the key thread, determine the resource supply corresponding to the second target frame rate as the second resource supply, and according to the second resource supply and according to the resource adjustment method of the key thread, adjust the resource supply of the key thread, the third corresponding relationship being the corresponding relationship between the frame rate and the resource supply.
[0032] In a possible implementation of the third aspect, the resource adjustment method includes at least one of the following: increasing scheduling priority, increasing memory allocation priority, I / O bandwidth guarantee, increasing the probability of switching to medium cores and / or large cores, and increasing device frequency.
[0033] In a fourth aspect, an embodiment of the present application provides an electronic device, including:
[0034] A key thread identification module, used to identify key threads;
[0035] The resource supply amount decision module is used to obtain the fifth frame rate of the producer and the sixth frame rate of the consumer; determine a third target frame rate, which is a lower frame rate between the fifth frame rate and the sixth frame rate; for each key thread, according to the fourth corresponding relationship of the key thread, determine that the resource supply amount corresponding to the third target frame rate is the third resource supply amount, and the fourth corresponding relationship is the corresponding relationship between the frame rate and the resource supply amount;
[0036] The resource supply module is used to adjust the resource supply of each key thread according to the third resource supply amount and the resource adjustment method of the key thread.
[0037] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method described in any one of the first aspect or the second aspect is implemented.
[0038] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in any one of the first aspect or the second aspect is implemented.
[0039] In a seventh aspect, an embodiment of the present application provides a chip system, the chip system includes a processor, the processor is coupled to a memory, and the processor executes a computer program stored in the memory to implement the method as described in any one of the first aspect or the second aspect. The chip system can be a single chip, or a chip module composed of multiple chips.
[0040] In an eighth aspect, an embodiment of the present application provides a computer program product. When the computer program product runs on an electronic device, the electronic device executes the method described in any one of the first aspect or the second aspect.
[0041] It can be understood that the beneficial effects of the third to eighth aspects mentioned above can be found in the relevant descriptions of the first and second aspects mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 A schematic diagram of thread wake-up relationships provided in an embodiment of the present application;
[0043] Figure 2 A schematic diagram of a short video scene provided in an embodiment of the present application;
[0044] Figure 3A A schematic diagram of the structure of an electronic device 100 provided in an embodiment of the present application;
[0045] Figure 3B A schematic block diagram of a software system of an electronic device 100 provided in an embodiment of the present application;
[0046] Figure 4 A schematic flow chart of a resource provisioning method provided in an embodiment of the present application;
[0047] Figure 5 Another schematic block diagram of the process of the resource provisioning method provided in the embodiment of the present application;
[0048] Figure 6 A schematic diagram of an associated scheduling group and a resource provisioning method provided in an embodiment of the present application;
[0049] Figure 7 A schematic diagram of the relationship between the resource supply level and the operating time provided in the embodiment of the present application;
[0050] Figure 8 A schematic block diagram of another process of the resource provisioning method provided in an embodiment of the present application;
[0051] Fig. 9 A schematic diagram of a dynamic frame rate decision process provided in an embodiment of the present application;
[0052] Fig.10 A schematic block diagram of another process of the resource provisioning method provided in an embodiment of the present application;
[0053] Fig.11 A schematic block diagram of another process of the resource provisioning method provided in an embodiment of the present application;
[0054] Fig.12 A structural block diagram of an electronic device 100 provided in an embodiment of the present application;
[0055] Fig.13 This is a structural block diagram of an electronic device 100 provided in an embodiment of the present application. DETAILED DESCRIPTION
[0056] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures and technologies are provided to facilitate a thorough understanding of the embodiments of the present application.
[0057] The following is an exemplary introduction to the relevant contents that may be involved in the embodiments of the present application.
[0058] (1) Relationship between processes, threads and thread wake-up.
[0059] A process is the basic unit of resource allocation in an operating system (OS). It is an execution process of a program and also a running activity of a program. A program is static and exists as a resource of an operating system; a process is dynamic and has its own life cycle.
[0060] For example, a series of system programs and third-party applications are installed on the Android operating system of a mobile phone. When a program is started and run on the operating system, a process corresponding to the program is generated; when the program is exited or closed, the process corresponding to the program will disappear.
[0061] When a program runs on an operating system, the operating system needs to allocate resources such as CPU and memory to the running program entity. Therefore, a process usually includes the running program entity and the resources occupied by running the program entity.
[0062] Thread is the basic unit of processor task scheduling and execution. A process includes at least one thread, and each thread shares the resources of this process. A process can have multiple threads concurrently, and each thread can execute different tasks in parallel.
[0063] For example, the Android operating system of a mobile phone has a browser application installed. When a user starts the browser, the operating system creates a process corresponding to the browser. The browser process may include an event response thread and a rendering thread.
[0064] The thread wakeup relationship refers to the business dependency wakeup relationship between threads. For two threads with a business dependency wakeup relationship, one thread must wait for part of the business logic of the other thread to be executed before it can continue to execute.
[0065] Exemplarily, the first thread strongly relies on part of the business logic of the second thread when executing the code logic. At this time, during the process of the first thread executing the code logic, the first thread must wait for the execution of part of the business logic of the second thread before it can continue execution. This relationship is called the second thread waking up the first thread, that is, there is a thread wake-up relationship between the second thread and the first thread.
[0066] For example, see Figure 1 The thread wake-up relationship diagram provided in the embodiment of the present application is shown, where the consumer (i.e., the consumption end) includes thread A, thread B, thread C, and thread D, and the producer (i.e., the production end) includes thread E, thread F, and thread G.
[0067] like Figure 1 As shown in the figure, the blank part can be understood as the execution gap, during which the thread does not execute or is in a waiting state; the shaded part indicates that the thread is executing. For consumers, after thread A executes part of the code logic, it wakes up thread B. During the execution of thread B, thread A is in a waiting state; after thread B is executed, it wakes up thread A again. After the awakened thread A continues to execute part of the code logic, thread A wakes up thread B again; after the awakened thread B is executed again, thread B wakes up thread C. After thread C is executed, thread C wakes up thread D; after thread D is executed, thread D wakes up thread A again. Thread A continues to execute part of the code logic. During the execution of threads B, C and D, thread A is in a waiting state.
[0068] Therefore, the thread wake-up relationship on the consumer side is: thread A and thread B can wake up each other, thread B wakes up thread C, thread C wakes up thread D, and thread D wakes up thread A.
[0069] Similarly, for the producer, after thread F executes part of the code logic, it wakes up thread G. During the execution of thread G, thread F is in a waiting state; after thread G completes execution, thread G wakes up thread F. After the awakened thread F continues to execute part of the code logic, thread F wakes up thread E.
[0070] Therefore, the thread wake-up relationship on the producer side is: thread F wakes up thread E, and thread F and thread G can wake up each other.
[0071] (2) Business scenarios and business paths.
[0072] In order to meet user needs or respond to user operations, electronic devices usually need to execute corresponding services and are in corresponding service scenarios. For example, in response to a user's audio playback operation, an electronic device executes an audio service to output corresponding audio, and at this time the electronic device is in an audio service scenario.
[0073] Exemplarily, the business scenarios of the electronic device may include, but are not limited to: a display business scenario, an audio business scenario, and an input business scenario.
[0074] For example, see Figure 2 In the short video scene schematic diagram shown, the main interface 211 of the mobile phone 21 includes applications such as smart life, settings, calendar, short video 212 and gallery. After the user manually clicks on the short video 212, the mobile phone 21 responds to the click operation and displays the video playback interface 213, which is playing the corresponding short video. The user slides up in the video playback interface 213, and the mobile phone responds to the upward sliding operation and displays the video playback interface 214 to switch from one short video to another.
[0075] exist Figure 2 In the short video browsing scenario shown, when the mobile phone 21 needs to display the main interface 211, it first draws the image frame to obtain the image frame to be displayed, and then displays the image frame to be displayed to display the main interface 211 on the screen. The image frame drawing process may include but is not limited to canvas creation, view creation, rendering, and synthesis. In this process, the business scenario of the mobile phone 21 is the display business scenario, that is, the purpose of displaying the main interface 211 is achieved by drawing the image frame and displaying the image frame.
[0076] In the process of the mobile phone 21 switching the interface displayed on the screen from the main interface 211 to the video playback interface 213 in response to the click operation on the short video 212, the mobile phone 21 first detects the user's operation on the screen to obtain the user's input event, and then performs the corresponding action according to the input event. At this time, the mobile phone 21 is in the input business scenario. In addition, the mobile phone 21 also needs to render the image frame corresponding to the video playback interface 213 and send the image frame for display, so that the screen interface switches from the main interface 211 to the video playback interface 213. At this time, the mobile phone 21 is in the display business scenario.
[0077] Similarly, when the user slides upward on the video playback interface 213 and the mobile phone 21 displays the video playback interface 214, the user's input operation and the rendering and display of the image frame are involved. At this time, the mobile phone 21 is in the input business scenario and the display business scenario.
[0078] It is understandable that when the mobile phone 21 is playing the video playback interface 213 and the video playback interface 214, if the audio of the short video needs to be output, the mobile phone 21 is still in the audio service scenario.
[0079] A business path consists of at least one thread, and all threads on the business path are used to implement business scenarios. In order to implement business scenarios, multiple threads usually need to be executed. During the execution of these multiple threads, a thread execution path is formed from the starting thread to the final thread. This thread execution path can be regarded as the business path corresponding to the business scenario.
[0080] In some business scenarios, the business path does not distinguish between consumers and producers, and there is only one complete business path, and in this case there is only one end point of the business path. In some business scenarios, the business path distinguishes between consumers and producers, and in this case the complete business path includes the producer business path and the consumer business path, and the end point of the business path includes the end point of the producer business path and the end point of the consumer business path.
[0081] For example, suppose the complete business path of a business scenario is as follows Figure 1 As shown, the complete business path includes the producer business path and the consumer business path. The producer business path includes threads E, G and F, and the specific thread execution path is: thread F→thread G→thread F→thread E; the consumer business path includes threads A, B, C and D, and the specific thread execution path is: thread A→thread B→thread A→thread B→thread C→thread D→thread A. The producer business path and the consumer business path are connected through Buffer. The end point of the producer business path is queueBuffer, and the end point of the consumer business path is postBuffer.
[0082] Figure 1 The producers in the example may be a group of threads participating in rendering of an application program, used to generate (render) the required image frames; the consumers may be a group of threads of display services, used to consume the image frames produced by the producers.
[0083] It is understandable that the end point of a service path usually refers to the thread used to output data, not the last thread executed (in execution order). Figure 1 In the consumer business path, the last executed thread is thread A, but the end point of the consumer business path is thread D.
[0084] For business scenarios that include consumers and producers, the end point of the producer business path is the thread used to output data for the consumer, for example, Figure 1 The thread E in is used to output data for consumers; the end point of the consumer business path is the end perceived by the user, or it is the thread that outputs data for the device. For example, in the display business scenario, Figure 1 Thread D in is used to output data to a display device (eg, a display screen).
[0085] For business scenarios that do not include consumers and producers, the end point of the business path may refer to the end perceived by the user, or the thread that outputs data to the device. For example, in an audio business scenario, the end point of the business path may refer to the thread that outputs data to the audio device (such as a speaker).
[0086] In other words, the business path may also refer to: a thread execution sequence ending at a thread that outputs data.
[0087] The execution efficiency of threads affects the performance of electronic devices, especially key threads in some key business scenarios. In order to ensure the performance of electronic devices, electronic devices usually need to identify key threads and provide resource supply guarantee for key threads in a timely and effective manner through resource scheduling operations.
[0088] Generally, electronic devices can identify key threads through a thread name whitelist. The thread name whitelist includes multiple thread names. When the thread name of a certain thread is the same as a thread name in the thread name whitelist, the thread is a key thread. Conversely, when the thread name of a certain thread is different from all thread names in the thread name whitelist, the thread is not a key thread.
[0089] When identifying key threads based on the thread name whitelist, if the thread name whitelist is incomplete and has omissions, that is, the thread name whitelist does not cover the thread names of all key threads, and the thread names of some key threads are not included in the thread name whitelist, threads that were originally key threads cannot be identified as key threads, thereby causing missed identification of key threads.
[0090] After the thread name whitelist is set, if the thread name of a critical thread is changed to another name, but the thread name whitelist is not updated accordingly, the thread with the changed name cannot be identified as a critical thread, resulting in missed identification of the critical thread. In addition, if there is a thread name that is not a critical thread and is the same as the thread name of the critical thread, the thread name that is not a critical thread will be identified as a critical thread because the thread name exists in the thread name whitelist, resulting in misidentification of the critical thread.
[0091] That is to say, when identifying key threads based on the thread name whitelist, there will be problems such as missed identification and misidentification of key threads. Problems such as missed identification and misidentification of key threads will result in the failure to timely and effectively supply resources to key threads, resulting in priority flipping, causing system freezes and slow response speeds.
[0092] In response to the problems of missed identification and misidentification of key threads, the inventors found in the long-term research process that, whether it is an application upgrade or adjustment, or a system version upgrade, the end point of the business path corresponding to the business scenario is fixed. Moreover, for the same business scenario, the business path corresponding to the business scenario may not be exactly the same due to different applications, but the end point of the business path is the same and fixed. For example, for the display business scenario, although the business path of the browser and the business path of the video application partially overlap and are not exactly the same, the end points of their business paths are the same.
[0093] In addition, after the business path of each application is fixed, the wake-up relationship between each thread on the business path is determined, and thread name updates, duplicate thread names, and incomplete thread name whitelists do not affect the thread wake-up relationship.
[0094] Based on this, taking the end point of a relatively fixed business path as the basis, each thread on the business path is identified in turn through the thread wake-up relationship, and then all threads on the business path are completely identified, and all or part of the threads on the business path are used as key threads to achieve the identification of key threads, which can reduce the probability of misidentification and missed identification of key threads.
[0095] For example, suppose Figure 1 The producer is a group of threads involved in rendering in the application, the consumer is a group of threads for display services, and the business scenario is a display business scenario. The end point of the producer business path is queueBuffer, and the end point of the consumer business path is postBuffer. For the producer business path, it is known that the end point of the business path is thread E, and the thread wake-up relationship is known. Based on the known thread wake-up relationship and the end point of the business path, all threads on the business path can be identified. Exemplarily, the thread wake-up relationship is: thread F wakes up thread E, and thread F and thread G can wake each other up. Based on this, based on thread E and the thread wake-up relationship, it can be identified that thread F is on the producer business path; after identifying that thread F is on the producer business path, since thread F and thread G have a thread wake-up relationship, it can be identified that thread G is also on the producer business path. In this way, all threads on the producer business path can be identified.
[0096] Similarly, for the consumer business path, it is known that the end point of the business path is thread D, and the thread wake-up relationship is known. Thread D is used as the identification starting point, and all threads on the consumer business path are identified by deducing the thread wake-up relationship. Exemplarily, after determining that the end point of the business path is thread D, thread D is known, and since there is a thread wake-up relationship between thread D and thread A, it can be identified that thread A is on the consumer business path, and there is also a thread wake-up relationship between thread C and thread D, so thread C can also be identified as being on the consumer business path; after identifying thread C, since there is a thread wake-up relationship between thread C and thread B, it can be identified that thread B is also on the consumer business path, and then all threads on the consumer business path are identified. In this way, all threads on the complete business path can be identified, and the complete business path includes the producer business path and the consumer path.
[0097] In the resource supply scheme provided in the embodiment of the present application, the electronic device first identifies the current business scenario. If the current business scenario is the target business scenario, the end point of the target business path of the target business scenario is determined; then, based on the end point of the target business path, all threads on the target business path are identified through the thread wake-up relationship, and all threads or part of the threads on the target business path are regarded as critical threads, and resource supply guarantee operations are performed on these critical threads, so as to timely and effectively provide resource supply guarantee for the critical threads, thereby improving the user experience.
[0098] In the embodiments of the present application, the electronic device may be a mobile phone, a tablet computer, a wearable device, a personal computer, a vehicle-mounted device, an Internet of Things device, etc., and the specific type and structure of the electronic device are not limited herein.
[0099] For example, Figure 3A 1 shows a schematic diagram of the structure of the electronic device 100. The electronic device 100 may include a processor 110, a memory 120, an audio module 130, a speaker 130A, a receiver 130B, a microphone 130C, an earphone interface 130D, a sensor module 140, and a display screen 150. The sensor module 140 may include a touch sensor 140K and the like.
[0100] 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 certain components, or split certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware. For example, the electronic device 100 may also include at least one of the following: an antenna, a mobile communication module, a wireless communication module, a subscriber identification module (SIM) card interface, a universal serial bus (USB) interface, a charging management module, a power management module, a battery, a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, an ambient light sensor, and a bone conduction sensor, etc.
[0101] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a CPU, a GPU, and a controller. Different processing units may be independent devices or integrated into one or more processors. The controller may generate an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions.
[0102] In an embodiment of the present application, the CPU may be a multi-core processor integrating at least two processing cores. Generally, the processing cores may be divided into different levels according to their processing capabilities. For example, the processing core with the highest processing capability may be referred to as a large core, the processing core with the lowest processing capability may be referred to as a small core, and the processing core with a processing capability between the large core and the small core may be referred to as a medium core. The performance and power consumption of the large core are often higher than those of the small core. The operating frequency of the large core is also often higher than that of the small core, and the performance and power consumption of the medium core are between the large core and the small core.
[0103] In the embodiment of the present application, the multi-core processor includes at least one large core and at least one small core. Of course, the multi-core processor may also include at least one large core, at least one medium core and at least one small core.
[0104] In the embodiment of the present application, processor resources such as CPU and GPU are used as a hardware resource of the electronic device. When a process or thread is running, the electronic device 100 provides corresponding processor resources for the process or thread through a resource scheduling strategy, for example, scheduling the CPU large core, small core and operating frequency of the core where the process or thread is running.
[0105] 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 mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, and / or a universal serial bus (USB) interface, etc.
[0106] 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 140K and the like through different I2C bus interfaces. For example, the processor 110 may be coupled to the touch sensor 140K through the I2C interface, so that the processor 110 communicates with the touch sensor 140K through the I2C bus interface, thereby realizing the touch function of the electronic device 100.
[0107] 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 130 via the I2S bus to achieve communication between the processor 110 and the audio module 130.
[0108] The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 130 and the wireless communication module can be coupled via a PCM bus interface. In some embodiments, the audio module 130 can also transmit audio signals to the wireless communication module 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.
[0109] The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 150. The MIPI interface includes a display serial interface (DSI), etc. The processor 110 and the display screen 150 communicate through the DSI interface to realize the display function of the electronic device 100.
[0110] 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 display screen 150, the audio module 130, and the sensor module 140, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, and a MIPI interface, etc.
[0111] 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.
[0112] The electronic device 100 implements the display function through a GPU, a display screen 150, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 150 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.
[0113] The display screen 150 is used to display images, videos, etc. The display screen 150 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 150, where N is a positive integer greater than 1.
[0114] In an embodiment of the present application, when the electronic device 100 is in a display business scenario, the GPU, display screen 150, application processor, etc. can be used to perform processes such as drawing, rendering, and displaying image frames to realize the display business.
[0115] The memory 120 can be used to store computer executable program codes, which include instructions. The memory 120 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the memory 120 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. The processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the memory 120, and / or instructions stored in a memory provided in the processor.
[0116] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 130 , the speaker 130A, the receiver 130B, the microphone 130C, the headphone jack 130D, and the application processor.
[0117] The audio module 130 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 130 can also be used to encode and decode audio signals. In some embodiments, the audio module 130 can be arranged in the processor 110, or some functional modules of the audio module 130 can be arranged in the processor 110.
[0118] The speaker 130A, 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 130A.
[0119] The receiver 130B, 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 130B close to the human ear.
[0120] The microphone 130C, also called a "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 approaching the microphone 130C with his mouth to input the sound signal into the microphone 130C. The electronic device 100 can be provided with at least one microphone 130C. The headphone interface 130D is used to connect a wired headphone.
[0121] In an embodiment of the present application, when the electronic device 100 is in an audio service scenario, actions can be performed through the audio module 130, the speaker 130A, the receiver 130B, the microphone 130C, the headphone interface 130D, and the application processor to implement audio services.
[0122] The touch sensor 140K is also called a "touch control device". The touch sensor 140K can be set on the display screen 150, and the touch sensor 140K and the display screen 150 form a touch screen, also called a "touch control screen". The touch sensor 140K 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 150. In other embodiments, the touch sensor 140K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 150.
[0123] In the input service scenario of the embodiment of the present application, the user can perform input operations based on the touch screen of the electronic device 100, and the electronic device 100 provides corresponding output feedback in response to the input operations. It is understandable that in the input service scenario, in addition to inputting through the touch screen, the user can also input through other methods, such as voice input and key input.
[0124] An operating system runs on the electronic device 100, and the operating system may be an Android system, an IOS system, a Windows system, or a Hongmeng system, etc.
[0125] In some embodiments, the software system of the electronic device 100 may include a user state and a kernel state, and the user state and the kernel state include corresponding modules for implementing corresponding functions.
[0126] User state refers to the environment in which an application runs, which can only access its own memory space and limited system resources and can execute non-privileged instructions; it represents the tasks performed by the application.
[0127] Kernel state refers to: the environment in which the operating system runs, access to all resources, and the ability to execute all instructions (privileged and non-privileged instructions); tasks performed on behalf of the operating system.
[0128] Privileged instructions are instructions that can only be executed in kernel mode. These instructions can access and modify the system's hardware resources and memory. When an application needs to access system resources, it needs to switch from user mode to kernel mode through a system call, allowing the operating system to perform the corresponding operation on behalf of the application. After the operation is completed, it switches back from kernel mode to user mode to allow the application to continue executing.
[0129] For example, see Figure 3B The software system schematic block diagram of the electronic device 100 shown in the figure may include a user state and a kernel state, wherein the user state includes a scene recognition module and a gear decision module, and the kernel state includes a service path recognition module, an associated scheduling group and a resource guarantee module.
[0130] The scene recognition module is used to identify the business scene in which the electronic device 100 is located, and transmit the identified business scene information to the business path recognition module. Generally, the scene recognition module can identify the current business scene based on the user's operation scene. Business scenes may include but are not limited to: display business scenes, audio business scenes, and input business scenes.
[0131] The service path identification module is used to identify key threads on each service path.
[0132] For example, the business path identification module can determine the end point of the business path corresponding to the business scenario based on the business scenario information sent by the scenario identification module, and then identify all threads on the business path in sequence based on the thread wake-up relationship based on the end point of the business path to achieve identification of key threads.
[0133] The associated scheduling group is used to set the key threads on the business path to the same associated scheduling group. One business path corresponds to one associated scheduling group.
[0134] The gear decision module is used to determine the resource supply gear according to the system frame rate, and when the frame rates at the producer and consumer ends are inconsistent, it makes a decision based on the smaller frame rate at both ends. The determined resource supply gear is passed to the resource guarantee module.
[0135] The resource guarantee module is used to supply resources to the key threads in the associated scheduling group according to the resource supply gear, so as to guarantee the software resources and hardware resources of the key threads in the associated scheduling group. For example, through resource guarantee operations such as scheduling priority, memory allocation, I / O bandwidth, processor core selection and device frequency improvement, the resources of the key threads can be guaranteed in a timely and effective manner.
[0136] It should be pointed out that Figure 3B The software system shown is only an example. In specific applications, the modules in the software system can be appropriately increased or decreased according to different situations. In addition, the functions of the modules in the software system can also be adaptively adjusted.
[0137] For example, when it is not necessary to make resource gear decision based on the smaller frame rate of both ends, the software system may not include the gear decision module. For another example, when it is not necessary to create an associated scheduling group, the software system may not include the associated scheduling group.
[0138] The technical solution provided in the embodiment of the present application is introduced and explained below by taking the electronic device 100 as an example.
[0139] See also Figure 4 , is a schematic flow chart of a resource provision method provided in an embodiment of the present application, and the method may include the following steps:
[0140] Step S401: If the electronic device is in a target business scenario, the electronic device 100 determines a target thread of the target business scenario. The target thread is a thread for outputting data.
[0141] The target business scenario refers to a specific business scenario that is set in advance. Usually, a business scenario that is user-perceivable and has high requirements for immediacy is set as the target business scenario, so that the key threads under the target business scenario can be supplied with resources in a timely and effective manner to ensure the user experience. Exemplarily, the target business scenario is a display business scenario, an audio business scenario, or an input business scenario.
[0142] It is understandable that the electronic device 100 may be in at least one target service scenario at the same time. Figure 2 As shown, when a user uses mobile phone 21 to browse short videos, if the user does not swipe up or down on the short video playback interface to switch short videos, and mobile phone 21 is in silent mode, mobile phone 21 may only involve the display business scenario; if the user swipes up or down on the short video playback interface to switch short videos, and mobile phone 21 plays the audio corresponding to the short video, mobile phone 21 may simultaneously involve the display business scenario, the audio business scenario and the input business scenario.
[0143] When the electronic device 100 is in at least one target business scenario, resources are supplied for each target business scenario respectively. That is, for each target business scenario, the end point of the target business path corresponding to the target business scenario is first determined, and then based on the end point of the target business path, all threads on the target business path are identified through the thread wake-up relationship to identify the complete business path corresponding to the target business scenario.
[0144] In a specific application, the electronic device 100 may first identify the current business scenario, and then determine whether the current business scenario is a preset target business scenario; if it is determined that the current business scenario is the target business scenario, it is determined to be in the target business scenario.
[0145] In some embodiments, the electronic device 100 can identify the current business scenario based on user operations and the current state. User operations refer to the operations of the user using the electronic device 100, and the current state refers to the device state (working state and non-working state, etc.) of the electronic device 100. In the process of performing corresponding actions in response to user operations, the electronic device 100 detects the devices and events involved in the current response action. For example, when the user inputs an up-slide operation to the electronic device 100, the electronic device 100 detects the input event and the frame sending event, and detects that the audio device (microphone and speaker, etc.) is in a working state, then it can be determined that the current business scenario includes a display business scenario, an audio business scenario, and an input business scenario. The embodiment of the present application does not limit the method for identifying business scenarios.
[0146] For example, the electronic device 100 may Figure 3B The scene recognition module shown performs scene recognition and determines the end point of the service path through service path recognition.
[0147] After the electronic device 100 identifies that it is currently in the target business scenario, it determines the target thread of the target business scenario. The target thread may refer to the end point of the business path. In the target business scenario, the target thread refers to the end point of the target business path, and the target business path refers to the business path corresponding to the target business scenario. The business path is a thread execution sequence with the thread for outputting data (i.e., the target thread) as the end point. For example, in Figure 1 In the scenario shown, the producer's target thread is thread E, and the consumer's target thread is thread D.
[0148] In the embodiment of the present application, the end point of the business path has the same meaning as the target thread. In the above and below related discussions, the end point of the business path is used in some places and the target thread is used in some places, but it should be understood that the meanings of the two descriptions are the same.
[0149] Optionally, a first correspondence may be preset, the first correspondence being a correspondence between a business scenario and a thread (end point of a business path). After identifying the target business scenario, the electronic device 100 determines the end point of the target business path corresponding to the target business scenario according to the first correspondence.
[0150] Exemplarily, the first corresponding relationship may be as shown in Table 1 below.
[0151] Table 1
[0152] Business Scenario Thread (end point of the business path) Display business scenarios First Thread Audio service scenario Second Thread
[0153] The first correspondence may be preset manually, that is, the end point of the business path corresponding to each business scenario is manually set, and the first correspondence may be persistently stored in the local storage space of the electronic device 100. In this way, after the electronic device 100 identifies the target business scenario, it may obtain the first correspondence from the local storage space, and then determine the end point of the target business path, that is, determine the target thread corresponding to the target business scenario, through the first correspondence.
[0154] It should be noted that when the target business path corresponding to the target business scenario includes consumers and producers, the end point of the target business path corresponding to the target business scenario includes the end point of the producer business path and the end point of the consumer business path, that is, the target thread includes the target thread of the producer and the target thread of the consumer. For example, in Figure 1 In the scenario shown, the producer's target thread (the end point of the producer's business path) is thread E, and the consumer's target thread (the end point of the producer's business path) is thread D. When the target business path corresponding to the target business scenario does not distinguish between consumers and producers, there is only one end point of the target business path.
[0155] The end point of the target business path is fixed. The business path may not be completely consistent for different applications, but the end point of the business path is fixed. In addition, the end point of the business path is consistent before and after application business upgrades or adjustments, and system version upgrades.
[0156] Step S402: The electronic device 100 identifies other threads of the target business scenario based on the target thread through the thread wake-up relationship, and determines some or all threads of the target business scenario as key threads. That is, the electronic device 100 can determine all threads on the target business path through the thread wake-up relationship based on the end point of the target business path to identify the complete business path corresponding to the target business scenario. The target business path is a path including all threads used to implement the target business scenario, and all or some threads on the target business path are key threads.
[0157] The threads of the target business scenario include the target thread of the target business scenario and other threads of the target business scenario, that is, the threads involved in the target business scenario include the target thread and other threads identified based on the target thread through thread wakeup relationships. Figure 1 In the scenario shown, the target thread of the consumer is thread D. Based on thread D, other threads identified through thread wakeup relationships include thread A, thread B, and thread C.
[0158] It is understandable that when the end point of the target business path includes the end point of the producer business path and the end point of the consumer business path, the electronic device 100 can determine all producer threads on the producer business path through the thread wake-up relationship based on the end point of the producer business path; and determine all consumer threads on the consumer business path through the thread wake-up relationship based on the end point of the consumer business path, so as to identify all threads on the complete target business path corresponding to the target business scenario. Among them, all threads on the target business path include all producer threads and all consumer threads.
[0159] In other words, the target thread includes the producer's target thread and the consumer's target thread. At this time, the electronic device 100 can determine other threads of the producer of the target business scenario through the thread wake-up relationship based on the producer's target thread; and determine other threads of the consumer of the target business scenario through the thread wake-up relationship based on the consumer's target thread; wherein the other threads of the target business scenario include other threads of the producer and other threads of the consumer.
[0160] For example, Figure 1 As shown, the end point of the producer business path is queueBuffer, and the end point of the consumer business path is postBuffer. For the end points of the producer business path and the consumer business path, all threads on the producer business path and the consumer business path are deduced and identified through the thread wake-up relationship. For the specific process, please refer to the corresponding content above, which will not be repeated here. The target thread of the producer is thread E, and the other threads of the producer identified by the thread wake-up relationship include thread F and thread G; similarly, the target thread of the consumer is thread D, and the other threads of the consumer identified by the thread wake-up relationship include thread A, thread B and thread C.
[0161] When the target service path has only one endpoint, the electronic device 100 can determine all threads on the complete target service path based on the endpoint through the thread wakeup relationship. That is, when the target service scenario does not involve consumers and producers, the target service scenario has only one target thread, and other threads can be identified based on the target thread through the thread wakeup relationship.
[0162] It is worth pointing out that based on the end point of the target business path, all threads on the complete target business path are identified through the thread wake-up relationship, and all threads or part of the threads on the complete target business path are used as key threads to realize the identification of key threads. In this way, the key threads can be accurately identified in cases where the thread names are the same or the thread names are updated, and misidentification and missed identification will not occur. In addition, since the thread name whitelist is not involved in the key thread identification process, the key threads can be accurately identified even if the thread name whitelist is incomplete.
[0163] It is also worth pointing out that when the application business is adjusted or upgraded, or the system version is upgraded, the configuration of the thread name whitelist and other configurations will change, which will make the solution for key thread identification based on the thread name whitelist invalid. The key thread identification solution needs to be re-adapted, but the adaptation workload is large and the adaptation difficulty is relatively large.
[0164] In addition, when the business architecture of display business, audio business, input business, etc. is adjusted, the method of identifying key threads based on thread name whitelist and other methods also requires additional adaptation work.
[0165] The embodiment of the present application is based on the end point of the target business path (i.e., the target thread of the target business scenario), and uses the thread wake-up relationship to identify the key thread. Before and after the application business is adjusted or upgraded and the system version is upgraded, the end point of the business path (i.e., the target thread) will not change. Therefore, after the application business is adjusted and the system version is upgraded, as well as after the business architecture of the display business, audio business, and input business is adjusted, the key thread identification solution can still be applied without additional adaptation work, and the solution has high versatility.
[0166] Step S403: The electronic device 100 adjusts the resource supply of the key thread, wherein the resource supply after the adjustment is stronger than the resource supply before the adjustment.
[0167] It is understandable that the execution efficiency of the key thread is related to the performance of the electronic device 100, such as the system fluency and response speed. In order to ensure the performance of the electronic device 100, it is usually necessary to enhance the resource supply of the key thread, thereby ensuring the resource supply of the key thread. In the embodiment of the present application, resource supply can have the same meaning as resource scheduling, that is, by scheduling resources for the key thread, the resource supply of the key thread can be guaranteed.
[0168] Resource supply operation refers to the operation of scheduling at least one resource such as CPU, GPU, memory, and I / O through resource scheduling strategy, and ensuring the supply of resources to key threads. Exemplarily, resource supply adjustment may include but is not limited to at least one of the following resource adjustment methods: increasing scheduling priority, memory priority allocation (increasing memory allocation priority), I / O bandwidth guarantee, giving priority to medium and large cores (increasing the probability of switching to medium and / or large cores), and device frequency increase. Among them, I / O bandwidth guarantee may refer to guaranteeing the I / O bandwidth size of key threads, and specifically, the I / O bandwidth size of key threads may be guaranteed by controlling the I / O bandwidth size of other threads.
[0169] When the electronic device 100 adjusts the resource supply of the key thread, the resource supply of the key thread may be adjusted according to the resource adjustment method of each key thread.
[0170] It is understandable that a thread has one or at least two business logics. Not all business logics in key threads are related to the target business scenario, that is, not all business logics affect the performance experience. For business logic in key threads that affects the performance experience, resource scheduling can be used to achieve accurate resource guarantees, while for business logic in key threads that does not affect the performance experience, resource scheduling and supply guarantees may not be performed.
[0171] That is to say, when resources are supplied to key threads, only the business logic in the key threads related to the target business scenario may be scheduled and supplied with resources, while the business logic in the key threads that is not related to the target business scenario may not be scheduled and supplied with resources.
[0172] It should be noted that accurate identification of critical threads can reduce the occurrence of problems such as system freezes and slow response speeds. Figure 1 In the consumer business path shown, if the key thread is identified based on the thread name whitelist, thread C is not identified as a key thread due to reasons such as thread C's thread name being updated or thread C's thread name being omitted from the thread name whitelist. When resources are supplied to key threads, although threads A, B, and D on the consumer business path can be supplied with resources in a timely and effective manner, thread C is not identified as a key thread, and the resource supply to thread C is not guaranteed in a timely and effective manner, making thread C the "shortest plank" in the barrel effect, resulting in a phenomenon similar to priority flipping, causing problems such as system freezes and slow response speeds.
[0173] It can be seen that the embodiment of the present application is based on a relatively fixed business path endpoint, and accurately identifies key threads through thread wake-up relationships, thereby reducing the probability of misidentification and missed identification of key threads, thereby reducing the occurrence of problems such as system freezes and slow response speeds, and improving user experience.
[0174] Based on the above Figure 4 In an embodiment, after the electronic device 100 accurately identifies the critical thread according to the end point of the business path and the thread wake-up relationship, it can place all or part of the critical threads on the target business path in an associated scheduling group, and supply resources to all threads on the complete business path in units of the associated scheduling group.
[0175] See also Figure 5 Another schematic flow chart of a resource provision method provided in an embodiment of the present application is shown. In this case, the resource provision method may include the following steps:
[0176] Step S501: If the electronic device is in a target business scenario, the electronic device 100 determines a target thread of the target business scenario, that is, the electronic device 100 determines an end point of a target business path of the target business scenario.
[0177] Step S502, the electronic device 100 identifies other threads of the target business scenario through the thread wake-up relationship based on the target thread, and determines some or all of the threads of the target business scenario as key threads. The threads of the target business scenario include the target thread of the target business scenario and other threads of the target business scenario. That is, the electronic device 100 determines all threads on the target business path through the thread wake-up relationship based on the end point of the target business path to identify the complete business path corresponding to the target business scenario. The target business path is a path including all threads used to implement the target business scenario, and all or some of the threads on the target business path are key threads.
[0178] It can be understood that steps S501 to S502 are similar to steps S401 to S402 described above. Please refer to the above for detailed description, which will not be repeated here.
[0179] Step S503: The electronic device 100 creates an associated scheduling group including all key threads.
[0180] All key threads on the complete target business path are placed in an associated scheduling group. Threads in the same associated scheduling group have the same importance and the same resource supply guarantee.
[0181] Step S504: After determining the first resource supply amount of the associated scheduling group, the electronic device 100 adjusts the resource supply of each key thread of the associated scheduling group according to the first resource supply amount and the resource adjustment method of the key thread.
[0182] For example, see Figure 6 The schematic diagram of the associated scheduling group and resource adjustment method is shown in FIG. Figure 1 After all threads on the complete business path of the scenario shown in the figure are placed in an associated scheduling group, the following is obtained: Figure 6 The associated scheduling group shown includes thread B, thread C, thread D, thread A, thread E, thread G and thread F. The resource supply mode set exemplarily includes resource supply modes 1 to 5.
[0183] For all threads in the associated scheduling group, select the appropriate resource adjustment method from the resource adjustment method set according to the needs of the thread. For example, if thread B does not involve I / O bandwidth, then select method 1 and method 2 as the resource adjustment method for thread B; if thread E involves memory, I / O bandwidth and device frequency, then select method 2, method 3 and method 5 as the resource adjustment method for thread E.
[0184] That is to say, Figure 6 The associated scheduling group on the left includes all or part of the threads on the complete business path. The resource adjustment method set on the right is an optional optimization item. According to the needs of each thread, you can select the appropriate resource adjustment method from the resource adjustment method set to ensure resource supply for each thread.
[0185] Of course, in other embodiments of the present application, after the electronic device 100 accurately identifies the critical thread based on the end point of the business path and the thread wake-up relationship, it may not place all or part of the threads on the complete business path in an associated scheduling group and supply resources on a group basis, but instead perform separate resource supply operations on each critical thread or part of the critical threads (for example, threads on the producer business path or the consumer business path).
[0186] However, in comparison, when supplying resources to key threads, if resources are supplied separately to each thread or part of the threads on the complete business path, the importance of each thread on the same business path is inconsistent, and the strength of resource supply guarantee is inconsistent, resulting in a "barrel effect", and then problems such as system freezes and slow response speeds caused by priority flipping.
[0187] By supplying resources to all threads in the complete business path in units of associated scheduling groups, all threads are in the same associated scheduling group, and the importance of each thread is the same, so the resource supply guarantee is consistent. This can reduce the probability of system freezes due to priority flipping and other phenomena, and further improve the user experience.
[0188] In the above step S504, the electronic device 100 may first determine the first resource supply amount of the entire associated scheduling group, and then supply resources according to the resource adjustment method of each thread based on the first resource supply amount.
[0189] In an optional implementation, for a business scenario that does not include producers and consumers, and for a business scenario that includes producers and consumers and the frame rates at both ends of the producer and consumer are consistent, the electronic device 100 can first obtain the frame rate, and then determine the resource supply corresponding to the system frame rate based on the correspondence between the frame rate and the resource supply, and then determine the first resource supply of the entire associated scheduling group.
[0190] For business scenarios including producers and consumers, the frame rates of the producers and consumers are inconsistent, and the electronic device 100 can obtain the frame rate of the producer and the frame rate of the consumer respectively, and then determine the resource supply corresponding to the producer's frame rate according to the corresponding relationship between the frame rate and the resource supply, and then determine the resource supply corresponding to the producer's business path, determine the resource supply corresponding to the consumer's frame rate, and then determine the resource supply corresponding to the consumer's business path. At this time, in the process of ensuring the resource supply of key threads, according to the resource supply corresponding to the producer's business path, the corresponding resource adjustment method is used to ensure the resource supply of the producer's thread; according to the resource supply corresponding to the consumer's business path, the corresponding resource adjustment method is used to ensure the resource supply of the consumer's thread.
[0191] Alternatively, when the frame rates at both ends of the producer and the consumer are inconsistent, the electronic device 100 obtains the frame rate of the producer and the frame rate of the consumer respectively, and determines the larger of the frame rate of the producer and the frame rate of the consumer as the target frame rate, and determines the resource supply corresponding to the target frame rate based on the correspondence between the frame rate and the resource supply, and then determines the first resource supply of the entire associated scheduling group.
[0192] In another optional implementation, when the target business scenario is a business scenario including producers and consumers, and the frame rates at both ends of the producer and the consumer are inconsistent, the electronic device 100 can first obtain the first frame rate of the producer and the second frame rate of the consumer, and then determine the lower frame rate between the first frame rate and the second frame rate as the first target frame rate, and finally, based on the second corresponding relationship, determine the resource supply corresponding to the first target frame rate as the first resource supply, and then determine the resource supply of the entire associated scheduling group.
[0193] The second corresponding relationship is the corresponding relationship between the frame rate and the resource supply. Exemplarily, the resource supply is specifically expressed as a resource supply gear, and the high and low resource supply gears correspond to the high and low resource supply. At this time, the second corresponding relationship can be shown in Table 2 below.
[0194] Table 2
[0195] Frame rate1 Frame rate 2 Frame rate 3 Scheduling Priority Gear 1 Gear 2 Gear 3 Memory priority allocation Gear 1 Gear 2 Gear 3 I / O bandwidth Gear 1 Gear 2 Gear 3 Prioritize medium and large cores Gear 1 Gear 2 Gear 3 Device frequency Gear 1 Gear 2 Gear 3
[0196] As shown in Table 2 above, frame rate 1, frame rate 2 and frame rate 3 correspond to gear 1, gear 2 and gear 3 respectively. Assume that frame rate 1 < frame rate 2 < frame rate 3, gear 1 < gear 2 < gear 3. The higher the gear, the greater the resource supply. For example, see Figure 7 The diagram shows the relationship between resource supply and running time. The vertical axis represents the resource supply, and the horizontal axis represents the running time. Frame rate 3 is the largest, and the resource supply grows the fastest; frame rate 1 is the smallest, and the resource supply grows the slowest; frame rate 2 is between frame rate 3 and frame rate 1, and the resource supply growth rate is also between the resource supply growth rates of frame rate 3 and frame rate 1.
[0197] Table 2 may also be the correspondence between the frame rate and the resource supply mentioned above. However, in actual applications, the correspondence between the frame rate and the resource supply in different situations is not exactly the same. In different correspondences, the resource supply corresponding to the same frame rate may be different.
[0198] It can be understood that in the same associated scheduling group, the same second corresponding relationship is adopted, so that the resource supply amount of each key thread in the group is consistent under each gear, thereby ensuring that the resource guarantee strength of each key thread in the group is consistent.
[0199] It is worth pointing out that by taking the smaller one between the first frame rate and the second frame rate as the target frame rate and determining the resource supply amount according to the target frame rate, resource waste can be avoided as much as possible.
[0200] For example, assuming that the producer produces at a frame rate of 60 frames and the consumer consumes at a frame rate of 120 frames, if resources are supplied at a target frame rate of 120 frames, the consumer will only be able to obtain the image frame produced by the producer for consumption once, resulting in a waste of resources for the consumer to obtain resources, and thus resulting in resource waste due to oversupply of resources. However, when the embodiment of the present application supplies resources at a target frame rate of 60 frames, the consumer will not perform an invalid resource-taking action, thus avoiding resource waste due to oversupply of resources.
[0201] In this implementation, when the target business scenario is a business scenario that does not include producers and consumers, and the frame rates of producers and consumers are consistent, the resource supply amount of the associated scheduling group can be determined by referring to the above optional implementation.
[0202] It can be seen that when resources are supplied in units of associated scheduling groups, decisions are made based on the smaller frame rate between the producer and consumer ends to provide different resource supply amounts at different frame rates, that is, to provide different resource supply intensities. This can not only improve the smoothness under high frame rate conditions, but also avoid resource waste caused by oversupply of resources as much as possible.
[0203] After determining the resource supply of the associated scheduling group, the electronic device 100 can ensure resource supply according to the determined resource supply and resource adjustment method. For example, assuming that the determined resource supply gear is gear 2, for thread B, its resource adjustment methods are method 1 and method 2. When performing resource supply according to method 1 and method 2, the resource adjustment strength of gear 2 is used for resource supply.
[0204] As shown above, when the embodiment of the present application uses the associated scheduling group as a unit to ensure the resource supply of all threads or some threads on the complete business path, when the target business scenario is a business scenario including producers and consumers, and the frame rates of the producer and consumer are inconsistent, the smaller frame rate between the two ends is used for decision making to determine the resource supply amount of the associated scheduling group, that is, to determine the resource supply strength. Figure 8 Provide an introduction and explanation.
[0205] See also Figure 8 , is another schematic flow chart of a resource provisioning method provided in an embodiment of the present application, and the method may include the following steps:
[0206] Step S801: If the electronic device is in a target business scenario, the electronic device 100 determines a target thread of the target business scenario, that is, the electronic device 100 determines an end point of a target business path of the target business scenario.
[0207] Step S802, the electronic device 100 identifies other threads of the target business scenario based on the target thread through the thread wake-up relationship, and determines some or all of the threads of the target business scenario as key threads. That is, the electronic device 100 determines all threads on the target business path based on the end point of the target business path through the thread wake-up relationship to identify the complete business path corresponding to the target business scenario. The target business path is a path including all threads used to implement the target business scenario, and all or some threads on the target business path are key threads.
[0208] Step S803: The electronic device 100 creates an associated scheduling group including all key threads.
[0209] Step S804: The electronic device 100 obtains the first frame rate of the producer and the second frame rate of the consumer.
[0210] Step S805: The electronic device 100 determines the smaller one between the first frame rate and the second frame rate as the first target frame rate.
[0211] Step S806: The electronic device 100 determines the resource supply amount corresponding to the first target frame rate as the first resource supply amount according to the second corresponding relationship, where the second corresponding relationship is the corresponding relationship between the frame rate and the resource supply amount (or resource supply gear).
[0212] Step S807: The electronic device 100 adjusts the resource supply of each key thread according to the first resource supply amount and the resource adjustment method of the key thread.
[0213] It should be noted that for the relevant introduction of this embodiment, please refer to the relevant content above, which will not be repeated here.
[0214] The electronic device 100 can detect the real-time frame rate through the probe, and then make a decision based on the frame rate to obtain the resource supply of the associated scheduling group. Fig. 9 The schematic diagram of the dynamic frame rate decision process is shown, in which the electronic device 100 obtains the real-time frame rate of the producer through the producer frame rate probe, obtains the real-time frame rate of the consumer through the consumer frame rate probe, and then makes a resource supply gear decision based on the real-time frame rates at both ends of the producer and the consumer. Finally, the decided resource supply gear is issued to supply resources according to the resource supply gear.
[0215] Among them, in the resource supply gear decision process, the smaller frame rate of the producer and consumer ends is first determined, and based on the corresponding relationship between the frame rate and the resource supply gear, the resource supply gear corresponding to the smaller frame rate at both ends is determined.
[0216] In the process of sending resource supply gears, the resource supply gears can be sent to the corresponding execution mechanism according to the resource supply method. The execution mechanism is the mechanism that executes the resource supply action. The consumption end points are different, and the sent end points (execution mechanisms) cannot be different. Exemplarily, when the resource supply method is to increase the scheduling priority, the resource supply gear is sent to the kernel, and the kernel schedules the priority of the key thread according to the sent resource supply gear. When the resource supply method is memory priority allocation, the resource supply gear is sent to the memory allocator, and the memory allocator allocates memory for the key thread according to the resource supply gear. When the resource supply method is to increase the device frequency, the resource supply gear is sent to the corresponding device to increase the device frequency to the corresponding gear.
[0217] It can be seen that in this Figure 8In the illustrated embodiment, based on the end point of the service path, all threads on the complete service path are accurately identified through the thread wake-up relationship, so as to accurately identify the key threads, reduce the probability of misidentification and missed identification of the key threads, and improve the user experience; further, all the identified key threads are placed in the same associated scheduling group, and resources are supplied to all threads on the complete service path on a group basis, thereby reducing the probability of system freezes due to priority flipping and the like, and further improving the user experience; further, in the process of ensuring resource supply for all threads on the complete service path on a group basis, the resource supply amount is determined based on the smaller of the frame rates at both ends for the case where the frame rates at both ends are inconsistent, thereby avoiding resource waste due to oversupply as much as possible.
[0218] Based on the above Figure 4 In an embodiment, after the electronic device 100 accurately identifies the critical thread according to the endpoint of the service path and the thread wake-up relationship, it is also possible to supply resources to all threads on the complete service path without using the associated scheduling group as a unit.
[0219] At this time, when the electronic device 100 supplies resources to the critical thread, if the target business scenario is a business scenario including producers and consumers, and the frame rates of the producers and consumers may be inconsistent, a decision can be made based on the smaller of the frame rates at both ends to determine the amount of resources supplied to the critical thread.
[0220] See also Fig.10 , is another schematic flow chart of a resource provisioning method provided in an embodiment of the present application, and the method may include the following steps:
[0221] Step S1001: If the electronic device is in a target business scenario, the electronic device 100 determines a target thread of the target business scenario, that is, the electronic device 100 determines an end point of a target business path of the target business scenario.
[0222] Step S1002, the electronic device 100 identifies other threads of the target business scenario based on the target thread through the thread wake-up relationship, and determines some or all of the threads of the target business scenario as key threads. That is, the electronic device 100 determines all threads on the target business path through the thread wake-up relationship based on the end point of the target business path to identify the complete business path corresponding to the target business scenario. The target business path is a path including all threads used to implement the target business scenario, and all or some threads on the target business path are key threads.
[0223] Step S1003: The electronic device 100 obtains the third frame rate of the producer and the fourth frame rate of the consumer.
[0224] Step S1004: The electronic device 100 determines the smaller one between the third frame rate and the fourth frame rate as the second target frame rate.
[0225] Step S1005, the electronic device 100 determines, for each key thread, according to the third correspondence of the key threads, that the resource supply corresponding to the second target frame rate is the second resource supply, and adjusts the resource supply of the key thread according to the second resource supply and the resource adjustment method of the key thread, where the third correspondence is the correspondence between the frame rate and the resource supply.
[0226] In this embodiment, each key thread has its own third corresponding relationship, and each third corresponding relationship is different. For example, in the third corresponding relationship of key thread A, the resource supply corresponding to frame rate A is resource supply A, and in the third corresponding relationship of key thread B, the resource supply corresponding to frame rate A is resource supply B. Resource supply A and resource supply B are different, that is, the second target frame rate is the same, but since the third corresponding relationships of each key thread are different, the resource supply corresponding to the second target frame rate of each key thread may be different.
[0227] It is understandable that the resource adjustment method of the critical thread can be determined according to the needs of the critical thread.
[0228] It should be noted that the similarities and differences between this embodiment and the above embodiments can be found in the above related contents and will not be repeated here.
[0229] It can be understood that for business scenarios that do not include producers and consumers, and for business scenarios that include producers and consumers and the frame rate on both ends of the producer and consumer is consistent, the resource supply of the key thread can be determined based on the correspondence between the frame rate and the resource supply.
[0230] It can be seen that in Fig.10 In the illustrated embodiment, based on the end point of the business path, all threads on the complete business path are accurately identified through thread wake-up relationships, so as to accurately identify the key threads, reduce the probability of misidentification and missed identification of the key threads, and improve the user experience; further, in the process of supplying resources to the key threads, in view of the inconsistent frame rates at both ends of the producer and consumer, the resource supply amount is determined according to the smaller of the frame rates at both ends, thereby avoiding resource waste due to oversupply of resources as much as possible.
[0231] In the embodiment shown above, when the electronic device 100 identifies the critical thread, it identifies all threads on the complete business path in sequence based on the end point of the business path through the thread wake-up relationship, which can reduce the probability of misidentification and missed identification of the critical thread. In other embodiments of the present application, the electronic device 100 can also adopt other critical thread identification methods, and after identifying the critical thread, it can provide resources to the critical thread.
[0232] See also Fig.11 , is another schematic flow chart of a resource provisioning method provided in an embodiment of the present application, and the method may include the following steps:
[0233] Step S1101: The electronic device 100 determines a critical thread.
[0234] In addition to identifying key threads based on the end point of the business path and the thread wake-up relationship mentioned above, the electronic device 100 can also identify key threads through thread name whitelists, etc., or through other methods. The method of identifying key threads is not limited here.
[0235] Step S1102: The electronic device 100 obtains the fifth frame rate of the producer and the sixth frame rate of the consumer.
[0236] Specifically, the electronic device 100 may detect the frame rates of the producer and consumer ends respectively through the consumer probe and the producer probe.
[0237] Step S1103: The electronic device 100 determines the smaller one between the fifth frame rate and the sixth frame rate as the third target frame rate.
[0238] Step S1104, the electronic device 100 determines, for each key thread, according to the fourth correspondence of the key threads, that the resource supply corresponding to the third target frame rate is the third resource supply, and adjusts the resource supply of the key thread according to the third resource supply and the resource adjustment method of the key thread, where the fourth correspondence is the correspondence between the frame rate and the resource supply.
[0239] For the introduction of the fourth corresponding relationship, please refer to the corresponding content of the third corresponding relationship above, which will not be repeated here. At this time, each key thread has its own fourth corresponding relationship.
[0240] It can be seen that in Fig.11 In the illustrated embodiment, during the process of supplying resources to the critical thread, in view of the inconsistent frame rates between the producer and the consumer, the resource supply amount is determined based on the smaller of the frame rates at both ends, thereby avoiding resource waste due to oversupply as much as possible.
[0241] based on Fig.11In the embodiment shown, after determining the critical thread, the electronic device 100 can also create an associated scheduling group including all critical threads, and put all identified critical threads on the complete business path into the same associated scheduling group. At this time, the third resource supply of the associated scheduling group is determined according to the above steps S1101 to S1103. The associated scheduling group only corresponds to one fourth corresponding relationship, and the third resource supply of each critical thread is the same. In the process of performing resource supply guarantee operations on the critical threads according to the third resource supply, the critical threads can be supplied with resources in units of associated scheduling groups, that is, for each critical thread, the resource supply method corresponding to the critical thread is determined, and the resource supply operation is performed on the critical thread according to the third resource supply method. In this way, supplying resources in groups can reduce the probability of system freezes caused by priority flipping and other phenomena, and further improve the user experience.
[0242] Corresponding to the method of the above embodiment, Fig.12 The structure block diagram of the electronic device 100 provided by the embodiment of the present application is shown. For the convenience of description, only the parts related to the embodiment of the present application are shown.
[0243] Reference Fig.12 , the electronic device 100 may include a scene recognition module 1210 , a key thread recognition module 1220 and a resource supply module 1230 .
[0244] Among them, the scene recognition module is used to identify the business scene of the electronic device; the key thread recognition module is used to determine the target thread of the target business scene if the electronic device is in the target business scene, and the target thread is a thread used to output data; based on the target thread, other threads of the target business scene are identified through thread wake-up relationships; some or all threads of the target business scene are determined as key threads; and the resource supply module is used to adjust the resource supply of the key thread, wherein the adjusted resource supply is stronger than the resource supply before the adjustment.
[0245] In a possible implementation, the key thread identification module 1220 is specifically used to: determine a target thread corresponding to a target business scenario according to a first corresponding relationship, where the first corresponding relationship is a corresponding relationship between a business scenario and a target thread.
[0246] In a possible implementation manner, the target service scenario is a display service scenario, an audio service scenario, or an input service scenario.
[0247] In a possible implementation, if the target business scenario is a business scenario including a producer and a consumer, the target thread includes a target thread of the producer and a target thread of the consumer;
[0248] The key thread identification module 1220 is specifically used to: determine other threads of the producer of the target business scenario through thread wake-up relationships based on the target thread of the producer; determine other threads of the consumer of the target business scenario through thread wake-up relationships based on the target thread of the consumer; wherein the other threads of the target business scenario include other threads of the producer and other threads of the consumer.
[0249] In a possible implementation, the resource supply module 1230 is specifically configured to adjust the resource supply of each key thread according to the resource adjustment mode of each key thread.
[0250] In a possible implementation, the resource supply module 1230 is specifically used to: create an associated scheduling group including all key threads; determine a first resource supply amount of the associated scheduling group; for each key thread, adjust the resource supply of the key thread according to the first resource supply amount and the resource adjustment method of the key thread. In a possible implementation, if the target business scenario is a business scenario including producers and consumers, the resource supply module 1230 is specifically used to: obtain a first frame rate of the producer and a second frame rate of the consumer; determine a first target frame rate, the first target frame rate being a lower frame rate between the first frame rate and the second frame rate; according to a second corresponding relationship, determine that the resource supply amount corresponding to the first target frame rate is the first resource supply amount, and the second corresponding relationship is the corresponding relationship between the frame rate and the resource supply amount.
[0251] In one possible implementation, if the target business scenario is a business scenario including producers and consumers, the resource supply module 1230 is specifically used to: obtain the third frame rate of the producer and the fourth frame rate of the consumer; determine a second target frame rate, which is a lower frame rate between the third frame rate and the fourth frame rate; for each key thread, according to the third corresponding relationship of the key thread, determine the resource supply corresponding to the second target frame rate as the second resource supply, and according to the second resource supply and according to the resource adjustment method of the key thread, adjust the resource supply of the key thread, the third corresponding relationship being the corresponding relationship between the frame rate and the resource supply.
[0252] In one possible implementation, the resource adjustment method includes at least one of the following: increasing scheduling priority, increasing memory allocation priority, I / O bandwidth guarantee, increasing the probability of switching to medium cores and / or large cores, and increasing device frequency.
[0253] The electronic device 100 has the function of implementing the resource supply method, which can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions, and the modules can be software and / or hardware.
[0254] It should be noted that the information interaction, execution process and other contents between the above-mentioned modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0255] Corresponding to the method of the above embodiment, Fig.13 The structure block diagram of the electronic device 100 provided by the embodiment of the present application is shown. For the convenience of description, only the parts related to the embodiment of the present application are shown.
[0256] Reference Fig.13 The electronic device 100 may include a critical thread identification module 1310 , a resource supply amount decision module 1320 and a resource supply module 1330 .
[0257] The key thread identification module 1310 is used to determine the key thread.
[0258] The resource supply quantity decision module 1320 is used to obtain the fifth frame rate of the producer and the sixth frame rate of the consumer; determine the third target frame rate, which is the lower frame rate between the fifth frame rate and the sixth frame rate; for each key thread, according to the fourth corresponding relationship of the key thread, determine that the resource supply quantity corresponding to the third target frame rate is the third resource supply quantity, and the fourth corresponding relationship is the corresponding relationship between the frame rate and the resource supply quantity.
[0259] The resource supply module 1330 is used to adjust the resource supply of each key thread according to the third resource supply amount and the resource adjustment method of the key thread.
[0260] In a possible implementation, the electronic device 100 also includes an associated scheduling group module 1340, which is used to create an associated scheduling group including all key threads. At this time, the resource supply module 1330 is specifically used to: for each key thread of the associated scheduling group, according to the third resource supply amount of the resource adjustment method, perform resource supply operations on the key threads. At this time, first determine the third resource supply amount of the entire associated scheduling group based on the third target frame rate, rather than determining the third resource supply amount of each key thread. Then, according to the third resource supply amount of the entire associated scheduling group, adjust the resource supply for each key thread in the group.
[0261] The electronic device 100 has the function of implementing the resource supply method, which can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions, and the modules can be software and / or hardware.
[0262] It should be noted that the information interaction, execution process and other contents between the above-mentioned modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0263] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0264] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device capable of carrying the computer program code to an electronic device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0265] Those of ordinary skill in the art will appreciate that the units and algorithm 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.
[0266] In the embodiments provided in the present application, it should be understood that the disclosed electronic devices and methods can be implemented in other ways. For example, the electronic device embodiments described above are only schematic. For example, the division of the modules or 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 an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0267] 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.
[0268] The electronic device provided in the embodiments of the present application may include a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, a method as described in any one of the above method embodiments is implemented.
[0269] The embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0270] An embodiment of the present application provides a computer program product. When the computer program product runs on an electronic device, the electronic device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0271] The present application also provides a chip system, which includes a processor coupled to a memory, and the processor executes a computer program stored in the memory to implement the methods described in the above method embodiments. The chip system can be a single chip or a chip module composed of multiple chips.
[0272] In the above-mentioned embodiments, the description of each embodiment has its own emphasis. For the part that is not described or recorded in detail in a certain embodiment, please refer to the relevant description of other embodiments. It should be understood that the size of the sequence number of each step in the above-mentioned embodiment does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. In addition, in the description of the present application specification and the attached claims, the terms "first", "second", "third", etc. are only used to distinguish the description, and cannot be understood as indicating or implying relative importance. The reference "one embodiment" or "some embodiments" described in the present application specification means that one or more embodiments of the present application include specific features, structures or characteristics described in combination with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in the different places in this specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways.
[0273] Finally, it should be noted that the above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application 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 supply method, characterized in that: Applied to electronic equipment, the method comprises: If the electronic device is in a target business scenario, determining a target thread of the target business scenario, where the target thread is a thread for outputting data; Based on the target thread, identifying other threads of the target business scenario through thread wakeup relationships; Determine part or all of the threads of the target business scenario as key threads, where the threads of the target business scenario include the target thread of the target business scenario and other threads of the target business scenario; The resource supply of the key thread is adjusted, wherein the resource supply after the adjustment is stronger than the resource supply before the adjustment.
2. The method according to claim 1, characterized in that Determining a target thread of the target business scenario includes: According to a first corresponding relationship, it is determined that the thread corresponding to the target business scenario is the target thread, and the first corresponding relationship is a corresponding relationship between a business scenario and a thread.
3. The method according to claim 1, characterized in that The target business scenario is a display business scenario, an audio business scenario or an input business scenario.
4. The method according to claim 1, characterized in that: If the target business scenario is a business scenario including a producer and a consumer, the target thread includes a target thread of the producer and a target thread of the consumer; Based on the target thread, identifying other threads of the target business scenario through thread wakeup relationships includes: Based on the target thread of the producer, determining other threads of the producer of the target business scenario through the thread wake-up relationship; Based on the target thread of the consumer, determining other threads of the consumer of the target business scenario through the thread wake-up relationship; The other threads of the target business scenario include other threads of the producer and other threads of the consumer.
5. The method according to any one of claims 1 to 4, characterized in that: The resource supply of the key thread is adjusted, including: According to the resource adjustment mode of each of the key threads, the resource supply of each of the key threads is adjusted.
6. The method according to claim 5, characterized in that According to the resource adjustment mode of each of the key threads, the resource supply of each of the key threads is adjusted, including: Creating an associated scheduling group including all of the critical threads; Determining a first resource supply amount of the associated scheduling group; For each of the key threads, the resource supply of the key thread is adjusted according to the first resource supply amount and the resource adjustment method of the key thread.
7. The method according to claim 6, characterized in that If the target business scenario is a business scenario including producers and consumers, determining the first resource supply amount of the associated scheduling group includes: Obtaining a first frame rate of the producer and a second frame rate of the consumer; Determine a first target frame rate, where the first target frame rate is a lower frame rate between the first frame rate and the second frame rate; According to the second corresponding relationship, the resource supply amount corresponding to the first target frame rate is determined as the first resource supply amount, and the second corresponding relationship is the corresponding relationship between the frame rate and the resource supply amount.
8. The method according to claim 5, characterized in that If the target business scenario is a business scenario including producers and consumers, adjusting the resource supply of each of the key threads according to the resource adjustment method of each of the key threads includes: Obtaining a third frame rate of the producer and a fourth frame rate of the consumer; determining a second target frame rate, wherein the second target frame rate is a lower frame rate between the third frame rate and the fourth frame rate; For each of the key threads, according to the third corresponding relationship of the key threads, the resource supply corresponding to the second target frame rate is determined as the second resource supply, and according to the second resource supply and the resource adjustment method of the key thread, the resource supply of the key thread is adjusted, and the third corresponding relationship is the corresponding relationship between the frame rate and the resource supply.
9. The method according to claim 5, characterized in that The resource adjustment method includes at least one of the following: improving scheduling priority, improving memory allocation priority, I / O bandwidth guarantee, increasing the probability of switching to medium cores and / or large cores, and increasing device frequency.
10. A resource supply method, characterized in that: Applied to electronic equipment, the method comprises: Identify critical threads; Get the fifth frame rate of the producer and the sixth frame rate of the consumer; determining a third target frame rate, wherein the third target frame rate is a lower frame rate between the fifth frame rate and the sixth frame rate; For each of the key threads, according to the fourth corresponding relationship of the key thread, the resource supply corresponding to the third target frame rate is determined as the third resource supply, and according to the third resource supply and the resource adjustment method of the key thread, the resource supply of the key thread is adjusted, and the fourth corresponding relationship is the corresponding relationship between the frame rate and the resource supply.
11. An electronic device, characterized in that: include: A scene recognition module, used to recognize the business scene of the electronic device; A key thread identification module, used for determining a target thread of the target business scenario if the electronic device is in a target business scenario, wherein the target thread is a thread for outputting data; Based on the target thread, identifying other threads of the target business scenario through thread wakeup relationships; determining part or all of the threads of the target business scenario as key threads, wherein the threads of the target business scenario include the target thread of the target business scenario and other threads of the target business scenario; The resource supply module is used to adjust the resource supply of the key thread, wherein the resource supply after the adjustment is stronger than the resource supply before the adjustment.
12. The electronic device according to claim 11, characterized in that: The key thread identification module is specifically used for: According to a first corresponding relationship, it is determined that the thread corresponding to the target business scenario is the target thread, and the first corresponding relationship is a corresponding relationship between a business scenario and a thread.
13. The electronic device according to claim 11, characterized in that: The target business scenario is a display business scenario, an audio business scenario or an input business scenario.
14. The electronic device according to claim 11, characterized in that: If the target business scenario is a business scenario including a producer and a consumer, the target thread includes a target thread of the producer and a target thread of the consumer; The key thread identification module is specifically used to: determine other threads of the producer of the target business scenario through the thread wake-up relationship based on the target thread of the producer; determine other threads of the consumer of the target business scenario through the thread wake-up relationship based on the target thread of the consumer; wherein the other threads of the target business scenario include other threads of the producer and other threads of the consumer.
15. The electronic device according to any one of claims 11 to 14, characterized in that: The resource supply module is specifically used for: According to the resource adjustment mode of each of the key threads, the resource supply of each of the key threads is adjusted.
16. The electronic device according to claim 15, characterized in that: The resource supply module is specifically used for: Creating an associated scheduling group including all of the critical threads; Determining a first resource supply amount of the associated scheduling group; For each of the key threads, the resource supply of the key thread is adjusted according to the first resource supply amount and the resource adjustment method of the key thread.
17. The electronic device according to claim 16, characterized in that: If the target business scenario is a business scenario including producers and consumers, the resource supply module is specifically used to: Obtain a first frame rate of the producer and a second frame rate of the consumer; determine a first target frame rate, where the first target frame rate is a lower frame rate between the first frame rate and the second frame rate; and determine, based on a second corresponding relationship, that a resource supply corresponding to the first target frame rate is the first resource supply, where the second corresponding relationship is a corresponding relationship between frame rate and resource supply.
18. The electronic device according to claim 15, characterized in that: If the target business scenario is a business scenario including producers and consumers, the resource supply module is specifically used to: Obtaining a third frame rate of the producer and a fourth frame rate of the consumer; determining a second target frame rate, wherein the second target frame rate is a lower frame rate between the third frame rate and the fourth frame rate; For each of the key threads, according to the third corresponding relationship of the key threads, the resource supply corresponding to the second target frame rate is determined as the second resource supply, and according to the second resource supply and the resource adjustment method of the key thread, the resource supply of the key thread is adjusted, and the third corresponding relationship is the corresponding relationship between the frame rate and the resource supply.
19. The electronic device according to claim 15, characterized in that: The resource adjustment method includes at least one of the following: improving scheduling priority, improving memory allocation priority, I / O bandwidth guarantee, increasing the probability of switching to medium cores and / or large cores, and increasing device frequency.
20. An electronic device, characterized in that: include: A key thread identification module, used to identify key threads; A resource supply decision module is used to obtain the fifth frame rate of the producer and the sixth frame rate of the consumer; Determine a third target frame rate, where the third target frame rate is a lower frame rate between the fifth frame rate and the sixth frame rate; for each of the key threads, determine, according to a fourth corresponding relationship of the key thread, that the resource supply amount corresponding to the third target frame rate is a third resource supply amount, where the fourth corresponding relationship is a corresponding relationship between the frame rate and the resource supply amount; The resource supply module is used to adjust the resource supply of the key thread according to the third resource supply amount and the resource adjustment method of the key thread for each of the key threads.
21. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 9 or 10 is implemented.
22. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 9 or 10 is implemented.
Citation Information
Cited By
Cache allocation method and electronic equipment
CN119739536A
Thread identification method and device, electronic equipment, storage medium and program product
CN122431843A