Patentable/Patents/US-20250383916-A1
US-20250383916-A1

Thread Scheduling Method and Apparatus

PublishedDecember 18, 2025
Assigneenot available in USPTO data we have
Inventorsnot available in USPTO data we have
Technical Abstract

This application provides a thread scheduling method. The method includes: At a first moment, in response to a first instruction, a terminal device changes, based on the first instruction, a processing priority of a second thread from a first priority to a second priority before executing a first work, where a processing priority of the second priority is higher than a processing priority of the first priority, the second thread carries a first identifier after the first moment; the terminal device executes the first work based on the second thread having the second priority; and at a second moment, when the terminal device determines that there is no to-be-executed work in the second thread, and the second thread carries the first identifier, the terminal device skips restoring the processing priority of the second thread.

Patent Claims

Legal claims defining the scope of protection, as filed with the USPTO.

1

. A thread scheduling method, applied to a terminal device, wherein a first process and a first thread are run in the terminal device, the first thread is a thread used to process a work, the first process comprises a second thread, the second thread is a binder thread, and the second thread comprises a first work; and the method comprises:

2

. The method according to, wherein the second thread further comprises a second work; and after the second moment, the method further comprises:

3

. The method according to, wherein the second instruction comprises one or more of the following: a binder communication number, an interface descriptor, or an asynchronous communication identifier, wherein the binder communication number indicates a communication interface, the interface descriptor indicates a client and a server that perform communication, and the asynchronous communication identifier indicates a communication mode; and that the terminal device determines, based on the second instruction, to change the processing priority of the second thread from the first priority to the second priority comprises:

4

. The method according to, wherein a third thread is run in the terminal device after the first moment and before the third moment, the third thread is a thread of a binder call initiated by the second thread, and the third thread comprises a fourth work; and the method further comprises:

5

. The method according to, wherein the first work type comprises a work type indicating that a communication transaction is completed and handed over to an initiator for processing, and/or a work type indicating that a communication transaction fails and is handed over to the initiator for processing.

6

. The method according to, wherein a fourth thread is run in the terminal device after the first moment and before the third moment, the fourth thread is a thread of a synchronous binder call initiated by the second thread, and the fourth thread comprises a fifth work; and the method further comprises:

7

. The method according to, wherein the second work type comprises a work type replied by the server.

8

. The method according to, wherein the first work is a work identified by the terminal device when there is an asynchronous binder call, the second thread further comprises a seventh work, the seventh work is a work identified by the terminal device when there is a synchronous binder call, the second thread carries a second identifier before the second moment, and the second identifier indicates that the second thread is an asynchronous binder call; and before the second moment and after the first moment, the method further comprises:

9

. The method according to, wherein after the fifth moment, the method further comprises:

10

. The method according to, wherein the first thread is a thread for image synthesis, and the first process is a process for image drawing; or the first process is a process used to generate window data of window information, and the first thread is a thread used to update window information of a system.

11

. A terminal device, comprising a processor and a memory, wherein

12

. The terminal device according to, wherein the second thread further comprises a second work; and after the second moment, the terminal device is further enabled to:

13

. The terminal device according to, wherein the second instruction comprises one or more of the following: a binder communication number, an interface descriptor, or an asynchronous communication identifier, wherein the binder communication number indicates a communication interface, the interface descriptor indicates a client and a server that perform communication, and the asynchronous communication identifier indicates a communication mode; and that the terminal device determines, based on the second instruction, to change the processing priority of the second thread from the first priority to the second priority comprises:

14

. The terminal device according to, wherein a third thread is run in the terminal device after the first moment and before the third moment, the third thread is a thread of a binder call initiated by the second thread, and the third thread comprises a fourth work; and the terminal device is further enabled to:

15

. The terminal device according to, wherein the first work type comprises a work type indicating that a communication transaction is completed and handed over to an initiator for processing, and/or a work type indicating that a communication transaction fails and is handed over to the initiator for processing.

16

