Search

CN-121996335-A - Thread processing method, medium, electronic device, and program product

CN121996335ACN 121996335 ACN121996335 ACN 121996335ACN-121996335-A

Abstract

The application discloses a thread processing method, a medium, electronic equipment and a program product, belonging to the technical field of design terminals. In the process of starting the application, whether a first thread initiating the call and a second thread being called meet the dispatch identifier transfer condition is judged. When the dispatch identifier transfer condition is judged to be met, whether the dispatch identifier (such as a VIP identifier) needs to be transferred from the first thread to the second thread or not can be further judged according to the type of the calling mode, and how to adjust the transfer depth of the second thread when the dispatch identifier is set for the second thread. When the scheduling identifier is transferred in the calling mode of the first type, the situation that the scheduling identifier cannot be normally transferred for the second thread and the higher scheduling priority cannot be set for the second thread is avoided by forcing not to set the transfer depth for the called second thread or forcing to set the transfer depth to be 0. Furthermore, the problem that the second thread blocks the first thread is solved, and the starting speed of the application is improved.

Inventors

  • LI YOUPENG
  • TAN WENWEN
  • ZHAO HEPING

Assignees

  • 荣耀终端股份有限公司

Dates

Publication Date
20260508
Application Date
20241108

Claims (15)

  1. 1. A thread processing method, for application to an electronic device, the method comprising: When a first thread calls a second thread in a first calling mode, judging whether the first thread and the second thread meet a dispatch identifier transfer condition, wherein the second thread is a thread related to starting animation of a first application; When the dispatch identifier transfer condition is met, determining the type of the first calling mode; When the type of the first calling mode is determined to be a first type, setting a scheduling identifier for the second thread, and prohibiting the setting of the transfer depth for the second thread or setting the transfer depth of the second thread to be the minimum transfer depth; When the type of the first calling mode is determined to be a second type, a scheduling identifier is set for the second thread, and the transfer depth of the second thread is adjusted according to the transfer depth of the first thread, wherein, The dispatching priority of the thread provided with the dispatching identification is higher than the dispatching priority of the thread not provided with the dispatching identification.
  2. 2. The method of claim 1, wherein the dispatch identifier transfer condition includes that the thread that initiated the call is provided with a dispatch identifier and that the transfer depth of the thread that initiated the call is less than the maximum transfer depth.
  3. 3. The method of claim 2, wherein the dispatch identifier transfer condition further comprises the invoked thread having a dispatch identifier and a transfer depth set and the transfer depth being less than the maximum transfer depth, or the invoked thread not having a dispatch identifier and a transfer depth set.
  4. 4. The method according to claim 1, wherein the method further comprises: and when the first thread or the second thread does not meet the dispatch identifier transfer condition, not adjusting the dispatch identifier and the transfer depth of the second thread.
  5. 5. The method of claim 1, wherein said adjusting the depth of delivery of the second thread based on the depth of delivery of the first thread comprises: if the second thread does not set the transfer depth, adding a second depth value obtained by adding 1 to the transfer depth of the first thread, updating the transfer depth of the second thread to the second depth value, If the second thread is provided with the transmission depth of the first depth value, adding 1 to the transmission depth of the first thread to obtain a second depth value, and updating the transmission depth of the second thread to be the maximum value of the first depth value and the second depth value, so that the transmission depth of the second thread is smaller than or equal to the maximum transmission depth.
  6. 6. The method according to claim 1, wherein the method further comprises: And if the type of the first calling mode is the second type, removing the scheduling identification and the transfer depth of the second thread or setting the transfer depth of the second thread as the minimum transfer depth when the second thread is called by the first thread.
  7. 7. The method according to claim 1, wherein the method further comprises: When a first process receives a first input event, setting a scheduling identifier for a key thread for processing the first input event and setting a transfer depth to be the minimum transfer depth, wherein the first input event is an input event corresponding to a touch operation of a user on an icon of a first application displayed on a display screen, and The first thread is the key thread or the first thread is a thread competing with the key thread for locks; The second thread is a thread having a dependency relationship with the critical thread.
  8. 8. The method of claim 7, wherein the critical threads include at least one of an animation processing thread in a system services process and a window management thread in a system user interface process; and the second thread is an animation loading thread in the starter process and a display frame rate determining thread in the frame rate service process.
  9. 9. The method of claim 8, wherein the step of determining the position of the first electrode is performed, When the first thread is the window management thread, the second thread is the display resource loading thread; and when the first thread loads the thread for the display resource, the second thread determines the thread for the display frame rate.
  10. 10. The method according to any one of claims 1 to 9, wherein the first type is a SHORT type, and a duration of a thread call by a call mode of the SHORT type is less than or equal to a preset duration; the second type includes at least one of a binder type and a lock contention type.
  11. 11. The method according to any one of claims 1 to 10, further comprising: When the second thread is called by the first thread, if the type of the first calling mode is the second type, the first thread calls the second thread in a second calling mode, and whether the first thread meets the dispatch identifier transfer condition is judged; and when the first thread meets the dispatch identifier transfer condition, determining the type of the second calling mode as the first type, setting a dispatch identifier for the second thread, and setting no transfer depth or the transfer depth as the minimum transfer depth for the second thread.
  12. 12. The method of claim 7, wherein the setting a scheduling flag and a depth of delivery to the minimum depth of delivery for a critical thread for processing the first input event comprises: dividing scheduling groups for threads corresponding to the first input event to obtain foreground process groups; Setting a scheduling identifier and a transfer depth to the minimum transfer depth for at least one third thread used for executing the first input event in the foreground process group, respectively, so as to add the at least one third thread Cheng Tian to an advanced process group, wherein the scheduling priority of threads in the advanced process group is higher than that of threads in the foreground process group; determining at least one fourth thread which has a dependency relationship with the at least one third thread and has a fixed thread name in threads for processing the first input event, setting a scheduling identifier and a transfer depth to the minimum transfer depth for the at least one fourth thread respectively, and adding the at least one fourth thread Cheng Tian to the advanced process packet.
  13. 13. A readable medium having stored thereon instructions which, when executed on an electronic device, cause the electronic device to perform the thread processing method of any of claims 1 to 12.
  14. 14. An electronic device comprising a memory for storing instructions for execution by one or more processors of the electronic device, and the processor being one of the processors of the electronic device for performing the thread processing method of any one of claims 1 to 12.
  15. 15. A computer program product, characterized in that the computer program product, when run on an electronic device, causes the electronic device to implement the thread processing method of any one of claims 1 to 12.

