Thread processing method and device and electronic equipment
By increasing the scheduling priority of the threads related to the target task, the shortcomings of the thread scheduling method under high load conditions are solved, and the execution quality of the target task and the performance of the electronic device are improved.
Patent Information
- Application Number
- CN202510134676.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-06
- Publication Date
- 2025-05-30
AI Technical Summary
In the prior art, there is room for improvement in thread scheduling methods, especially under high load conditions, the UI threads and Render threads of the foreground application may not be scheduled in time, resulting in reduced frame drops and FPS, affecting the user experience.
By determining the target thread, the target thread is related to realizing the target task, improving the scheduling priority of the target thread, and increasing the scheduling priority of the first thread to make it higher than the target thread, so as to increase the probability that the thread acquires processing resources.
By increasing the scheduling priority of threads related to the target task, processing resources can be obtained with a higher probability, the execution quality of the target task can be improved, and the performance of electronic devices can be guaranteed on the basis of maintaining the original priority order.
Smart Images

Figure CN120066718A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more particularly, to a thread processing method, apparatus, and electronic device. Background Art
[0002] For an electronic device, required functions can be executed through threads. For example, when the electronic device performs a screen display, the screen display can be performed through a thread related to the screen display. For another example, when the electronic device plays audio, the audio can be played through a thread related to the audio play. However, in the related art, there is still a problem that the thread scheduling method needs to be improved. Summary of the Invention
[0003] In view of the above problems, this application provides a thread processing method, apparatus, and electronic device to improve the above problems.
[0004] In a first aspect, this application provides a thread processing method, the method including: determining a target thread, the target thread including a thread related to implementing a target task; increasing the scheduling priority of the target thread and increasing the scheduling priority of a first thread, where the scheduling priority of the first thread is higher than that of the target thread, and where the higher the scheduling priority of a thread, the greater the probability of obtaining processing resources.
[0005] In a second aspect, this application provides a thread processing apparatus, the apparatus including: a thread determination unit, configured to determine a target thread, the target thread including a thread related to implementing a target task; a thread processing unit, configured to increase the scheduling priority of the target thread and increase the scheduling priority of a first thread, where the scheduling priority of the first thread is higher than that of the target thread, and where the higher the scheduling priority of a thread, the greater the probability of obtaining processing resources.
[0006] In a third aspect, this application provides an electronic device, including one or more processors and a memory; one or more programs are stored in the memory and configured to be executed by the one or more processors to implement the above method.
[0007] In a fourth aspect, this application provides a computer-readable storage medium, where program code is stored in the computer-readable storage medium, and where the above method is executed when the program code is run by a processor.
[0008] A thread processing method, apparatus, and electronic device provided by the present application. In this method, a target thread can be determined first, where the target thread includes threads related to the implementation of a target task. Then, the scheduling priority of the target thread can be increased and the scheduling priority of a first thread can be increased, where the scheduling priority of the first thread is higher than that of the target thread, and the higher the scheduling priority of a thread, the greater the probability of obtaining processing resources. Thus, through the above method, the scheduling priority of the target thread related to the target task can be increased, which is beneficial to the thread related to the target task obtaining processing resources with a greater probability when the target task is executed, and is beneficial to improving the execution quality of the target task. Moreover, the scheduling priority of the first thread whose original scheduling priority is higher than that of the target thread will also be increased, so that when the execution quality of the target task is improved, the original priority order can be maintained to a greater extent, which is beneficial to ensuring the performance of the electronic device. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application. For those skilled in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0010] Figure 1 The flowchart of a thread processing method proposed in an embodiment of the present application is shown;
[0011] Figure 2 The schematic diagram of a data container in an embodiment of the present application is shown;
[0012] Figure 3 The schematic diagram of adding a thread identifier to a data container in an embodiment of the present application is shown;
[0013] Figure 4 The schematic diagram of adding a thread identifier to the head position of a data container in an embodiment of the present application is shown;
[0014] Figure 5 The schematic diagram of adding a thread identifier to the head position of a second data container in an embodiment of the present application is shown;
[0015] Figure 6 The schematic diagram of moving and deleting a thread identifier in an embodiment of the present application is shown;
[0016] Figure 7 The schematic diagram of determining a key thread in an embodiment of the present application is shown;
[0017] Figure 8Shows a schematic diagram of the scheduling priority of threads in an embodiment of the present application;
[0018] Figure 9 Shows a flowchart of a thread processing method proposed in another embodiment of the present application;
[0019] Figure 10 Shows a schematic diagram of multiple functions related to the processor device selection strategy in an embodiment of the present application;
[0020] Figure 11 Shows a flowchart of a thread processing method proposed in still another embodiment of the present application;
[0021] Figure 12 Shows a schematic diagram of re - arranging the priorities of threads in an embodiment of the present application;
[0022] Figure 13 Shows a flowchart of a thread processing method in an embodiment of the present application;
[0023] Figure 14 Shows a structural block diagram of a thread processing device proposed in an embodiment of the present application;
[0024] Figure 15 Shows a structural block diagram of an electronic device for executing the thread processing method according to the embodiment of the present application in real - time;
[0025] Figure 16 Shows a storage unit for storing or carrying the program code for implementing the thread processing method according to the embodiment of the present application in real - time. Detailed implementation manners
[0026] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.
[0027] For an electronic device, various required functions can be executed through threads. For example, when the electronic device is performing screen display, the rendering of the screen can be specifically controlled through a thread related to screen display. Another example is that when the electronic device is playing audio, a thread related to audio playback is responsible for decoding and outputting audio data. However, in the related methods, although the use of threads has brought significant performance improvements, the thread scheduling method is still an issue to be improved.
[0028] For example, taking the screen display task as an example, during the process of an electronic device executing the screen display task, rendering is an important link, and the screen situation it presents directly affects the user experience. In related screen display tasks, the UI (User Interface) thread and the Render thread related to the screen display task play a crucial role in the rendering of the entire frame. Among them, the UI thread involves operations such as input processing, animation, measurement, layout, drawing, and synchronization, and the Render thread involves operations such as synchronization, drawing, and swapping buffers. Both are important threads for frame drawing. With the rapid development of electronic devices, current electronic devices can run more tasks simultaneously, which leads to the situation that in high-load scenarios, it cannot be guaranteed that the UI thread and the Render thread of the foreground application can be scheduled in a timely manner, resulting in frame drops and a decrease in FPS (Frames Per Second), seriously affecting the user experience. In addition, there are unreasonable settings for the scheduling priorities in related electronic devices. This chaotic and unreasonable scheduling priority order will lead to unnecessary processor preemption, resulting in blocking at certain critical moments, which is not conducive to ensuring the user experience.
[0029] Therefore, the inventors have proposed the thread processing method, device, and electronic device in this application. In this method, the target thread can be determined first, where the target thread includes the threads related to the implementation of the target task. Then, the scheduling priority of the target thread can be increased and the scheduling priority of the first thread can be increased, where the scheduling priority of the first thread is higher than that of the target thread, and the higher the scheduling priority of a thread, the greater the probability of obtaining processing resources. Thus, through the above method, the scheduling priority of the target thread related to the target task can be increased, which is beneficial for the threads related to the target task to obtain processing resources with a greater probability when the target task is executed, which is beneficial for improving the execution quality of the target task. Moreover, the scheduling priority of the first thread, whose original scheduling priority is higher than that of the target thread, will also be increased, so that while improving the execution quality of the target task, the original priority order can be maintained to a greater extent, which is beneficial for ensuring the performance of the electronic device.
[0030] The following will specifically describe the embodiments of this application in conjunction with the accompanying drawings.
[0031] Please refer to Figure 1 , a thread processing method provided by an embodiment of this application, the method includes:
[0032] S110: Determine the target thread, where the target thread includes the threads related to the implementation of the target task.
[0033] In the embodiments of the present application, the purpose of determining the target thread is to enable a relatively higher scheduling priority during the operation of the target thread. Among them, during the operation of the thread, it is usually to complete a specific task. Therefore, determining the target thread can also be understood as determining the target thread corresponding to the target task. In this case, the target thread includes the threads related to achieving the target task. And for different target tasks, the determined target threads can be different. In the embodiments of the present application, the target task can be understood as the task to be optimized in terms of performance, or it can be understood as the task to ensure the running performance. For example, the target task can be a screen display task, an audio playback task, an image acquisition task, etc.
[0034] As a way, the threads related to achieving the target task can include: the task execution thread and the key thread. Among them, the task execution thread is the thread responsible for executing the target task, and the key thread is the thread associated with the task execution thread. Among them, the key thread can also be understood as the thread that assists the task execution thread in executing the target task.
[0035] Among them, the task execution thread can be understood as the thread directly responsible for executing the target task. For example, for the screen display task, the task execution thread can include the UI thread and the Render thread. Among them, the UI thread and the Render thread play a crucial role in the screen rendering process. Among them, the main role of the UI thread is to handle user interactions, calculate the layout and size of the views, and draw these views on the screen. After the drawing operation is completed, the drawing instructions will be converted into graphic commands by the Render thread and submitted to the GPU (Graphics Processing Unit) for rendering. The two cooperate with each other and play a key role in the frame drawing process. Among them, the UI thread and the Render thread will also call other threads during the operation. Then, the other called threads can be understood as the threads associated with the UI thread and the Render thread. For another example, for the audio playback task, the task execution thread can include the audio playback thread, etc.
[0036] In the embodiments of the present application, there can be various ways to determine the key thread.
[0037] As a way, a thread that has been awakened by the task execution thread can be used as a critical thread. Among them, a thread that has been awakened by the task execution thread can also be understood as a thread that has been called by the task execution thread. As another way, a thread that has a data dependency relationship with the task execution thread can be used as a critical thread. It should be noted that a thread is the smallest unit that the operating system can perform operation scheduling on. The data dependency relationship between threads refers to a mutually dependent state formed in a multi-threaded environment where the execution result (data) of one thread is required by other threads. This dependency relationship may be caused by factors such as shared data access and task sequence requirements.
[0038] As yet another way, the critical thread includes one or more of the following multiple threads, and the multiple threads include: a thread that has been awakened by the task execution thread a preset number of times; a thread that has a data dependency relationship with the task execution thread. The preset number of times can be greater than or equal to 2 times. It should be noted that for some threads, they may only be accidentally awakened by the task execution thread. Therefore, if a thread that has been awakened by the task execution thread is directly used as a critical thread, the determined critical thread may not be accurate enough. Therefore, screening the critical thread through the preset number of times is beneficial to making the determined critical thread more accurate.
[0039] In an embodiment of the present application, as a way, during the running process of the task execution thread, the threads awakened by the task execution thread and the number of awakenings can be recorded, so that the critical thread can be determined according to the recorded results. Exemplarily, the recording situation of the awakened threads and the corresponding number of awakenings can be as shown in the following table:
[0040] Thread Name Wake-up Times Thread T1 1 Thread T2 1 Thread T3 1 Thread T4 2
[0041] Based on the above table situation, if the preset number of times is 1 time, then threads T1, T2, T3, and T4 can be used as critical threads. If the preset number of times is 2, then thread T4 can be used as the critical thread.
[0042] Optionally, a data container can be used to assist in determining the critical thread. In this way, a first data container and a second data container can be configured. If a thread is awakened by a task execution thread, the thread identifier (e.g., the PID of the thread) of the awakened thread can be stored in the first data container first. If the thread identifier of the awakened thread has already been stored in the first data container, the thread identifier of the awakened thread can be stored in the second data container. Each time the content of the second data container is updated, the thread stored in the second data container can be used as the critical thread. Based on this situation, as a way, the method provided by the embodiments of the present application may further include: if a thread is awakened by a task execution thread and the thread identifier of the awakened thread is not stored in the first data container, storing the thread identifier of the awakened thread in the first data container; if a thread is awakened by a task execution thread and the thread identifier of the awakened thread has already been stored in the first data container, storing the thread identifier of the awakened thread in the second data container, and using the thread in the second data container as the critical thread.
[0043] Optionally, storing the thread identifier of the awakened thread in the first data container includes: storing the thread identifier of the awakened thread at the head position of the first data container, and moving the thread identifiers already stored in the first data container one position backward to the tail of the first data container in sequence. If the first data container is full, the thread identifier at the tail position of the first data container is deleted. Optionally, if a thread is awakened by a task execution thread and the thread identifier of the awakened thread has already been stored in the first data container, the thread identifiers sorted before the thread identifier of the awakened thread in the first data container are moved one position backward to the tail of the first data container in sequence, and the thread identifier of the awakened thread is moved to the head position of the first data container.
[0044] It should be noted that in the embodiments of the present application, the data in the data container can be managed based on the LRU (Least Recently Used) algorithm. It should be noted that LRU is a replacement algorithm and also a management strategy in computer operating systems. The core idea of the LRU algorithm is that if a piece of data (for example, a thread in the present application) has not been accessed in a recent period of time, then the possibility of being accessed in the future is also very small. Therefore, when the space of the data container is insufficient, the system will preferentially eliminate the data that has been least recently used in order to make room for new data. Therefore, in the data container (the first data container or the second data container), the thread identifier placed at the head position can be understood as the thread identifier of the thread that was last awakened. Correspondingly, compared with the threads corresponding to other thread identifiers in the data container, the thread corresponding to the thread identifier stored at the tail position has the longest time since the last awakening until the current time.
[0045] Exemplarily, the first data container and the second data container can be as Figure 2 shown. If the thread identifier of the thread currently awakened by the task execution thread is thread identifier T6, then it can be as Figure 3 shown, add the thread identifier T6 to the first data container (because the thread identifier T6 does not exist in the first data container yet). After that, if the thread corresponding to the thread identifier T6 is awakened again by the task execution thread, in addition to retaining the thread identifier T6 in the first data container, the thread identifier T6 will also be added to the second data container.
[0046] Among them, as a way, when the thread identifier T6 does not exist in the first data container and the thread corresponding to the thread identifier T6 is awakened, as Figure 4 shown, the thread identifier T6 can be placed at the head position of the first data container, and the thread identifier T5 originally at the head position is moved one position towards the tail position. Based on Figure 4 the situation shown in Figure 5 if the thread corresponding to the thread identifier T6 is awakened again, then it can be as Figure 5 shown, add the thread identifier T6 to the second data container. And, as
[0047] shown, it will make the thread identifier T6 be at the head position of both the first data container and the second data container.
[0047] In addition, taking the first data container as an example, if new data needs to be written into the data container but the storage location of the data container is full, then the data at the tail position in the data container can be deleted. For example, Figure 6Delete the thread identifier T8 in it, and then move the thread identifiers T6, T5, and T7 to the tail position one by one in sequence to vacate the head position for storing the thread identifier T9 to be written.
[0048] It should be noted that in the case where there are multiple task execution threads corresponding to the target task, the corresponding key threads can be determined for each task execution thread respectively. In this case, the target threads can include multiple task execution threads and the corresponding key threads of each of the multiple task execution threads. In this case, the corresponding first data container and second data container can be configured for each task execution thread, so that the thread identified by the thread identifier stored in the second data corresponding to each task execution thread can be used as the corresponding key thread.
[0049] In the embodiments of the present application, the first data container or the second data container can be implemented in multiple ways. As one way, both the first data container and the second data container can be arrays. In this case, the first data container can be the first array, and the second data container can be the second array. Among them, the first array can be understood as an auxiliary array, and the second array can be understood as an important array. When both the first data container and the second data container are arrays, the process of determining the key thread can be as Figure 7 shown. Exemplarily, in Figure 7 the example shown, the thread identifier is the PID (process ID) of the thread.
[0050] Based on Figure 7 the process shown, the thread identifiers of the key threads can be recorded in the form of a queue.
[0051] S120: Increase the scheduling priority of the target thread and increase the scheduling priority of the first thread, where the scheduling priority of the first thread is higher than that of the target thread, and the higher the scheduling priority of a thread, the greater the probability of obtaining processing resources.
[0052] After determining the target thread, the scheduling priority of the target thread can be increased.
[0053] As a way, promoting the scheduling priority of the target thread may include: changing the scheduling method of the target thread from a first scheduling method to a second scheduling method, where the scheduling priority corresponding to the second scheduling method is higher than that of the first scheduling method. Optionally, when changing the scheduling method of the target thread from the first scheduling method to the second scheduling method, it may also be based on modifying the priority value used to represent the target definition. It should be noted that in some cases, the scheduling method adopted by the electronic device for the thread is determined based on the scheduling priority corresponding to the thread. Therefore, in this case, it may be by modifying the scheduling priority of the target thread to achieve changing the scheduling method of the target thread from the first scheduling method to the second scheduling method. For example, when the smaller the priority value, the higher the scheduling priority, the priority value of the target thread can be decreased to achieve changing the scheduling method of the target thread from the first scheduling method to the second scheduling method.
[0054] Among them, there are various ways to promote the scheduling priority of the first thread. As a way, it can also be by changing the scheduling method of the first thread from a first scheduling method to a second scheduling method to achieve the promotion of the scheduling priority. For example, when the smaller the priority value, the higher the scheduling priority, the priority value of the first thread can be decreased to achieve changing the scheduling method of the target thread from the first scheduling method to the second scheduling method. As another way, the scheduling priority of the first thread can be promoted by directly changing the number representing the scheduling priority.
[0055] Optionally, the first scheduling method can be Completely Fair Scheduler (CFS), and the second scheduling method can be Real Time (RT). In this case, promoting the scheduling priority of the target thread can be understood as changing the scheduling method of the target thread from the completely fair scheduling method to the real-time scheduling method. Optionally, when the first scheduling method is the completely fair scheduling method and the second scheduling method is the real-time scheduling method, the first thread can be understood as a thread that was originally scheduled using the second scheduling method. For example, the first thread can be a native RT thread.
[0056] It should be noted that in the completely fair scheduling method, a red-black tree algorithm can be used to manage scheduling entities (such as threads). For example, the virtual running time of scheduling entities is tracked to schedule the entities in the running queue, and the processing resources (such as CPU resources) are evenly distributed to execute the threads of each task. Among them, real-time scheduling is a real-time scheduling algorithm. In one way, tasks with a priority value less than 100 can be determined as RT tasks. The scheduling of RT tasks is directly related to their priorities. The smaller the priority value, the higher the corresponding scheduling priority. Among them, RT tasks are executed by RT threads.
[0057] Exemplarily, take the target threads including the UI thread and the Render thread as an example. As Figure 8 shown, in the screen display task, the UI thread and the Render thread default to the completely fair scheduling method (priority value >= 100), and other threads adopt the real-time scheduling method (priority value < 100). Therefore, changing the scheduling methods of the UI thread and the Render thread from the completely fair scheduling method to the real-time scheduling method can further ensure the performance of the UI thread and the Render thread to ensure the smoothness of the screen display. Among them, in the target threads involved in the screen display task, for the way of changing the scheduling priority of the determined key threads, the way of changing the UI thread and the Render thread can also be referred to. Among them, Figure 8 "prio" in it represents the priority value of the thread.
[0058] Since the second scheduling method (such as the real-time scheduling method) has the characteristic of preemptive scheduling, the scheduling priority of the target thread cannot be simply and blindly increased, because this may affect the overall order of thread execution in the electronic device and cause system disorders. Take the task execution threads including the UI thread and the Render thread as an example. When adjusting the scheduling priority of the target thread, the following principles should be followed: First, the UI thread and the Render thread of the foreground application are modified to the real-time scheduling method. However, in the case of being modified to the real-time scheduling method, the scheduling priorities of the UI thread and the Render thread should be lower than the original native RT threads in the system (such as the aforementioned first thread), because the original native RT threads in the system are the most sensitive and important batch of threads to latency. Among them, the native RT threads can be understood as the threads that are originally scheduled by the real-time scheduling method without being processed by the method provided in the embodiments of the present application.
[0059] Secondly, if only the scheduling priorities of the UI thread and the Render thread are modified, in some cases, it cannot meet our need to ensure QoE. A series of key threads related to these two threads, these threads either play important roles or interact with the UI thread and the Render thread. If the priorities of the key threads are not adapted, scheduling defects may occur due to untimely data interaction or failure to complete certain important tasks in a timely manner. Therefore, as a way, the scheduling priorities of the key threads will be changed together with the scheduling priorities of the task execution threads. Finally, when modifying the scheduling priorities, it is necessary to ensure that the overall arrangement of the default priority order of the system does not change as much as possible. This is because there are often certain dependencies between the priority arrangements of threads. Changing the scheduling priority order of some threads may have a serious impact on other threads and interfere with the stable operation of the entire system. Therefore, it is necessary to ensure that the overall arrangement trend of the thread priority order in the system remains unchanged.
[0060] Based on the above principles, in specific implementation, as a way, the scheduling priorities of some or all native RT threads (for example, the first thread in this application) can be increased first. On the one hand, this ensures that the priority order of the native RT threads is not disturbed. On the other hand, a whole block of priority sequence is vacated for the target threads (for example, including the UI thread, the Render thread, and the selected key threads) selected in the above steps to use. As shown in Table 1, for example, the scheduling priorities of the UI thread and the Render thread can be set to a certain level, and the priorities of other key threads can be set with reference to the wake-up and dependency relationships between the threads. It can be seen that for these threads (i.e., the target threads) that originally adopted the completely fair scheduling method, even if they are all converted to the real-time scheduling method, the order of their scheduling priorities with the native RT threads is not affected. For example, the scheduling priority of android.display is higher than that of android.ui (UI thread). After the scheduling priority is modified, the priority order will still not change.
[0061]
[0062] Table 1
[0063] A thread processing method provided in this embodiment can thus increase the scheduling priorities of the target threads related to the target task through the above method, which is beneficial to the threads related to the target task being more likely to obtain processing resources when the target task is executed, and is beneficial to improving the execution quality of the target task. Moreover, the scheduling priority of the first thread whose original scheduling priority is higher than that of the target thread will also be increased, so as to improve the execution quality of the target task on the basis of maintaining the original priority order to a greater extent, which is beneficial to ensuring the performance of the electronic device.
[0064] For example, in the execution thread processing method, there are a first thread, a second thread, and a target thread in the embodiment of the present application in the electronic device. Among them, the native (or initial) scheduling priority of the first thread is higher than the native scheduling priority of the target thread, and the native scheduling priority of the second thread is the same as the native scheduling priority of the target thread. In the case of improving the native scheduling priority of the target thread by the method provided in the embodiment of the present application, the scheduling priority of the target thread can be made higher than the scheduling priority of the second thread, and thus the probability of obtaining processing resources can be greater. Moreover, because the native scheduling priority of the first thread is synchronously improved, after the scheduling priority is improved, the scheduling priority of the first thread can still be higher than the scheduling priority of the target thread, thereby maintaining the original priority order to a certain extent.
[0065] Please refer to Figure 9 , a thread processing method provided by an embodiment of the present application, the method includes:
[0066] S210: Determine a target thread, where the target thread includes a thread related to implementing a target task.
[0067] S220: Change the scheduling mode of the target thread from a first scheduling mode to a second scheduling mode, where the scheduling priority corresponding to the second scheduling mode is higher than the scheduling priority of the first scheduling mode.
[0068] S230: Improve the scheduling priority of a first thread, where the scheduling priority of the first thread is higher than the scheduling priority of the target thread, and the higher the scheduling priority of a thread, the greater the probability of obtaining processing resources.
[0069] In the embodiments of the present application, threads in an electronic device need to run through a processing device. The processing device can be a core in a processor. For some task execution threads, if they frequently run on processing devices with low computing power, it may cause insufficient resources allocated to these task execution threads. For example, for the UI thread and the Render thread, they are the main threads for application frame drawing. Frequent execution on a processor with low computing power will result in insufficient resources allocated to them, leading to a longer running time and an increased risk of frame loss. Additionally, in the embodiments of the present application, the processor device selection strategies corresponding to different scheduling methods will also be different. Therefore, when modifying the scheduling method of a target thread from a first scheduling method to a second scheduling method, the processor device selection strategy corresponding to the second scheduling method may not be suitable for the target thread. Therefore, after modifying the scheduling method of the target thread, it is also necessary to synchronously modify the processor device selection strategy of the target thread. For example, after modifying the UI thread, the Render thread, and their related critical threads to the real-time scheduling method, the corresponding core selection logic (processor device selection strategy) also needs to be modified accordingly.
[0070] Among them, the core selection strategy for the real-time scheduling method mainly selects a suitable run queue to run real-time tasks according to the characteristics of real-time tasks and the system load situation in the select_task_rq_rt() function, so as to ensure the timely response of real-time tasks and the performance stability of the system. Among them, the balance_rt() function performs load balancing operations on real-time tasks in a real-time system to ensure that real-time tasks can be executed on a suitable run queue. That is, when there are no real-time tasks on a certain processor, this function will be used to pull tasks from other processors with heavy real-time tasks and run them on this processor.
[0071] Among them, the rto_push_irq_work_func() function realizes the load balancing of real-time tasks through task pushing in a real-time system, improving the execution efficiency of real-time tasks in the system and the system performance. The core selection of the RT thread is performed through the above three methods, and the call relationship of the core selection logic function is as Figure 10 shown.
[0072] Among them, the select_task_rq_rt() function is used to select a suitable run queue to run real-time tasks. It will first record relevant scheduling information according to the incoming real-time task p, processor number, and flag flags, and perform tracking by calling the trace_android_rvh_select_task_rq_rt() function. When a suitable processor is selected, it will return the currently selected processor.
[0073] When performing processor selection in the trace_android_rvh_select_task_rq_rt() function, the fast core selection path in it will frequently select the processor where the previous thread was located. Therefore, once a small core is selected, it will have a small core tendency, causing task processing threads (such as the UI thread and the Render thread) to frequently run on the small core, affecting performance. Therefore, for specific threads (such as task execution threads like the UI and Render threads), under the condition of ensuring that the scheduling method is a real-time scheduling method, a processor selection strategy of the completely fair scheduling method can be adopted to select cores for the specific thread. As a way, in the select_task_rq_rt() function, it can first be determined whether the RT thread is the target thread determined in the embodiment of the present application (such as the UI thread or the Render thread)
[0074] If so, call the trace_android_rvh_select_task_rq_fair() function to select a processor device for the thread according to the processor selection strategy of the completely fair scheduling method, and return after selecting a suitable processor device. Otherwise, still select an appropriate processor device for the thread according to the original processor selection strategy of the real-time scheduling method.
[0075] Secondly, the balance_rt() function is used to perform load balancing operations for real-time tasks. In this function, it will check whether the real-time task p is not on the real-time run queue and needs to pull the real-time task to the current run queue. If this condition holds, the pull_rt_task() function will be called to change the processor where the RT thread is located for load balancing. The main role of the pull_rt_task() function is to attempt to migrate non-running tasks to processors with lower running priorities when there are multiple real-time tasks on the current processor, so as to ensure that tasks can run on appropriate processors and avoid lower-priority tasks being executed first. However, due to the small-core preference of RT thread core selection, if the task execution threads (such as the UI thread and the Render thread) are selected on small cores, it will affect performance. Among them, the pull_rt_task(rq) function is used to pull real-time tasks from other overloaded run queues to the current run queue to achieve load balancing and priority management, mainly by using the find_lowest_rq() function to select other processors. The function will check whether the current run queue rq is in an overloaded state. If it is not overloaded, it will directly return 0, indicating that no push operation is required. Then, it will call the pick_next_pushable_task function to select the next pushable task next_task. If there is no pushable task, it will directly return 0 indicating that no push operation is required. Before pushing, the function will perform some retry operations to ensure the effectiveness of the push: if the priority of the next task is lower than that of the current task, the current task will be rescheduled. If the migration of the next task is disabled, the following operations will be performed: 1. In the case where the migration is disabled, the function will attempt to push the current task on other processors; 2. If the push operation cannot be performed or the current run queue is already busy pushing tasks, it will directly return 0, indicating that the push operation cannot be performed; 3. Ensure that the current task belongs to the real-time task class, otherwise return 0; 4. Find a processor with a lower priority than the current task by calling the find_lowest_rq function; 5. If a suitable processor is found, attempt to push the current task to that processor. Finally, the function returns 0 indicating that the push operation is completed or the push operation cannot be performed. Therefore, in the find_lowest_rq() function, if the processor where the task execution threads (such as the UI thread and the Render thread) are located needs to perform load balancing, the trace_android_rvh_select_task_rq_fair() function will be used to select the core according to the processor selection strategy of the completely fair scheduling method during core selection.
[0076] Finally, the rto_push_irq_work_func() function is called from the hard interrupt context. The function is used to perform a task push operation on the processor with real-time task load in a real-time system to balance the system load and improve the execution efficiency of real-time tasks. Therefore, the processor device selection for RT threads is involved in this function. It checks whether there are real-time tasks that can be pushed in the current run queue. If so, it tries to call the push_rt_task() function to push the real-time task to other processors for execution. When selecting the processor device in the push_rt_task() function, the processor device selection of the task execution threads (e.g., UI thread and Render thread) is not involved in the push_rt_task() function, and the processor device selection policy in this function is implemented by calling the find_lowest_rq() function.
[0077] Therefore, based on the foregoing, as a way, the first scheduling method is the completely fair scheduling method, and the second scheduling method is the real-time scheduling method. After changing the scheduling method of the target thread from the first scheduling method to the second scheduling method in this way, it further includes: determining a corresponding processor device for the target thread based on the processor device selection policy of the completely fair scheduling method.
[0078] A thread processing method provided in this embodiment can thus increase the scheduling priority of the target thread related to the target task in the above manner, which is beneficial to the thread related to the target task being more likely to obtain processing resources when executing the target task, beneficial to improving the execution quality of the target task, and also increasing the scheduling priority of the first thread whose original scheduling priority is higher than that of the target thread, so that the original priority order can be maintained to a greater extent when improving the execution quality of the target task, which is beneficial to ensuring the performance of the electronic device. And in this embodiment, the policy for determining the processor device can also be adapted for the determined target thread, so as to further improve the performance of the electronic device executing the thread processing method in this application.
[0079] Please refer to Figure 11 , a thread processing method provided in an embodiment of this application, the method includes:
[0080] S310: Determine a target thread, where the target thread includes a thread related to implementing a target task;
[0081] S320: Boost the initial scheduling priority of the target thread and the initial scheduling priority of the first thread, where the initial scheduling priority of the first thread is higher than that of the target thread. The higher the scheduling priority of a thread, the greater the probability of obtaining processing resources. The initial scheduling priority of the threads in the electronic device is determined based on the functional attributes of the threads.
[0082] It should be noted that in existing electronic devices, there are some unreasonable aspects in the setting of thread scheduling priorities. For example, the scheduling priorities of some threads that have an intuitive impact on the user experience are too low, which may cause them to be preempted by relatively less important threads. Therefore, for existing RT threads and added RT threads (such as the determined target thread), we need an overall partitioning scheme. In the embodiments of the application, the priorities of the threads can be partitioned according to the functional attributes of each thread. Such a priority setting makes the priority levels of RT scheduling entities clear. As a way, it can be partitioned according to functions such as audio, application main thread, SurfaceFlinger, driver, GPU, etc. For example, the audio-related settings are in [A, A + 10], and the threads related to the application main process are set in [A + 10, A + 30]. The advantage of this is that the priority sizes are allocated according to the functional attributes, so that each module has a corresponding priority range. When a new RT scheduling thread is added later, its corresponding priority range can be matched according to its function, and an appropriate size can be set in combination with the relationship with other threads. Among them, when partitioning the scheduling priorities according to the functional attributes of the threads, the obtained partitioning results can be as Figure 12 shown. Among them, Figure 12 the example shown is to re-partition the scheduling priorities of RT scheduling entities (RT threads).
[0083] A thread processing method provided in this embodiment can boost the scheduling priority of the target thread related to the target task through the above method, which is beneficial for the thread related to the target task to obtain processing resources with a greater probability when executing the target task, and is beneficial for improving the execution quality of the target task. Moreover, the scheduling priority of the first thread, whose original scheduling priority is higher than that of the target thread, will also be boosted, so that when improving the execution quality of the target task, the original priority order can be maintained to a greater extent, which is beneficial for ensuring the performance of the electronic device. And in this embodiment, the scheduling priority (initial scheduling priority) of each thread can be reconfigured according to the functional attribute of each thread, so that from the perspective of task execution, the rationality of the scheduling priority of each thread is improved.
[0084] It should be noted that in an electronic device, binder is a way to achieve cross-process communication. In the kernel of the electronic device, in the binder_open() function, an initial value will be assigned to proc->default_priority.prio, and this value will be used as the priority when a thread is created. As a way, the binder priority of the native RT threads (for example, the first thread in this application) in the electronic device can be adjusted. For example, all of them can be raised by a certain level to free up some priority space for the threads in the user layer (for example, the target thread determined in the embodiments of this application) to use, so as to adapt to the upgraded real-time scheduling algorithm.
[0085] In the binder_transaction_priority() function, during the pre-judgment, it will check whether the current binder node supports the real-time scheduling method. If it does not support, the scheduling priority will be set to a fixed value, for example, 120. Since the binder of some task execution threads (for example, the UI thread and the Render thread) does not support the real-time scheduling method by default, a judgment condition is added here. If it is a specific thread (for example, the UI thread or the Render thread), then this adjustment will be skipped, so that the real-time scheduling priority of the specific thread can be inherited through binder and restored to the original priority when the communication ends. When setting the priority, it is necessary to consider not conflicting with the priority of the native RT threads in the system. Therefore, as a way, the method provided in the embodiments of this application further includes: changing the cross-process communication thread (binder thread) communicating with the target thread to support the real-time scheduling method.
[0086] In the embodiments of this application, the scheduling priority of the target thread can be raised after the target thread is determined. Or, during the execution of the target task, the scheduling priority of the target thread can be raised and the scheduling priority of the first thread can be raised. Or, when it is estimated that the target task is to be achieved, the scheduling priority of the target thread can be raised and the scheduling priority of the first thread can be raised.
[0087] Based on the foregoing content, the overall architecture of the thread processing method involved in the embodiments of this application can be summarized as shown in Figure 13 as follows. In Figure 13Among them, taking the target task as the screen display task and the task execution threads including the UI thread and the Render thread as an example, the thread processing method is introduced again. Among them, a thread that has been woken up by the UI thread or the Render thread can be used as a candidate key thread and added to the auxiliary array or the VIP array. Among them, the auxiliary array can be understood as a first data container, and the VIP array can be understood as a second data container. For the auxiliary array and the VIP array, they can be managed by the LRU algorithm. Among them, a key thread queue can also be configured to store the determined key threads. After determining the key threads, the scheduling methods of the UI thread, the Render thread, and the key threads can be changed from CFS scheduling to RT scheduling. Correspondingly, RT scheduling adaptation will also be performed. Among them, RT scheduling adaptation includes communication adaptation, RT priority adaptation, and core selection algorithm adaptation. In addition, in Figure 13 In the shown manner, the priorities of the native RT threads in the electronic device can also be re-planned. Among them, the division can be based on the functional attributes of the native RT threads.
[0088] Please refer to Figure 14 , a thread processing device 400 provided by an embodiment of the present application, the device 400 includes:
[0089] A thread determination unit 410, configured to determine a target thread, where the target thread includes a thread related to implementing a target task;
[0090] A thread processing unit 420, configured to increase the scheduling priority of the target thread and increase the scheduling priority of a first thread, where the scheduling priority of the first thread is higher than that of the target thread, and the higher the scheduling priority, the greater the probability of obtaining processing resources for the thread.
[0091] As a way, the thread determination unit 410 is specifically configured to, if a thread is woken up by a task execution thread and the thread identifier of the woken-up thread is not stored in the first data container, store the thread identifier of the woken-up thread in the first data container; if a thread is woken up by a task execution thread and the thread identifier of the woken-up thread has been stored in the first data container, store the thread identifier of the woken-up thread in the second data container; and use the thread in the second data container as a key thread.
[0092] Optionally, the thread determination unit 410 is specifically configured to store the thread identifier of the woken-up thread at the head position of the first data container, and move the thread identifiers already stored in the first data container one position backward to the tail of the first data container in sequence.
[0093] Optionally, the thread determination unit 410 is further specifically configured to, if a thread is awakened by a task execution thread and the thread identifier of the awakened thread has been stored in the first data container, move the thread identifiers sorted before the thread identifier of the awakened thread in the first data container one position backward in sequence to the tail of the first data container, and move the thread identifier of the awakened thread to the head position of the first data container.
[0094] As a way, the thread processing unit 420 is specifically configured to change the scheduling mode of the target thread from the first scheduling mode to the second scheduling mode, where the scheduling priority corresponding to the second scheduling mode is higher than the scheduling priority of the first scheduling mode.
[0095] Optionally, the first scheduling mode is the completely fair scheduling mode, and the second scheduling mode is the real-time scheduling mode. In this case, the thread processing unit 420 is further configured to determine a corresponding processor device for the target thread based on the processor device selection strategy of the completely fair scheduling mode.
[0096] As a way, the thread processing unit 420 is further configured to change the cross-process communication thread communicating with the target thread to support the real-time scheduling mode.
[0097] As a way, the thread processing unit 420 is specifically configured to increase the initial scheduling priority of the target thread and increase the initial scheduling priority of the first thread; where the initial scheduling priority of the threads in the electronic device is determined based on the functional attributes of the threads.
[0098] A thread processing device provided in this embodiment can increase the scheduling priority of the target thread related to the target task through the above thread processing device, which is beneficial to the threads related to the target task being more likely to obtain processing resources when the target task is executed, beneficial to improving the execution quality of the target task, and will also increase the scheduling priority of the first thread whose original scheduling priority is higher than that of the target thread, so that when the execution quality of the target task is improved, the original priority order can be maintained to a greater extent, which is beneficial to ensuring the performance of the electronic device.
[0099] It should be noted that the device embodiments in this application correspond to the foregoing method embodiments. The specific principles in the device embodiments can refer to the content in the foregoing method embodiments and will not be elaborated here.
[0100] Next, Figure 15 an electronic device provided in this application will be described.
[0101] Please refer to Figure 15, based on the above audio processing method and apparatus, another electronic device 200 capable of executing the foregoing audio processing method is further provided in an embodiment of the present application. The electronic device 200 includes one or more (only one is shown in the figure) processors 202, a memory 204, a network module 206, a sensor module 208, and an audio collection device 210 that are coupled to each other. Among them, a program that can execute the content in the foregoing embodiments is stored in the memory 204, and the processor 202 can execute the program stored in the memory 204.
[0102] Among them, the processor 202 may include one or more processing cores. The processor 202 uses various interfaces and lines to connect various parts within the entire electronic device 200, and by running or executing instructions, programs, code sets, or instruction sets stored in the memory 204, and by calling data stored in the memory 204, it executes various functions of the electronic device 200 and processes data. Optionally, the processor 202 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 202 may integrate one or a combination of several of a central processing unit (CPU), a graphics processing unit (GPU), and a modem, etc. Among them, the CPU mainly processes the operating system, user interface, application programs, etc.; the GPU is responsible for rendering and drawing the displayed content; the modem is used to process wireless communication. It can be understood that the above modem may not be integrated into the processor 202 and may be implemented separately through a communication chip.
[0103] The memory 204 may include a random access memory (RAM), and may also include a read-only memory. The memory 204 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 204 may include a program storage area and a data storage area. Among them, the program storage area may store instructions for implementing the operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc.
[0104] The network module 206 is used to implement information interaction between the electronic device 200 and other devices. For example, it transmits device control instructions, manipulation request instructions, and status information acquisition instructions, etc. When the electronic device 200 is specifically different devices, the corresponding network module 206 may be different.
[0105] The sensor module 208 may include at least one sensor. Specifically, the sensor module 208 may include but is not limited to: optical sensors, motion sensors, pressure sensors, infrared thermal sensors, distance sensors, acceleration sensors, and other sensors.
[0106] Among them, the pressure sensor is a sensor that can detect the pressure generated by pressing on the electronic device 200. That is, the pressure sensor detects the pressure generated by the contact or pressing between the user and the electronic device, such as the pressure generated by the contact or pressing between the user's ear and the mobile terminal. Therefore, the pressure sensor can be used to determine whether there is contact or pressing between the user and the electronic device 200, and the magnitude of the pressure.
[0107] Among them, the acceleration sensor can detect the magnitude of acceleration in each direction (generally three axes). When stationary, it can detect the magnitude and direction of gravity, and can be used in applications for identifying the posture of the electronic device 200 (such as horizontal and vertical screen switching, related games, magnetometer attitude calibration), vibration recognition related functions (such as pedometers, tapping), etc. In addition, the electronic device 200 can also be configured with other sensors such as gyroscopes, barometers, hygrometers, and thermometers, which will not be elaborated here.
[0108] The audio acquisition device 210 is used to acquire audio signals. Optionally, the audio acquisition device 210 includes multiple audio acquisition components. The audio acquisition component can be a microphone. For example, in one way, the audio acquisition device 210 can include two microphones. In this way, one of the microphones can correspond to one analog-to-digital converter, and the other microphone can correspond to two analog-to-digital converters with different analog gains. In another way, the audio acquisition device 210 can include three microphones. In this way, two of the microphones (for example, the main microphone and the secondary microphone) can each correspond to one analog-to-digital converter, and the other microphone (for example, the camera microphone) can correspond to two analog-to-digital converters with different analog gains.
[0109] As a way, the network module of the electronic device 200 is a radio frequency module, which is used to receive and send electromagnetic waves, realize the mutual conversion between electromagnetic waves and electrical signals, so as to communicate with a communication network or other devices. The radio frequency module may include various existing circuit elements for performing these functions. For example, an antenna, a radio frequency transceiver, a digital signal processor, an encryption / decryption chip, a subscriber identity module (SIM) card, a memory, and so on. For example, the radio frequency module can interact with external devices through the electromagnetic waves sent or received, and then receive the audio signals sent by the external devices.
[0110] Furthermore, the electronic device 200 may also include an image acquisition device for image acquisition. For example, videos, static pictures or dynamic pictures can be taken through this image acquisition device.
[0111] Please refer to Figure 16 , which shows a structural block diagram of a computer-readable storage medium provided by an embodiment of the present application. Program code is stored in the computer-readable medium 800, and the program code can be called by a processor to execute the method described in the above method embodiment.
[0112] The computer-readable storage medium 800 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer-readable storage medium 800 includes a non-transitory computer-readable storage medium. The computer-readable storage medium 800 has a storage space for the program code 810 that executes any method step in the above method. These program codes can be read out from or written into one or more computer program products. The program code 810 can be compressed in an appropriate form, for example.
[0113] A thread processing method, apparatus, and electronic device provided by the present application. In this method, a target thread can be determined first, where the target thread includes threads related to implementing a target task. Then, the scheduling priority of the target thread can be increased and the scheduling priority of a first thread can be increased, where the scheduling priority of the first thread is higher than that of the target thread, and the higher the scheduling priority of a thread, the greater the probability of obtaining processing resources. Thus, through the above method, the scheduling priority of the target thread related to the target task can be increased, which is beneficial to the thread related to the target task obtaining processing resources with a greater probability when executing the target task, and is beneficial to improving the execution quality of the target task. Moreover, the scheduling priority of the first thread whose original scheduling priority is higher than that of the target thread will also be increased, so that when the execution quality of the target task is improved, the original priority order can be maintained to a greater extent, which is beneficial to ensuring the performance of the electronic device.
[0114] Among them, the embodiment of the present application implements a set of low-overhead and efficient methods for determining critical threads, and can modify the scheduling method of the selected critical threads from the CFS scheduling method to the RT scheduling method, and make corresponding scheduling strategy adaptations. Finally, the scheduling priorities of the native RT threads in the device are overall arranged to achieve stable and reliable system operation. The present invention is applicable to various scenarios, not limited to a single application scenario, and is not complex in kernel implementation. It can select critical threads with extremely low overhead, and will update the critical thread queue according to the switching of scenarios, and optimize the scheduling according to the selected threads, so as to ensure the performance while the power consumption does not change significantly.
[0115] Specifically, the present application solves the problem of manually screening and marking critical threads in application scenarios, greatly improving the efficiency of system development and operation, and avoiding the cumbersome work of repeatedly screening and marking for ever-changing application scenarios.
[0116] In addition, the present application realizes the purpose of screening critical threads in the Android system with extremely low overhead through a dynamic management method, and realizes real-time dynamic switching of critical threads in different application scenarios in the kernel without manual intervention.
[0117] In addition, the present application changes the scheduling algorithm of critical threads (for example, critical threads determined based on the UI thread and the Render thread) from the CFS scheduling method to the RT scheduling method to ensure a specific task process, for example, to further ensure the rendering process. And tests on mainstream applications show that the present application will not deteriorate the device power consumption while realizing dynamic critical thread switching and scheduling optimization.
[0118] In addition, the present application implements an overall arrangement of priorities for the system's native RT threads and key tasks in the user layer according to their functional attributes and impacts on the user experience, avoiding unnecessary preemption during scheduling and ensuring the stable progress of the system rendering process.
[0119] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and are not intended to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the various embodiments of the present application.
Claims
1. A thread processing method, characterized in that: The method comprises: Determine a target thread, wherein the target thread includes a thread related to achieving a target task; The scheduling priority of the target thread is increased and the scheduling priority of the first thread is increased, wherein the scheduling priority of the first thread is higher than the scheduling priority of the target thread, wherein the thread with a higher scheduling priority has a greater probability of acquiring processing resources.
2. The method according to claim 1, characterized in that The threads related to achieving the target task include: a task execution thread and a key thread, wherein the task execution thread is a thread used to execute the target task, and the key thread is a thread associated with the task execution thread.
3. The method according to claim 2, characterized in that The key thread includes one or more of the following multiple threads, and the multiple threads include: Threads that have been awakened by the task execution thread for a preset number of times; A thread that has data dependencies with the task execution thread.
4. The method according to claim 2, characterized in that: The method further comprises: If a thread is awakened by the task execution thread, and the thread identifier of the awakened thread is not stored in the first data container, the thread identifier of the awakened thread is stored in the first data container; If a thread is awakened by the task execution thread, and the thread identifier of the awakened thread has been stored in the first data container, the thread identifier of the awakened thread is stored in the second data container; The thread in the second data container is regarded as a key thread.
5. The method according to claim 4, characterized in that The step of storing the thread identifier of the awakened thread in the first data container includes: The thread identifier of the awakened thread is stored at the head position of the first data container, and the thread identifiers already stored in the first data container are moved one position toward the tail of the first data container in sequence.
6. The method according to claim 5, characterized in that The method further comprises: If a thread is awakened by the task execution thread, and the thread identifier of the awakened thread has been stored in the first data container, the thread identifiers in the first data container that are sorted before the thread identifier of the awakened thread are moved one position to the tail of the first data container, and the thread identifier of the awakened thread is moved to the head position of the first data container.
7. The method according to any one of claims 1 to 6, characterized in that: The step of increasing the scheduling priority of the target thread includes: The scheduling mode of the target thread is changed from a first scheduling mode to a second scheduling mode, wherein the scheduling priority corresponding to the second scheduling mode is higher than the scheduling priority of the first scheduling mode.
8. The method according to claim 7, characterized in that The first scheduling mode is a completely fair scheduling mode, the second scheduling mode is a real-time scheduling mode, and after changing the scheduling mode of the target thread from the first scheduling mode to the second scheduling mode, the method further includes: Based on the processing device selection strategy of the completely fair scheduling method, a corresponding processing device is determined for the target thread.
9. The method according to any one of claim 7, characterized in that: The second scheduling mode is a real-time scheduling mode, and the method further includes: The cross-process communication thread that communicates with the target thread is changed to support real-time scheduling.
10. The method according to any one of claims 1 to 6, characterized in that: The step of increasing the scheduling priority of the target thread and increasing the scheduling priority of the first thread includes: Improving the initial scheduling priority of the target thread and improving the initial scheduling priority of the first thread; The initial scheduling priority of the thread in the electronic device is determined based on the functional attributes of the thread.
11. A thread processing device, characterized in that: The device comprises: A thread determination unit, used to determine a target thread, wherein the target thread includes a thread related to achieving a target task; A thread processing unit is used to increase the scheduling priority of the target thread and the scheduling priority of the first thread, wherein the scheduling priority of the first thread is higher than the scheduling priority of the target thread, wherein the higher the scheduling priority of the thread, the greater the probability of obtaining processing resources.
12. An electronic device, characterized in that: The method comprises one or more processors and a memory; one or more programs are stored in the memory and are configured so that the one or more processors execute the method according to any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program code, wherein when the program code is executed by a processor, the method according to any one of claims 1 to 10 is executed.