. The terminal device according to, wherein a fourth thread is run in the terminal device after the first moment and before the third moment, the fourth thread is a thread of a synchronous binder call initiated by the second thread, and the fourth thread comprises a fifth work; and the terminal device is further enabled to:

17

. The terminal device according to, wherein the second work type comprises a work type replied by the server.

18

. The terminal device according to, wherein the first work is a work identified by the terminal device when there is an asynchronous binder call, the second thread further comprises a seventh work, the seventh work is a work identified by the terminal device when there is a synchronous binder call, the second thread carries a second identifier before the second moment, and the second identifier indicates that the second thread is an asynchronous binder call; and before the second moment and after the first moment, the terminal device is further enabled to:

19

. The terminal device according to, wherein after the fifth moment, the terminal device is further enabled to:

20

. A computer-readable storage medium, configured to store a computer program, wherein when the computer program is run on a terminal device, the terminal device is enabled to perform:

Detailed Description

Complete technical specification and implementation details from the patent document.

PCT/CN2024/080655, filed on Mar. 7, 2024, which claims priority to Chinese Patent Application No. 202310623835.1, filed on May 29, 2023, both of which are incorporated herein by reference in their entireties.

This application is a continuation of International Application No.

This application relates to the field of terminal technologies, and in particular, to a thread scheduling method and apparatus.

With development of terminal technologies, terminal devices have become an important tool in people's lives. The terminal device needs to execute a plurality of works. For example, in a process of processing a work, the terminal device buffers work data of the work into a buffer area, and processes the work based on the work data in the buffer area. After completing processing the work, the terminal device releases the work data in the buffer area.

In the conventional technology, the terminal device releases the work data in the buffer area based on a binder thread; and the binder thread needs to wait to be scheduled before releasing the work data in the buffer area.

However, in the thread scheduling method, there is a case in which the binder thread cannot be scheduled in a timely manner, and consequently, the terminal device cannot process a new work in a timely manner.

Embodiments of this application provide a thread scheduling method and apparatus, so that a terminal device can delay restoration of a processing priority of a second thread, to reduce an occurrence of the second thread being in a runnable state.

According to a first aspect, an embodiment of this application provides a thread scheduling method, applied to a terminal device. A first process and a first thread are run in the terminal device, the first thread is a thread used to process a work, the first process includes a second thread, the second thread is a binder thread, and the second thread includes a first work. The method includes: At a first moment, in response to a first instruction, the terminal device changes, based on the first instruction, a processing priority of the second thread from a first priority to a second priority before executing the first work, where a processing priority of the second priority is higher than a processing priority of the first priority, the second thread carries a first identifier after the first moment, the first identifier indicates that the second thread is in a priority-elevated state, and the first instruction is an instruction corresponding to the first work; the terminal device executes the first work based on the second thread having the second priority; and at a second moment, when the terminal device determines that there is no to-be-executed work in the second thread, and the second thread carries the first identifier, the terminal device skips restoring the processing priority of the second thread. In this way, the terminal device can delay restoration of the processing priority of the second thread, to reduce an occurrence of the second thread being in a runnable state.

In a possible implementation, the second thread further includes a second work. After the second moment, the method further includes: At a third moment, in response to a second instruction, when the terminal device determines, based on the second instruction, to change the processing priority of the second thread from the first priority to the second priority, and the terminal device is at the second priority after the second moment, the terminal device skips restoring the processing priority of the second thread, and executes the second work based on the second thread having the second priority, where the second instruction is an instruction corresponding to the second work; or when the terminal device determines, based on the second instruction, not to change the processing priority of the second thread from the first priority to the second priority, and the terminal device is at the second priority after the second moment, the terminal device restores the second priority to the first priority, and executes the second work based on the second thread having the first priority.

It may be understood that, before a binder thread in the terminal device executes a next work, a binder driver may determine whether to restore a processing priority of the binder thread, so that a process of restoring the priority is delayed from an end of a current work to a start of the next work, to better resolve a long-term runnable problem caused by restoring the priority after the current work ends.

