CN109918141B - Thread execution method, thread execution device, terminal and storage medium - Google Patents

Thread execution method, thread execution device, terminal and storage medium Download PDF

Info

Publication number
CN109918141B
CN109918141B CN201910197390.9A CN201910197390A CN109918141B CN 109918141 B CN109918141 B CN 109918141B CN 201910197390 A CN201910197390 A CN 201910197390A CN 109918141 B CN109918141 B CN 109918141B
Authority
CN
China
Prior art keywords
thread
dependent
execution
key
critical
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910197390.9A
Other languages
Chinese (zh)
Other versions
CN109918141A (en
Inventor
王猛猛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN201910197390.9A priority Critical patent/CN109918141B/en
Publication of CN109918141A publication Critical patent/CN109918141A/en
Application granted granted Critical
Publication of CN109918141B publication Critical patent/CN109918141B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The embodiment of the application provides a thread execution method, a thread execution device, a terminal and a storage medium. The method comprises the following steps: identifying whether a critical thread exists in the threads in the blocking state; if the critical thread exists in the threads in the blocking state, determining a waiting chain of the critical thread; acquiring a thread execution strategy corresponding to a dependent thread; and executing the dependent thread according to the thread execution strategy corresponding to the dependent thread. According to the technical scheme provided by the embodiment of the application, under the condition that the key thread is determined to be in the blocking state, each thread depended by awakening the key thread is analyzed and obtained, then the thread execution strategy corresponding to each thread is obtained, and each thread is executed according to the thread execution strategy, so that the execution efficiency of each thread depended by awakening the key thread is improved, the time required by awakening the key thread is shortened, and the execution efficiency of the key thread is improved.

Description

Thread execution method, thread execution device, terminal and storage medium
Technical Field
The embodiment of the application relates to the technical field of terminals, in particular to a thread execution method, a thread execution device, a terminal and a storage medium.
Background
A thread is the smallest unit that an operating system can perform computational scheduling. The execution efficiency of the thread directly affects the use performance of the terminal.
In practical applications, an operating system generally determines an execution policy of a thread according to various factors, such as the execution priority of the thread, the power consumption of different Central Processing Units (CPUs), and the change of system load, and executes the thread according to the execution policy.
Disclosure of Invention
The embodiment of the application provides a thread execution method, a thread execution device, a terminal and a storage medium. The technical scheme is as follows:
in one aspect, an embodiment of the present application provides a method for executing a thread, where the method includes:
identifying whether a critical thread exists in the threads in the blocking state;
if the critical thread exists in the threads in the blocking state, determining a waiting chain of the critical thread, wherein the waiting chain comprises a dependent thread of the critical thread, and the dependent thread is a thread on which the critical thread is awakened;
acquiring a thread execution strategy corresponding to the dependent thread;
and executing the dependent thread according to the thread execution strategy corresponding to the dependent thread.
In another aspect, an embodiment of the present application provides a thread execution apparatus, where the apparatus includes:
the thread identification module is used for identifying whether a key thread exists in the threads in the blocking state;
a waiting chain determining module, configured to determine a waiting chain of the key thread if the key thread exists in the threads in the blocking state, where the waiting chain includes a dependent thread of the key thread, and the dependent thread is a thread on which the key thread is awakened;
the strategy acquisition module is used for acquiring a thread execution strategy corresponding to the dependent thread;
and the thread execution module is used for executing the dependent thread according to the thread execution strategy corresponding to the dependent thread.
In another aspect, an embodiment of the present application provides a terminal, where the terminal includes a processor and a memory, where the memory stores a computer program, and the computer program is loaded and executed by the processor to implement the thread execution method in the foregoing aspect.
In still another aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored, and the computer program is loaded and executed by a processor to implement the thread execution method according to the above aspect.
The technical scheme provided by the embodiment of the application can bring the following beneficial effects:
under the condition that the key thread is determined to be in the blocking state, each thread on which the key thread depends is analyzed and obtained, then a thread execution strategy corresponding to each thread is obtained, and each thread is executed according to the thread execution strategy, so that the execution efficiency of each thread on which the key thread depends is aroused is improved, the time required for the key thread to be aroused is shortened, and the execution efficiency of the key thread is improved.
Drawings
FIG. 1 is a flow diagram of a method for thread execution according to one embodiment of the present application;
FIG. 2 is a schematic diagram of a wait chain provided by another embodiment of the present application;
FIG. 3 is a flow diagram of a method for thread execution according to one embodiment of the present application;
FIG. 4 is a block diagram of a thread execution apparatus according to one embodiment of the present application;
fig. 5 is a block diagram of a terminal according to an embodiment of the present application.
Detailed Description
To make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
First, the related terms related to the present application will be described.
The key thread: refers to a thread that can affect the system performance, which can be intuitively perceived by a user, such as the rendering time, picture quality, frame rate, etc. of a currently displayed picture. The critical thread may be a rendering thread.
Dependent threads of a critical thread: refers to the thread on which the wake-critical thread depends. Critical threads need to rely on resources provided by the thread when executing, such as relying on execution results of the thread, synchronization locks, and the like. In this case, the critical thread needs to start executing after the dependent thread finishes executing.
Waiting chain of critical threads: the wait chain includes all dependent threads that wake up the critical thread, and the dependencies between all the dependent threads. The waiting chain comprises m branched chains, each branched chain comprises n stages of threads, m is a positive integer, and n is also a positive integer. Wherein, the value of n corresponding to each branched chain can be the same or different. The 1 st level thread in each branched chain refers to a thread on which a key thread is awakened, the i +1 th level thread in each branched chain refers to a thread on which the i th level thread is awakened, and the value of i is a positive integer less than or equal to n-1. And the awakening mode of the nth level thread in each branched chain is an interrupt mode.
An interruption mode: CPU suspends the execution of current program temporarily, transfers to the execution of interrupt processing program for random event service, and automatically resumes the execution of original program after the processing is finished.
A CPU big core: the CPU with a high operating frequency generally has an operating frequency of 2.6Ghz, and is mainly used for processing an operating type program, such as a game type application program, a live broadcast type application program, and the like. The number of CPU big cores may be 1, 2, 4, etc.
A CPU corelet: the CPU with lower running frequency is usually 2.1Ghz and is mainly used for processing common application programs. The number of CPU big cores may be 4, 6, 9, etc. The operating frequency of a large CPU core is typically greater than the operating frequency of a small CPU core.
In the related art, if a certain critical thread depends on the execution results of other threads during execution, the terminal executes the other threads first and then executes the critical thread, and at this time, if the execution priority of the other threads is low or the allocated system resources are less, the execution efficiency of the other threads is low, which results in low execution efficiency of the critical thread.
Based on this, the embodiment of the application provides a thread execution method, a thread execution device, a terminal and a storage medium. In the technical scheme provided by the embodiment of the application, under the condition that the key thread is determined to be in a blocked state, each thread on which the key thread depends is analyzed and obtained, then the thread execution strategy corresponding to each thread is obtained, and each thread is executed according to the thread execution strategy, so that the execution efficiency of each thread on which the key thread depends is awakened is improved, the time required for awakening the key thread is shortened, and the execution efficiency of the key thread is improved.
According to the technical scheme provided by the embodiment of the application, the execution main body of each step is the terminal. Optionally, an operating system runs in the terminal, and the operating system may also be an Android (Android) operating system or an IOS operating system. The execution subject of each step may also be an operating system. In the embodiments of the present application, only the main execution body of each step is described as an example.
Referring to fig. 1, a flowchart of a thread execution method according to an embodiment of the present application is shown. The method can be applied to a terminal, and comprises the following steps:
step 101, identifying whether a critical thread exists in the threads in the blocking state.
The blocked state is a state in which the thread gives up the CPU right of use for some reason and temporarily stops its operation. The reason a thread is in a blocked state may be as follows:
1) waiting for blocking, namely, enabling the thread to wait for the completion of certain work by calling a wait () method of the thread; 2) synchronous blocking, i.e., a thread fails to acquire a synchronized synchronous lock (because the lock is occupied by other threads), it enters a synchronous blocking state; 3) other blocking, i.e., a thread enters a blocked state by calling the thread's sleep () or join () or issuing an I/O request.
In the embodiment of the present application, the reason that the thread is in the blocking state is generally waiting for blocking and synchronizing the blocking.
The key thread refers to a thread that can affect the system performance, which can be intuitively perceived by a user, such as rendering time, picture quality, frame rate, and the like of a currently displayed picture.
Optionally, the key thread may be a rendering thread, and step 101 is specifically implemented as: and calling a preset interface in the operating system to identify whether a rendering thread exists in the threads in the blocking state.
In a possible implementation manner, when determining that the currently running application is the preset type of application, the terminal performs a step of subsequently identifying whether a critical thread exists in the threads in the blocking state. The preset type of application program may be a game type application program, a live type application program, a video call type application program, and the like. In another possible implementation manner, the terminal performs a subsequent step of identifying whether a critical thread exists in the threads in the blocking state when the current display screen meets the preset condition. The preset condition may be that the picture quality of the current display picture is lower than a preset value, or that the current display picture is stuck. The display screen is displayed in a display screen frame, where the display screen frame is displayed in a display screen frame, and the display screen frame is displayed in a display screen frame. The preset value, the preset frame rate, and the preset speed may be set according to actual requirements, which is not limited in the embodiments of the present application.
Step 102, if there is a critical thread in the threads in the blocking state, determining a waiting chain of the critical thread.
The waiting chain includes dependent threads of the critical thread. Dependent threads refer to threads on which wake-up critical threads depend. The number of dependent threads may be one or more. As explained in the above embodiments, the reasons for the blocking state may be waiting blocking, synchronous blocking, etc. In combination with the above reasons, in the embodiment of the present application, the dependent thread is a thread that provides a preset resource to the critical thread, and the preset resource may be an execution result of the dependent thread or a synchronization lock.
Alternatively, step 102 may be implemented as:
102a, determining a dependent thread in a historical wake-up record in a recursive manner;
the recursive method is a method of obtaining a result by using a recursive relationship triggered by an initial condition. The historical wake-up record is used to describe wake-up information of the critical thread during past execution.
Optionally, the dependent thread comprises m branches, m being a positive integer. Each of the m branched chains includes n stages, and n is a positive integer. The value of n corresponding to each branched chain can be the same or different. And the awakening mode of the nth level dependent thread in each branched chain is an interrupt mode. The interrupt mode is a mode that CPU temporarily stops the execution of the current program, transfers to execute an interrupt processing program for serving a certain random event and automatically recovers the execution of the original program after the processing is finished.
Optionally, step 102a is specifically implemented as:
1. determining the thread which awakens the key thread in the historical awakening record as a 1 st-level dependent thread in the kth branch chain, wherein k is a positive integer less than or equal to m;
2. and determining the thread which wakes up the ith level dependent thread in the kth branch chain in the historical wake-up record as the (i + 1) th level dependent thread in the kth branch chain, wherein i is a positive integer less than or equal to n-1.
Step 102b, add the dependent thread to the wait chain.
The terminal adds the above-mentioned respective dependent threads to the waiting chain. Optionally, the terminal stores the waiting chain after determining the waiting chain. The embodiment of the application does not limit the storage mode and the storage path of the standby chain. Optionally, the terminal stores the waiting chain in a list.
In one specific example, reference is made in conjunction with FIG. 2, which illustrates a schematic diagram of a wait chain as shown in one embodiment of the present application. The waiting chain for critical thread a includes 3 branches. The 1 st branched chain comprises a dependent thread B, and the awakening mode of the dependent thread B is an interrupt mode; the 2 nd branch chain comprises a 1 st level dependent thread C and a 2 nd level dependent thread E, the awakening mode of the 2 nd level dependent thread E is an interrupt mode, the 3 rd branch chain comprises a 1 st level dependent thread D and 2 nd level dependent threads F and G, and the awakening mode of the 2 nd level dependent threads F and G is an interrupt mode.
And 103, acquiring a thread execution strategy corresponding to the dependent thread.
The thread execution policy corresponding to the dependent thread is used to indicate how to execute the dependent thread. Optionally, step 103 may comprise: improving the execution priority of the dependent thread; and/or binding the dependent thread to a Central Processing Unit (CPU) big core.
The execution priority of the threads is used to indicate the execution order of the threads. The higher the execution priority of the thread is, the earlier the thread is executed; the lower the execution priority of a thread, the later the execution order of the thread. Generally, the thread in the execution state has the highest execution priority. In the embodiment of the application, the terminal increases the execution priority of the dependent thread, that is, the execution sequence of the dependent thread is advanced.
The CPU core is a CPU with a high operating frequency, and the operating frequency of the CPU core is usually 2.6Ghz, and is mainly used for processing an operating type program, such as a game type application program, a live broadcast type application program, and the like. The number of CPU big cores may be 1, 2, 4, etc.
Binding a dependent thread to a CPU core sets the affinity between the dependent thread and the CPU core, and then the dependent thread will only run on the bound CPU core. The binding of the dependent thread to the CPU megacore may be accomplished in a mask form or a list form, which is not limited in this application embodiment. The mask form is that the mask is converted into a binary form, the binary system converted by the mask is used for indicating the serial number of the kernel from the lowest bit to the highest bit, and when the value of a certain bit is 1, the kernel corresponding to the bit is bound. The list form means that the sequence number of the core to be bound is directly recorded in the list.
Optionally, when the number of the CPU megacores is multiple, the terminal detects the load of each CPU megacore, and determines the CPU megacore whose load meets a preset condition as the CPU megacore bound to the dependent thread. The preset condition may be that the load of the CPU core is lower than a preset value, or that the load of the CPU core is the lowest. The preset value can be set according to actual requirements, and the embodiment of the application does not limit the preset value.
In a specific example, step 103 is specifically implemented as:
1. detecting whether a CPU large core or a CPU small core is bound by the dependent thread;
if the terminal adopts a mask mode to carry out core binding, firstly determining the bit number of 1 in the binary number converted by the mask, then determining the CPU core bound by the dependent thread according to the bit number, and then judging whether the CPU core is a CPU big core or a CPU small core according to the running frequency of the bound CPU core.
If the terminal adopts a list form to bind, the terminal directly reads the CPU kernel bound by the dependent thread from the list, and then judges whether the CPU kernel is a CPU big kernel or a CPU small kernel according to the running frequency of the bound CPU kernel.
2. And if the dependent thread is bound to the CPU small core, the dependent thread and the CPU small core are unbound, and the dependent thread and the CPU large core are bound.
3. If the dependent thread is bound to the CPU big core, detecting whether the execution priority of the dependent thread is smaller than a preset level;
the preset level may be set according to actual requirements, and this is not limited in the embodiment of the present application.
4. And if the execution priority of the dependent thread is smaller than the preset level, the execution priority of the dependent thread is increased.
And 104, executing the dependent thread according to the thread execution strategy corresponding to the dependent thread.
And the terminal executes the dependent thread according to the acquired thread execution strategy.
Optionally, after the terminal finishes executing the dependent thread, the critical thread is switched from the blocking state to the ready state, and then is switched to the executing state.
In one specific example, reference is made in conjunction with FIG. 3, which illustrates a flow chart of a method for thread execution according to an embodiment of the present application. The terminal firstly identifies the closed thread in the blocking state, then searches the waiting chain of the key thread in a recursion mode, promotes the priority of the key thread and the thread in the waiting chain, and puts the thread to a large core for execution if necessary.
To sum up, according to the technical scheme provided by the embodiment of the application, under the condition that it is determined that the key thread is in the blocked state, each thread on which the key thread depends is analyzed and obtained, then the thread execution strategy corresponding to each thread is obtained, and each thread is executed according to the thread execution strategy, so that the execution efficiency of each thread on which the key thread depends is awakened is improved, the time required for awakening the key thread is shortened, and the execution efficiency of the key thread is improved.
During the running process of the application program, a user interacts with the application program, at this time, the terminal executes the next task according to the interactive operation executed by the user, at this time, the key thread required to be run by the terminal is also constantly changing, and the key thread stored in the list by the terminal and the waiting chain of the key thread also need to be updated in time. In an alternative embodiment provided based on the embodiment shown in fig. 1, the method further comprises:
1. whether the key thread has an association relation with a real-time task of an application program running in the foreground or not.
The real-time task refers to a task to be executed within a preset time length, and the preset time length can be set according to actual requirements, which is not limited in the embodiment of the application.
The fact that the key thread and the real-time task have the association relation means that the terminal can display the real-time task after the key thread is executed. The fact that the key thread does not have an association relation with the real-time task means that the terminal cannot display the real-time task after the key thread is executed.
Optionally, the terminal monitors whether an interactive operation triggered by a user and corresponding to an application program running in the foreground is received, and if the terminal monitors that the interactive operation is received, it is detected whether the key thread has an association relationship with a real-time task of the application program running in the foreground.
In other possible implementation manners, the terminal detects whether the key thread has an association relationship with a real-time task of the application program running in the foreground at intervals of preset time, and the preset time can be set according to actual requirements, which is not limited in the embodiment of the present application.
2. And if the key thread does not have an association relation with the real-time task, deleting the key thread and the waiting chain of the key thread.
And if the key thread does not have an association relation with the real-time task, deleting the key thread in the list and the waiting chain of the key thread by the terminal so as to update the list.
A user may interact with the application program in the running process of the application program, and the terminal displays different pictures according to the interactive operation performed by the user, so that the key threads to be run in the terminal are constantly changing. In the embodiment of the application, the terminal updates the list of the storage waiting chain according to the real-time task, avoids the interactive operation executed by the terminal responding to the user after executing unnecessary key threads, and can reduce the time required by the terminal to respond to the interactive operation of the user.
In summary, according to the technical scheme provided by the embodiment of the application, the key threads stored in the list and the waiting chains of the key threads are updated according to the real-time task of the application program running in the foreground, so that the terminal can be prevented from responding to the interactive operation executed by the user after executing unnecessary key threads, and the time required by the terminal to respond to the interactive operation of the user is reduced.
Referring to fig. 4, a block diagram of a thread execution apparatus according to an embodiment of the present application is shown. The apparatus may include: a thread identification module 401, a wait chain determination module 402, a policy acquisition module 403, and a thread execution module 404.
The thread identifying module 401 is configured to identify whether a critical thread exists in the threads in the blocking state.
A waiting chain determining module 402, configured to determine a waiting chain of the critical thread if the critical thread exists in the threads in the blocking state, where the waiting chain includes a dependent thread of the critical thread, and the dependent thread is a thread on which the critical thread is waken up.
A policy obtaining module 403, configured to obtain a thread execution policy corresponding to the dependent thread.
And a thread executing module 404, configured to execute the dependent thread according to a thread executing policy corresponding to the dependent thread.
To sum up, according to the technical scheme provided by the embodiment of the application, under the condition that it is determined that the key thread is in the blocked state, each thread on which the key thread depends is analyzed and obtained, then the thread execution strategy corresponding to each thread is obtained, and each thread is executed according to the thread execution strategy, so that the execution efficiency of each thread on which the key thread depends is awakened is improved, the time required for awakening the key thread is shortened, and the execution efficiency of the key thread is improved.
In an optional embodiment provided on the basis of the embodiment of fig. 4, the wait chain determining module 402 is configured to:
determining the dependent thread in a historical wake-up record through a recursive mode, wherein the recursive mode is a mode of obtaining a result by utilizing a recursive relation after being triggered by an initial condition;
adding the dependent thread to the wait chain.
Optionally, the dependent thread includes m branched chains, each branched chain in the m branched chains includes n stages, m is a positive integer, n is a positive integer, and an awakening mode of an nth stage dependent thread in each branched chain is an interrupt mode;
the wait chain determining module 402 is configured to:
determining the thread wakening the key thread in the historical wakening record as a 1 st-level dependent thread in a kth branch chain, wherein k is a positive integer less than or equal to m;
determining the thread wakening the ith level dependent thread in the kth branch chain in the historical wakening record as the (i + 1) th level dependent thread in the kth branch chain, wherein i is a positive integer less than or equal to n-1.
In an optional embodiment provided based on the embodiment shown in fig. 4, the policy obtaining module 403 is configured to increase the execution priority of the dependent thread; and/or binding the dependent thread to a Central Processing Unit (CPU) big core.
Optionally, the policy obtaining module 403 is configured to:
detecting whether the dependent thread is bound to the CPU big core or the CPU small core;
if the dependent thread is bound to the CPU small core, the dependent thread and the CPU small core are unbound, and the dependent thread and the CPU large core are bound;
if the dependent thread is bound to the CPU big core, detecting whether the execution priority of the dependent thread is smaller than a preset level;
and if the execution priority of the dependent thread is smaller than the preset level, the execution priority of the dependent thread is increased.
In an optional embodiment provided based on the embodiment shown in fig. 4, the critical thread is a rendering thread, and the thread identifying module 401 is configured to invoke a preset interface in an operating system to identify whether the rendering thread exists in the threads in the blocking state.
In an optional embodiment provided based on the embodiment shown in fig. 4, the apparatus further comprises: a first detection module and a deletion module (not shown in the figure).
And the first detection module is used for detecting whether the key thread has an association relation with a real-time task of the application program running in the foreground.
And the deleting module is used for deleting the key thread and the waiting chain of the key thread if the association relationship does not exist between the key thread and the real-time task.
Optionally, the apparatus further comprises: a second detection module (not shown).
A second detection module for detecting whether an interactive operation corresponding to the application program running in the foreground is received;
the first detection module is configured to, if the interactive operation is detected, execute the step of detecting whether the key thread has an association relationship with a real-time task of an application program running in a foreground.
It should be noted that, when the apparatus provided in the foregoing embodiment implements the functions thereof, only the division of the functional modules is illustrated, and in practical applications, the functions may be distributed by different functional modules according to needs, that is, the internal structure of the apparatus may be divided into different functional modules to implement all or part of the functions described above. In addition, the apparatus and method embodiments provided by the above embodiments belong to the same concept, and specific implementation processes thereof are described in the method embodiments for details, which are not described herein again.
Referring to fig. 5, a block diagram of a terminal according to an exemplary embodiment of the present application is shown. A terminal in the present application may include one or more of the following components: a processor 510 and a memory 520.
Processor 510 may include one or more processing cores. The processor 510 connects various parts within the overall terminal using various interfaces and lines, and performs various functions of the terminal and processes data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 520 and calling data stored in the memory 520. Alternatively, the processor 510 may be implemented in hardware using at least one of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). Processor 510 may integrate one or a combination of a Central Processing Unit (CPU) and a modem. Wherein, the CPU mainly processes an operating system, an application program and the like; the modem is used to handle wireless communications. It is understood that the modem may not be integrated into the processor 510, but may be implemented by a single chip.
Alternatively, the thread execution methods provided by the various method embodiments described below are implemented by the processor 510 when executing program instructions in the memory 520.
The Memory 520 may include a Random Access Memory (RAM) or a Read-Only Memory (Read-Only Memory). Optionally, the memory 520 includes a non-transitory computer-readable medium. The memory 520 may be used to store instructions, programs, code sets, or instruction sets. The memory 520 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function, instructions for implementing the various method embodiments described above, and the like; the storage data area may store data created according to the use of the terminal, and the like.
The structure of the terminal described above is only illustrative, and in actual implementation, the terminal may include more or less components, such as: a display screen, etc., which are not limited in this embodiment.
Those skilled in the art will appreciate that the configuration shown in fig. 5 is not intended to be limiting of terminal 500 and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components may be used.
In an exemplary embodiment, a computer readable storage medium is also provided, in which a computer program is stored, which is loaded and executed by a processor of a terminal to implement the respective steps in the above-described method embodiments.
In an exemplary embodiment, a computer program product is also provided for implementing the functions of the individual steps in the above-described method embodiments when the computer program product is executed.
It should be understood that reference to "a plurality" herein means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
The above description is only exemplary of the present application and should not be taken as limiting the present application, and any modifications, equivalents, improvements and the like that are made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (9)