Description

Thread processing method, medium, electronic device, and program product Technical Field The present application relates to the field of terminal technologies, and in particular, to a thread processing method, a medium, an electronic device, and a program product. Background When a user uses an application in a terminal device, the response speed of the application, such as the start-up speed, is one of important indicators of the performance of a product. The slow response speed is usually represented by delayed click effect, waiting operation, long white screen time, etc. when the user performs touch operations such as clicking operation and sliding operation on the display screen. When a user performs a start operation on an application, such as a click operation on an icon of the application, a software system in the terminal device may receive a corresponding input interrupt event and call a corresponding process and related threads to process the input interrupt event to display a start animation of the application on a display screen and start the application. At this time, the starting speed may be measured by a duration from a receiving time of an input interrupt event of the application to a display time of a first frame image of the starting animation, and the starting speed is slower as the duration is larger. It will be appreciated that each process or thread requires certain hardware resources, such as processor resources, to be run. Then, when the terminal device runs the process and the related thread corresponding to the starting operation of the application, if the load of the terminal device is high, some threads corresponding to the starting operation may be preempted by processes and/or threads of other tasks for the processor resource. For example, dependent threads that have a dependency relationship with the critical thread corresponding to the launch operation may be preempted processor resources due to a lower call priority, blocking the critical threads, which in turn results in a slower launch speed of the application. Disclosure of Invention The embodiment of the application provides a thread processing method, a medium, electronic equipment and a program product, which can improve the response speed of displaying a starting animation on a display screen when an application is started. In a first aspect, an embodiment of the present application provides a thread processing method, applied to an electronic device, where the method includes, when a first thread invokes a second thread in a first invocation mode, determining whether the first thread and the second thread meet a dispatch identifier transfer condition, where the second thread is a thread related to starting an animation of the first application, determining a type of the first invocation mode when the dispatch identifier transfer condition is met, setting a dispatch identifier for the second thread when the type of the first invocation mode is determined to be the first type, and prohibiting setting a transfer depth for the second thread or setting the transfer depth of the second thread to be a minimum transfer depth, setting a dispatch identifier for the second thread when the type of the first invocation mode is determined to be the second type, and adjusting the transfer depth of the second thread according to the transfer depth of the first thread, where a dispatch priority of the thread with the dispatch identifier is higher than a dispatch priority of the thread without the dispatch identifier. It can be understood that when the scheduling identifier is transferred in the first type of calling mode, the transfer depth is not set to the called second thread or is set to 0, so that the situation that the scheduling identifier cannot be transferred normally for the second thread and the higher scheduling priority cannot be set for the second thread is avoided. Therefore, normal transmission of the transmission depth of the thread corresponding to the scheduling identifier can be ensured, and the scheduling identifier can be set by both the key thread and the related dependent thread in the application starting process, so that the threads can schedule the processor resource with higher scheduling priority, and the starting speed of the application is improved. In a possible implementation of the first aspect, the dispatch identifier transfer condition includes that a thread that initiates the call is provided with a dispatch identifier, and a transfer depth of the thread that initiates the call is smaller than a maximum transfer depth, such as 0. Then, when the thread that initiates the call, such as the first thread, satisfies the schedule identification transfer condition, it is stated that the transfer depth of the schedule identification in the first thread may be transferred to other threads. In a possible implementation of the first aspect, the dispatch identifier transfer condition further includes that th