In a possible implementation, the second instruction includes one or more of the following: a binder communication number, an interface descriptor, or an asynchronous communication identifier. The binder communication number indicates a communication interface, the interface descriptor indicates a client and a server that perform communication, and the asynchronous communication identifier indicates a communication mode. That the terminal device determines, based on the second instruction, to change the processing priority of the second thread from the first priority to the second priority includes: When the second thread is determined based on the second instruction and the second thread meets a preset condition, the terminal device changes the processing priority of the second thread from the first priority to the second priority. The preset condition includes one or more of the following: The communication interface indicated by the binder communication number is a communication interface between the first thread and the second thread, the client that is indicated by the interface descriptor and that performs communication is the first thread and the server that is indicated by the interface descriptor and that performs communication is the second thread, or the asynchronous communication identifier indicates that the first thread and the second thread are in asynchronous binder communication. In this way, the terminal device can accurately identify a fixed binder call, and the terminal device can improve accuracy of performing priority processing on the binder thread.

In a possible implementation, a third thread is run in the terminal device after the first moment and before the third moment, the third thread is a thread of a binder call initiated by the second thread, and the third thread includes a fourth work. The method further includes: The terminal device inserts a third work into an execution queue of the second thread based on the third thread; in response to a third instruction, when the terminal device determines, based on the third instruction, to restore the processing priority of the second thread, and the third work meets a preset first work type, the terminal device skips restoring the processing priority of the second thread, where the third instruction is an instruction corresponding to the third work; the terminal device executes the third work based on the second thread having the second priority; and the terminal device executes the fourth work. In this way, before the work is executed, the binder driver in the terminal device may determine, based on Sand S, a processing priority of the binder call, and filter out a preset work that causes the priority of the binder thread to be restored in advance, to reduce an occurrence of the binder thread being in a runnable state.

In a possible implementation, the first work type includes a work type indicating that a communication transaction is completed and handed over to an initiator for processing, and/or a work type indicating that a communication transaction fails and is handed over to the initiator for processing.

In a possible implementation, a fourth thread is run in the terminal device after the first moment and before the third moment, the fourth thread is a thread of a synchronous binder call initiated by the second thread, and the fourth thread includes a fifth work. The method further includes: The terminal device inserts a sixth work into the second thread after executing the fifth work, where the sixth work indicates that the terminal device completes processing the fifth work; in response to a fourth instruction, when the terminal device determines, based on the fourth instruction, to restore the processing priority of the second thread, and the sixth work meets a preset second work type, the terminal device skips restoring the processing priority of the second thread, where the fourth instruction is an instruction corresponding to the sixth work; the terminal device executes the sixth work based on the second thread having the second priority; and the terminal device executes the fifth work. In this way, before the work is executed, the binder driver in the terminal device may determine, based on Sand S, a processing priority of the binder call, and filter out a preset work that causes the priority of the binder thread to be restored in advance, to reduce an occurrence of the binder thread being in a runnable state.

In a possible implementation, the second work type includes a work type replied by the server.

In a possible implementation, the first work is a work identified by the terminal device when there is an asynchronous binder call, the second thread further includes a seventh work, the seventh work is a work identified by the terminal device when there is a synchronous binder call, the second thread carries a second identifier before the second moment, and the second identifier indicates that the second thread is an asynchronous binder call. Before the second moment and after the first moment, the method further includes: At a fourth moment, in response to a fifth instruction, when the terminal device detects the seventh work and the second thread that carries the second identifier, the terminal device restores the processing priority of the second thread before executing the seventh work, where the fifth instruction is an instruction corresponding to the seventh work; and at a fifth moment, the terminal device changes the processing priority of the second thread from the first priority to the second priority, and processes the seventh work based on the second priority, where the fifth moment is after the fourth moment, the second thread is in a state of the synchronous binder call in a first time period after the fifth moment, and the second thread is in a state of the asynchronous binder call between the fourth moment and the fifth moment. In this way, when the terminal device detects a conflict between a work identified by a synchronous binder and a work identified by an asynchronous binder, a processing priority of an asynchronous call is first restored, and then a processing priority of a synchronous call is elevated. It may be understood that, in a period of time after the binder driver elevates the processing priority of the synchronous call of the binder thread, the binder thread follows a synchronous binder call solution.

In a possible implementation, after the fifth moment, the method further includes: At a sixth moment, the terminal device restores the processing priority of the second thread, where the processing priority of the second thread is at the first priority in a second time period after the sixth moment.

In a possible implementation, the first thread is a thread for image synthesis, and the first process is a process for image drawing; or the first process is a process used to generate window data of window information, and the first thread is a thread used to update window information of a system.

According to a second aspect, an embodiment of this application provides a thread scheduling apparatus. A first process and a first thread are run in the apparatus, the first thread is a thread used to process a work, the first process includes a second thread, the second thread is a binder thread, and the second thread includes a first work. At a first moment, in response to a first instruction, a processing unit is configured to change, based on the first instruction, a processing priority of the second thread from a first priority to a second priority before executing the first work, where a processing priority of the second priority is higher than a processing priority of the first priority, the second thread carries a first identifier after the first moment, the first identifier indicates that the second thread is in a priority-elevated state, and the first instruction is an instruction corresponding to the first work; an execution unit is further configured to execute the first work based on the second thread having the second priority; and at a second moment, when a terminal device determines that there is no to-be-executed work in the second thread, and the second thread carries the first identifier, the processing unit does not restore the processing priority of the second thread.

According to a third aspect, an embodiment of this application provides a terminal device, including a processor and a memory. The memory is configured to store a computer program. The processor is configured to invoke and execute the computer program, so that the terminal device performs the method according to any one of the first aspect and the possible implementations of the first aspect.

According to a fourth aspect, an embodiment of this application provides a computer-readable storage medium, configured to store a computer program. When the computer program is run on a computer, the computer is enabled to perform the method according to any one of the first aspect and the possible implementations of the first aspect.

According to a fifth aspect, this application provides a computer program product. When the computer program product runs on a computer, the computer is enabled to perform the method according to any one of the first aspect and the possible implementations of the first aspect.

It can be understood that for beneficial effects in the second aspect to the fifth aspect, reference may be made to the beneficial effects in any one of the first aspect and the possible implementations of the first aspect. Details are not repeated herein.

To clearly describe technical solutions in embodiments of this application, words such as “first” and “second” are used in embodiments of this application to distinguish between same items or similar items that have basically a same function or purpose. For example, a first value and a second value are merely intended to distinguish between different values, but not to limit a sequence of the values. A person skilled in the art may understand that the words such as “first” and “second” do not limit a quantity or an execution sequence, and the words such as “first” and “second” do not define a definite difference.

It should be noted that, in this application, the word such as “example” or “for example” is used to represent giving an example, an illustration, or a description. Any embodiment or design scheme described as an “example” or “for example” in this application should not be explained as being more preferred or having more advantages than another embodiment or design scheme. Exactly, use of the words such as “example” or “for example” is intended to present a related concept in a specific manner.

In this application, “at least one” means one or more, and “a plurality of” means two or more. The term “and/or” describes an association relationship between associated objects, and indicates that three relationships may exist. For example, A and/or B may indicate the following three cases: Only A exists, both A and B exist, and only B exists, where A and B may be singular or plural. The character “/” usually indicates an “or” relationship between the associated objects. “At least one of the following items (pieces)” or a similar expression thereof indicates any combination of these items, including a single item (piece) or any combination of a plurality of items (pieces). For example, at least one item (piece) of a, b, or c may represent: a, b, c, a and b, a and c, b and c, or a, b, and c, where a, b, and c may be singular or plural.

It should be noted that “when . . . ” in embodiments of this application may be an instantaneous occurrence time of a case, or may be a period of time after an occurrence of a case, and this is not specifically limited in embodiments of this application. In addition, a display interface provided in embodiments of this application is only used as an example, and the display interface may further include more or less content.