1. A method of thread execution, the method comprising:
identifying whether a critical thread exists in the threads in the blocking state;
if the critical thread exists in the threads in the blocking state, determining a waiting chain of the critical thread, wherein the waiting chain comprises a dependent thread of the critical thread, the dependent thread is a thread on which the critical thread is awakened, and the dependent thread is used for providing an execution result and/or a synchronous lock of the dependent thread for the critical thread;
detecting whether an interactive operation corresponding to an application program running in a foreground is received;
if the interactive operation is detected, detecting whether the key thread has an incidence relation with the real-time task of the application program running in the foreground;
if the key thread and the real-time task have the incidence relation, acquiring a thread execution strategy corresponding to the dependent thread, and executing the dependent thread according to the thread execution strategy corresponding to the dependent thread;
and if the key thread and the real-time task do not have the incidence relation, deleting the key thread and a waiting chain of the key thread.
2. The method of claim 1, wherein determining the wait chain for the critical thread comprises:
determining the dependent thread in a historical wake-up record through a recursive mode, wherein the recursive mode is a mode of obtaining a result by utilizing a recursive relation after being triggered by an initial condition;
adding the dependent thread to the wait chain.
3. The method of claim 2, wherein the dependent thread comprises m branches, each of the m branches comprises n levels, m is a positive integer, n is a positive integer, and the nth level of the branch is an interrupt dependent thread;
the determining the dependent thread in the historical wake-up record in a recursive manner includes:
determining the thread wakening the key thread in the historical wakening record as a 1 st-level dependent thread in a kth branch chain, wherein k is a positive integer less than or equal to m;
determining the thread wakening the ith level dependent thread in the kth branch chain in the historical wakening record as the (i + 1) th level dependent thread in the kth branch chain, wherein i is a positive integer less than or equal to n-1.
4. The method of claim 1, wherein obtaining the thread execution policy corresponding to the dependent thread comprises:
increasing the execution priority of the dependent thread; and/or binding the dependent thread to a Central Processing Unit (CPU) big core.
5. The method of claim 4, wherein said increasing the execution priority of the dependent thread; and/or binding the dependent thread to a Central Processing Unit (CPU) big core, comprising:
detecting whether the dependent thread is bound to the CPU big core or the CPU small core;
if the dependent thread is bound to the CPU small core, the dependent thread and the CPU small core are unbound, and the dependent thread and the CPU large core are bound;
if the dependent thread is bound to the CPU big core, detecting whether the execution priority of the dependent thread is smaller than a preset level;
and if the execution priority of the dependent thread is smaller than the preset level, the execution priority of the dependent thread is increased.
6. The method of any of claims 1 to 5, wherein the critical threads are rendering threads, and wherein the identifying whether a critical thread exists in the threads in the blocked state comprises:
and calling a preset interface in an operating system to identify whether the rendering thread exists in the threads in the blocking state.
7. A thread execution apparatus, comprising:
the thread identification module is used for identifying whether a key thread exists in the threads in the blocking state;
a wait chain determining module, configured to determine a wait chain of the critical thread if the critical thread exists in the threads in the blocked state, where the wait chain includes a dependent thread of the critical thread, the dependent thread is a thread on which the critical thread is woken up, and the dependent thread is used to provide an execution result and/or a synchronization lock of the dependent thread to the critical thread;
the second detection module is used for detecting whether the interactive operation corresponding to the application program running in the foreground is received or not;
the first detection module is used for detecting whether the key thread has an association relation with the real-time task of the application program running in the foreground or not if the interactive operation is detected;
a policy obtaining module, configured to obtain a thread execution policy corresponding to the dependent thread if the association relationship exists between the key thread and the real-time task; the thread execution module is used for executing the dependent thread according to the thread execution strategy corresponding to the dependent thread if the incidence relation exists between the key thread and the real-time task;
and the deleting module is used for deleting the key thread and the waiting chain of the key thread if the association relationship does not exist between the key thread and the real-time task.
8. A terminal, characterized in that the terminal comprises a processor and a memory, the memory storing a computer program that is loaded and executed by the processor to implement the thread execution method according to any of claims 1 to 6.
9. A computer-readable storage medium, in which a computer program is stored, which is loaded and executed by a processor to implement the thread execution method according to any one of claims 1 to 6.
CN201910197390.9A 2019-03-15 2019-03-15 Thread execution method, thread execution device, terminal and storage medium Active CN109918141B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910197390.9A CN109918141B (en) 2019-03-15 2019-03-15 Thread execution method, thread execution device, terminal and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910197390.9A CN109918141B (en) 2019-03-15 2019-03-15 Thread execution method, thread execution device, terminal and storage medium