To better understand embodiments of this application, the following describes a structure of a terminal device in embodiments of this application. For example,is a diagram of a hardware structure of a terminal device according to an embodiment of this application. The terminal device may be referred to as a terminal (terminal), user equipment (user equipment, UE), a mobile station (mobile station, MS), a mobile terminal (mobile terminal, MT), or the like. For example, the terminal device may be a mobile phone (mobile phone), a smart television, a wearable device, a tablet computer (Pad), a computer having a wireless transceiver function, a virtual reality (virtual reality, VR) terminal device, an augmented reality (augmented reality, AR) terminal device, a wireless terminal in industrial control (industrial control), a wireless terminal in self-driving (self-driving), a wireless terminal in remote medical surgery (remote medical surgery), a wireless terminal in a smart grid (smart grid), a wireless terminal in transportation safety (transportation safety), a wireless terminal in a smart city (smart city), a wireless terminal in a smart home (smart home), or the like. A specific technology and a specific device form that are used by the terminal device are not limited in embodiments of this application.

As shown in, the terminal device may include a processor, an external memory interface, an internal memory, a universal serial bus (universal serial bus, USB) interface, a charging management module, a power management module, an antenna, an antenna, a mobile communication module, a wireless communication module, an audio module, a speakerA, a receiverB, a microphoneC, a headset jackD, a sensor module, a button, an indicator, a camera, a display, and the like.

The sensor modulemay include one or more of the following: for example, a pressure sensor, a gyroscope sensor, a barometric pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, an optical proximity sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, or a bone conduction sensor.

It may be understood that the structure shown in embodiments of this application does not constitute a specific limitation on the terminal device. In some other embodiments of this application, the terminal device may include more or fewer components than those shown in the figure, or combine some components, or split some components, or have different component arrangements. The components shown in the figure may be implemented by hardware, software, or a combination of software and hardware.

The processormay include one or more processing units. Different processing units may be independent devices, or may be integrated into one or more processors. A memory may be further disposed in the processor, and is configured to store instructions and data.

The USB interfaceis an interface that complies with a USB standard specification, and may be specifically a Mini USB interface, a Micro USB interface, a USB Type-C interface, or the like. The USB interfacemay be configured to connect to a charger to charge the terminal device, may be configured to transmit data between the terminal device and a peripheral device, or may be configured to connect to a headset, for audio playing through the headset. The interface may alternatively be configured to connect to another device, for example, an AR device.

The charging management moduleis configured to receive a charging input from the charger. The charger may be a wireless charger, or may be a wired charger. The power management moduleis configured to connect to the charging management moduleand the processor.

A wireless communication function of the terminal device may be implemented through the antenna, the antenna, the mobile communication module, the wireless communication module, a baseband processor, and the like.

The antennaand the antennaare configured to transmit and receive electromagnetic wave signals. The antenna in the terminal device may be configured to cover one or more communication frequency bands. Different antennas may be further multiplexed to improve antenna utilization.

The mobile communication modulemay provide a solution to wireless communication including 2G/3G/4G/5G and the like applied to the terminal device. The mobile communication modulemay include at least one filter, a switch, a power amplifier, a low noise amplifier (low noise amplifier, LNA), and the like. The mobile communication modulemay receive an electromagnetic wave through the antenna, perform processing such as filtering or amplification on the received electromagnetic wave, and transmit the electromagnetic wave to a modem for demodulation.

The wireless communication modulemay provide a solution to wireless communication including a wireless local area network (wirelesslocal area networks, WLAN) (such as a wireless fidelity (wireless fidelity, Wi-Fi) network), Bluetooth (bluetooth, BT), a global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), and the like applied to the terminal device.

The modem may include a modulator and a demodulator. The modulator is configured to modulate a to-be-sent low-frequency baseband signal into a medium-high frequency signal. The demodulator is configured to demodulate a received electromagnetic wave signal into a low-frequency baseband signal. Then, the demodulator transmits the low-frequency baseband signal obtained through demodulation to the baseband processor for processing. The low-frequency baseband signal is processed by the baseband processor and then transmitted to an application processor. The application processor outputs a sound signal through an audio device (which is not limited to a speaker, a receiver, or the like), or displays an image or a video through the display. In some embodiments, the modem may be an independent device. In some other embodiments, the modem may be independent of the processor, and is disposed in a same device as the mobile communication moduleor another functional module.

The terminal device implements a display function through a GPU, the display, the application processor, and the like. The GPU is a microprocessor for image processing, and is connected to the displayand the application processor. The GPU is configured to perform mathematical and geometric computing for graphics rendering.

The displayis configured to display an image, a video, or the like. The displayincludes a display panel. In some embodiments, the terminal device may include 1 or N displays, where N is a positive integer greater than 1.

The terminal device may implement a photographing function through an ISP, the camera, a video codec, the GPU, the display, the application processor, and the like.

The camerais configured to capture a still image or a video. In some embodiments, the terminal device may include 1 or N cameras, where N is a positive integer greater than 1.

The external memory interfacemay be configured to connect to an external storage card such as a Micro SD card, to extend a storage capability of the terminal device. The external storage card communicates with the processorthrough the external memory interface, to implement a data storage function. For example, music, video, and other files are stored in the external storage card.

The internal memorymay be configured to store computer-executable program code, where the executable program code includes instructions. The internal memorymay include a program storage area and a data storage area.

The terminal device may implement an audio function, for example, music playing or recording, through the audio module, the speakerA, the receiverB, the microphoneC, the headset jackD, the application processor, and the like.

The audio moduleis configured to convert digital audio information into an analog audio signal for output, and is also configured to convert an analog audio input into a digital audio signal. The speakerA, also referred to as a “loudspeaker”, is configured to convert an audio electrical signal into a sound signal. The terminal device may be used to listen to music or answer a call in a hands-free mode through the speakerA. The receiverB, also referred to as “earpiece”, is configured to convert an electrical audio signal into a sound signal. When the terminal device is used to answer a call or receive voice information, the receiverB may be put close to a human ear to listen to a voice. The headset jackD is configured to connect to a wired headset. The microphoneC, also referred to as a “mic” or a “mike”, is configured to convert a sound signal into an electrical signal. In embodiments of this application, the terminal device may have one microphoneC.

The buttonincludes a power on/off button, a volume button, or the like. The buttonmay be a mechanical button, or may be a touch button. The terminal device may receive a button input, and generate a button signal input related to user settings and function control of the terminal device. The indicatormay be an indicator light, may be configured to indicate a charging status or a power change, and may further be configured to indicate a message, a missed incoming call, a notification, and the like.

In addition, an operating system, for example, an iOS operating system, an Android (android) operating system, or a Windows operating system, is further run on the foregoing components of the device. An application may be installed and run on the operating system.

A software system of the terminal device may use a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, a cloud architecture, or the like. Details are not described herein. In embodiments of this application, an Android system of a layered architecture is used as an example to describe a software structure of the terminal device.

Patent Metadata

Filing Date

Unknown

Publication Date

December 18, 2025

Inventors

Unknown

Want to explore more patents?

Browse 5M+ US patents with plain-English claim translations and AI-generated analysis.

Citation & reuse

Analysis on this page is generated by Patentable — an AI-powered patent intelligence platform. AI-generated summaries, explanations, and analysis may be reused with attribution and a visible link back to the canonical URL below. Patent abstracts and claims are USPTO public domain.

Cite as: Patentable. “THREAD SCHEDULING METHOD AND APPARATUS” (US-20250383916-A1). https://patentable.app/patents/US-20250383916-A1

© 2026 Patentable. All rights reserved.

Patentable is a research and drafting-assistant tool, not a law firm, and does not provide legal advice. Documents we generate are drafts for review by a licensed patent attorney.

THREAD SCHEDULING METHOD AND APPARATUS | Patentable