Publications (2)

Publication Number Publication Date
CN109918141A CN109918141A (en) 2019-06-21
CN109918141B true CN109918141B (en) 2020-11-27

Family

ID=66965024

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910197390.9A Active CN109918141B (en) 2019-03-15 2019-03-15 Thread execution method, thread execution device, terminal and storage medium

Country Status (1)

Country Link
CN (1) CN109918141B (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111538580B (en) * 2020-04-23 2024-01-05 苏州大学 Thread signal operation method and system of embedded real-time operating system
CN111767124A (en) * 2020-06-03 2020-10-13 Oppo广东移动通信有限公司 Request response method, device, storage medium and electronic equipment
CN111767138A (en) * 2020-06-09 2020-10-13 Oppo广东移动通信有限公司 Resource allocation method, storage medium, and electronic device
CN111782410B (en) * 2020-06-30 2023-06-27 抖音视界有限公司 Lock jam monitoring method and device, electronic equipment and computer readable medium
CN111831462A (en) * 2020-07-01 2020-10-27 Oppo广东移动通信有限公司 IO request processing method and device, storage medium and electronic equipment
CN112328392A (en) * 2020-10-27 2021-02-05 金蝶软件(中国)有限公司 Data processing method and related equipment
CN113377517B (en) * 2021-06-28 2023-02-28 上海鲲宜软件技术有限公司 Thread scheduling method and system based on real-time operating system
CN116701320A (en) * 2022-12-01 2023-09-05 荣耀终端有限公司 Log generation method and related device
CN117130769A (en) * 2023-02-25 2023-11-28 荣耀终端有限公司 Frequency modulation method, training method of frequency adjustment neural network and electronic equipment
CN116578422A (en) * 2023-06-15 2023-08-11 荣耀终端有限公司 Resource allocation method and electronic equipment
CN116737346B (en) * 2023-08-14 2023-10-24 南京翼辉信息技术有限公司 Scheduling configuration system for large and small core processors and implementation method thereof

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1955931A (en) * 2005-09-30 2007-05-02 科威尔公司 Scheduling in a multicore architecture
CN109144863A (en) * 2018-08-10 2019-01-04 广东电网有限责任公司信息中心 A kind of automated testing method based on network system
CN109213601A (en) * 2018-09-12 2019-01-15 华东师范大学 A kind of load-balancing method and equipment based on CPU-GPU
CN109426563A (en) * 2017-08-31 2019-03-05 华为技术有限公司 A kind of process management method and device

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8336762B1 (en) * 2008-11-17 2012-12-25 Greenwise Bankcard LLC Payment transaction processing
US10235220B2 (en) * 2012-01-23 2019-03-19 Advanced Micro Devices, Inc. Multithreaded computing
US20140258697A1 (en) * 2013-03-07 2014-09-11 Mips Technologies, Inc. Apparatus and Method for Transitive Instruction Scheduling
CN104111848B (en) * 2014-06-27 2017-04-26 华中科技大学 Multi-thread software dynamic upgrading method based on asynchronous check points
CN105955567B (en) * 2016-04-21 2019-07-26 北京元心科技有限公司 Method and device for displaying user interface and progress bar
CN107133092A (en) * 2017-05-24 2017-09-05 努比亚技术有限公司 Multi-thread synchronization processing method, terminal and computer-readable recording medium
CN107402813B (en) * 2017-06-21 2020-10-30 泰州市元和达电子科技有限公司 Resource allocation method, mobile terminal and computer readable storage medium
CN108509260B (en) * 2018-01-31 2021-08-13 深圳市万普拉斯科技有限公司 Thread identification processing method and device, computer equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1955931A (en) * 2005-09-30 2007-05-02 科威尔公司 Scheduling in a multicore architecture
CN109426563A (en) * 2017-08-31 2019-03-05 华为技术有限公司 A kind of process management method and device
CN109144863A (en) * 2018-08-10 2019-01-04 广东电网有限责任公司信息中心 A kind of automated testing method based on network system
CN109213601A (en) * 2018-09-12 2019-01-15 华东师范大学 A kind of load-balancing method and equipment based on CPU-GPU

Also Published As

Publication number Publication date
CN109918141A (en) 2019-06-21

Similar Documents

Publication Publication Date Title
CN109918141B (en) Thread execution method, thread execution device, terminal and storage medium
CN106802826B (en) Service processing method and device based on thread pool
CN103984598B (en) method and system for thread scheduling
CN107491346B (en) Application task processing method, device and system
CN103761182A (en) Method and device for deadlock detection
US10467054B2 (en) Resource management method and system, and computer storage medium
CN111897637B (en) Job scheduling method, device, host and storage medium
CN105760216A (en) Multi-process synchronization control method
CN102023899B (en) Multithreaded data synchronization method and device
CN113010275A (en) Interrupt processing method and device
CN107436672B (en) Application processing method and terminal
US20230409391A1 (en) Thread priority adjusting method, terminal, and computer-readable storage medium
CN100583047C (en) Method for synchronizing real-time interruption with multiple progress states
CN111984402A (en) Unified scheduling monitoring method and system for thread pool
CN101349975B (en) Method for implementing interrupt bottom semi-section mechanism in embedded operation system
CN114116015B (en) Method and system for managing hardware command queue
CN115658153A (en) Sleep lock optimization method and device, electronic equipment and storage medium
CN116048762A (en) Computer resource scheduling system based on historical data analysis
CN115587049A (en) Memory recovery method and device, electronic equipment and storage medium
CN109413489B (en) Serial multi-thread bullet screen distribution method, device, equipment and storage medium
CN109246470B (en) Multi-thread synchronous bullet screen distribution method, device, equipment and storage medium
CN110442404A (en) A kind of object method for releasing, device, equipment and storage medium
CN107608498B (en) Application program management method and terminal equipment
CN114064227A (en) Interrupt processing method, device, equipment and storage medium applied to microkernel
CN108733480B (en) CT reconstruction architecture design method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant