Thread processing method and device, electronic equipment and computer readable storage medium
By responding to core binding requests in the kernel and using asynchronous threads to perform core binding processing, the problem that thread core binding operations in existing technologies are limited to scenarios where scheduling switching is allowed is solved, thus improving convenience and user experience in situations where scheduling switching is not allowed.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN TCL DIGITAL TECH CO LTD
- Filing Date
- 2025-12-11
- Publication Date
- 2026-04-14
AI Technical Summary
The existing thread binding core operation can only be performed in scenarios where scheduling is allowed, and cannot be performed in scenarios where scheduling is not allowed, resulting in limitations and inconveniences in the core binding operation.
By responding to core binding requests in the kernel and using asynchronous threads to perform core binding, thread core binding operations can be achieved without relying on switching and scheduling of other threads.
Even in scenarios where scheduling is not allowed, thread-core binding operations can be implemented, improving the convenience and user experience of core binding operations.
Smart Images

Figure CN121858271A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of thread processing technology, specifically to a thread processing method, apparatus, electronic device, and computer-readable storage medium. Background Technology
[0002] With the updates and iterations of Android versions, various application scenarios have also diversified. For example, thread binding to cores is a technique that fixes a thread to run on a specific CPU core, aiming to optimize thread processing. For instance, binding threads corresponding to high-priority business operations to high-performance, high-power cores can optimize the execution scheduling of such business operations or threads, thereby improving the user experience.
[0003] However, the current core binding operation is only applicable to scenarios where switching to schedule other threads is allowed. For example, the core binding operation on the current thread can be achieved by switching to schedule other threads. In scenarios where switching to schedule other threads is not allowed, the core binding operation cannot be performed, resulting in limitations and inconveniences in the core binding operation. Summary of the Invention
[0004] This application provides a thread processing method, apparatus, electronic device, and computer-readable storage medium, which can improve the convenience of thread core binding operations.
[0005] In a first aspect, embodiments of this application provide a thread processing method, the method comprising: The kernel responds to the core binding request for the target thread and determines the core binding information of the target thread; Using the kernel and the kernel binding information, the target thread is bound to the kernel using an asynchronous thread to obtain the thread binding result.
[0006] Secondly, embodiments of this application also provide a thread processing apparatus, the apparatus comprising: The determination module is used to respond to a core binding request for a target thread through the kernel and determine the core binding information of the target thread; The core binding module is used to perform core binding processing on the target thread using an asynchronous thread based on the kernel and the core binding information, so as to obtain the thread core binding result.
[0007] Optionally, in some embodiments of this application, before obtaining the thread binding result by using an asynchronous thread to perform core binding processing on the target thread through the kernel and the core binding information, the method further includes: The kernel sends the kernel binding information to an information queue, which includes a first-in-first-out (FIFO) queue. The process of using the kernel and the kernel binding information to perform kernel binding on the target thread using an asynchronous thread to obtain the thread kernel binding result includes: The kernel controls the asynchronous thread to read the kernel binding information from the information queue; Furthermore, the kernel controls the asynchronous thread to perform core binding processing on the target thread based on the read core binding information, thereby obtaining the thread core binding result.
[0008] Optionally, in some embodiments of this application, the step of controlling the asynchronous thread through the kernel to perform core binding processing on the target thread based on the read core binding information, and obtaining the thread core binding result, includes: The kernel controls the asynchronous thread to call the core binding interface based on the read core binding information to perform core binding processing on the target thread, thereby obtaining the core binding result of the thread; The core binding interface includes an interface based on sched.
[0009] Optionally, in some embodiments of this application, the step of controlling the asynchronous thread through the kernel to read the kernel binding information from the information queue includes: If the core binding information is detected in the information queue, the asynchronous thread is invoked from the waiting queue, and the core binding information is read from the information queue through the asynchronous thread.
[0010] Optionally, in some embodiments of this application, the core binding information includes core binding instruction information or thread identification information. The core binding instruction information is used to indicate core binding or unbinding, and the thread identification information is used to identify the target thread to be bound to the core.
[0011] Optionally, in some embodiments of this application, the method further includes: The target thread's core binding status information is obtained in real time through the asynchronous thread; Output the core binding status information.
[0012] Optionally, in some embodiments of this application, the method further includes: The first core binding feature information of the target thread is determined based on the core binding information; Generate core binding prompt information based on the second core binding feature information and the first core binding feature information of the already bound core thread; Output the core binding prompt information.
[0013] Thirdly, embodiments of this application also provide an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the steps in the thread processing method described above.
[0014] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in the thread processing method described above.
[0015] Fifthly, embodiments of this application also provide a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the various optional implementations described in embodiments of this application.
[0016] In summary, the embodiments of this application respond to the core binding request for the target thread through the kernel and determine the core binding information of the target thread. Through the kernel and the core binding information, the target thread is processed by an asynchronous thread to obtain the core binding result.
[0017] In this embodiment, the thread-core binding operation is implemented through asynchronous threads, so that the thread-core binding operation does not depend on the switching and scheduling of other threads. This allows thread-core binding to be implemented even in scenarios where switching and scheduling are not allowed, improving the convenience of thread-core binding operation and enhancing the user experience. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a schematic diagram illustrating a scenario where a terminal device, according to an embodiment of this application, executes the thread processing method. Figure 2 This is a flowchart illustrating the thread processing method provided in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of the thread processing device provided in the embodiments of this application; Figure 4 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0020] The technical solutions of this application will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0021] In the description of the embodiments of this application, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientation or positional relationships based on the orientation or positional relationships shown in the accompanying drawings, are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the present invention. Furthermore, the terms "first," "second," "third," and "fourth" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, features defined with "first," "second," "third," and "fourth" may explicitly or implicitly include one or more features. In the description of the present invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0022] In this application, the term "exemplary" is used to mean "serving as an example, illustration, or description." Any embodiment described as "exemplary" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to make and use the invention. Details are set forth in the following description for purposes of explanation. It should be understood that those skilled in the art will recognize that the invention can be made without using these specific details. In other instances, well-known structures and processes will not be described in detail to avoid obscuring the description of the invention with unnecessary detail. Therefore, the invention is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed in this application.
[0023] This application provides a thread processing method, apparatus, electronic device, and computer-readable storage medium. Specifically, this application provides a thread processing apparatus suitable for electronic devices, which include terminal devices or servers. The terminal devices include, but are not limited to, mobile phones, tablets, laptops, or televisions. The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. The server can be directly or indirectly connected via wired or wireless communication.
[0024] For example, please see Figure 1 , Figure 1 This is a schematic diagram illustrating a scenario where a terminal device, according to an embodiment of this application, executes the thread processing method. Specifically, the execution process of the thread processing method by the terminal device is as follows: Terminal device 101 responds to the core binding request for the target thread through the kernel and determines the core binding information of the target thread. Using the kernel and the core binding information, it uses an asynchronous thread to perform core binding processing on the target thread and obtains the thread core binding result.
[0025] For example, a user or terminal device generates a core binding request after initiating a core binding operation for a target thread based on business needs. The terminal device responds to the core binding request through its kernel and determines the core binding information corresponding to the target thread. Then, the kernel of the terminal device calls an asynchronous thread and uses the core binding information to perform core binding processing on the target thread, obtaining the thread core binding result.
[0026] In summary, the embodiments of this application implement thread-core binding operation through asynchronous thread, so that thread-core binding operation does not depend on the switching and scheduling of other threads. This enables thread-core binding to be implemented even in scenarios where switching and scheduling are not allowed, improving the convenience of thread-core binding operation and enhancing user experience.
[0027] The following sections provide detailed descriptions of each example. It should be noted that the order in which the embodiments are described is not intended to limit the priority of the embodiments.
[0028] Please see Figure 2 , Figure 2This is a flowchart illustrating a thread processing method provided in an embodiment of this application. Although the flowchart shows a logical order, in some cases, the steps shown or described may be executed in a different order than that shown in the flowchart. Specifically, this thread processing method is applied to a terminal device, and the specific flow of the thread processing method is as follows: S201. The kernel responds to the core binding request for the target thread and determines the core binding information of the target thread.
[0029] The target thread is the thread that needs to be bound to the core in this application embodiment. The target thread can be a thread for each application.
[0030] The kernel is the core component of the Linux operating system. It is an open-source system software that runs on top of computer hardware. It is responsible for managing the computer's low-level resources (such as CPU, memory, input / output devices, etc.) and providing a stable and efficient operating environment for upper-level applications.
[0031] A core binding request is a request to perform a core binding operation, which involves binding a thread to a CPU (such as a CPU core, i.e., a physical core or a logical core). This core binding request can be generated based on business needs; for example, after configuring priorities for various applications, a user might bind the threads of higher-priority applications to CPUs.
[0032] The core binding information refers to the instruction information for core binding operations, including core binding or unbinding. Core binding means binding a thread to a CPU, allowing the thread to be scheduled to run only on that CPU; while unbinding refers to the unbinding operation after core binding, such as unbinding the thread from the CPU, allowing the thread to be scheduled to run on another CPU. In addition, in this embodiment, the core binding information may also include the object of core binding, that is, the core binding information also includes thread identification information to indicate which thread is being bound. For example, in this embodiment, the object of core binding includes the target thread.
[0033] It is understood that the embodiments of this application realize kernel-based binding by responding to the kernel binding request, and by determining the kernel binding information corresponding to the target thread, it helps to perform the expected operation based on the kernel binding information and obtain the expected processing result.
[0034] S202. Using the kernel and the kernel binding information, the target thread is bound to the kernel using an asynchronous thread to obtain the thread binding result.
[0035] It is understandable that by executing the core binding operation of the target thread through an asynchronous thread, instead of switching and scheduling other threads to perform the core binding operation, the core binding operation can be performed even in scenarios where switching and scheduling other threads is not allowed, thus improving the convenience of the core binding operation.
[0036] For example, the current core binding operation only applies to process context scenarios, meaning it relies on the ability of process contexts to switch and schedule other threads to bind the current thread to the core. However, in atomic context scenarios, switching and scheduling other threads is not allowed, making thread core binding impossible.
[0037] The embodiments of this application implement thread-core binding operation through asynchronous thread, so that thread-core binding operation does not depend on the switching and scheduling of other threads. This enables thread-core binding to be implemented even in scenarios where switching and scheduling are not allowed, improving the convenience of thread-core binding operation and enhancing user experience.
[0038] As is understandable, asynchronous threads refer to threads that respond to external events or tasks in a non-blocking manner. Their core characteristic is that their execution flow is decoupled from the main thread (or the caller), allowing them to continue executing other tasks without waiting for the operation to complete. The scheduling and execution of asynchronous threads rely on event-driven mechanisms, callback functions, or coroutines, rather than traditional synchronous blocking scheduling. For example, execution is triggered by detecting a state that meets the requirements for execution, which differs from the passive switching of scheduling by the thread callee. For instance, in this embodiment, there is no need to actively schedule a thread to perform a core-binding operation; instead, an asynchronous thread is automatically invoked after detecting core-binding information, and the core-binding operation is performed through this asynchronous thread.
[0039] Optionally, in this embodiment, the core binding information can be sent to an information queue, and the asynchronous thread performs the core binding operation by listening to the core binding information in the information queue. That is, optionally, in some embodiments of this application, before the step "using the asynchronous thread to perform core binding processing on the target thread through the kernel and the core binding information to obtain the thread core binding result", the method further includes: The kernel sends the kernel binding information to an information queue, which includes a first-in-first-out (FIFO) queue. The process of using the kernel and the kernel binding information to perform kernel binding on the target thread using an asynchronous thread to obtain the thread kernel binding result includes: The kernel controls the asynchronous thread to read the kernel binding information from the information queue; Furthermore, the kernel controls the asynchronous thread to perform core binding processing on the target thread based on the read core binding information, thereby obtaining the thread core binding result.
[0040] For example, an asynchronous thread automatically and continuously listens to the information queue. If it reads core binding information from the information queue, it performs a core binding operation on the target thread based on the read core binding information.
[0041] In this embodiment, the information queue can be a first-in, first-out (FIFO) queue, i.e., a FIFO queue. This facilitates the execution of core binding operations for each thread in the order of core binding requirements.
[0042] In this embodiment of the application, the core binding process for the target thread is implemented by calling the core binding interface. Specifically, in some embodiments of this application, the step "controlling the asynchronous thread through the kernel to perform core binding processing on the target thread based on the read core binding information, and obtaining the thread core binding result" includes: The kernel controls the asynchronous thread to call the core binding interface based on the read core binding information to perform core binding processing on the target thread, thereby obtaining the core binding result of the thread; The core binding interface includes an interface based on sched.
[0043] In Linux, `sched` is a collection of APIs related to process / thread scheduling. These APIs allow for finer-grained control over processes or threads, such as setting scheduling policies and priorities, and binding threads to specific CPU cores. This binding operation is typically implemented using the `sched_setaffinity` and `sched_getaffinity` functions. These functions specify which CPU cores a thread can run on. For example, binding highly relevant threads to adjacent CPU cores can reduce cache misses caused by thread migration, thereby improving program execution efficiency.
[0044] Optionally, in this embodiment, if the core binding information is added to the information queue, an asynchronous thread is invoked from the waiting queue to perform the core binding operation. That is, optionally, in some embodiments of this application, the step "controlling the asynchronous thread to read the core binding information from the information queue through the kernel" includes: If the core binding information is detected in the information queue, the asynchronous thread is invoked from the waiting queue, and the core binding information is read from the information queue through the asynchronous thread.
[0045] The waiting queue is a data structure (usually a linked list or priority queue) that stores tasks (threads / coroutines) that are suspended due to unmet conditions. It is understood that in this embodiment, if the core binding information is not added to the information queue, the asynchronous thread is in the waiting queue, i.e., in a suspended state. Once the core binding information is added to the information queue, the asynchronous thread is awakened.
[0046] It is understood that, in the embodiments of this application, the core binding status information of the target thread can also be recorded in order to know the changes in the core binding status of the target thread. That is, optionally, in some embodiments of this application, the method further includes: The target thread's core binding status information is obtained in real time through the asynchronous thread; Output the core binding status information.
[0047] For example, if the target thread adjusts its core binding status through other channels, the latest core binding status of the target thread can be known through the real-time core binding status information. Furthermore, obtaining this real-time core binding status information also helps to detect problems where the core binding status has been tampered with. For instance, if the core binding status of the thread is tampered with through other channels, the core binding status information changes, and after outputting this information, the terminal device or user will know that the core binding status of the target thread has been tampered with.
[0048] Optionally, in some embodiments of this application, the target thread to be bound to the core may also be subject to core binding verification to generate a prompt indicating whether it is suitable for core binding. That is, optionally, in some embodiments of this application, the method further includes: The first core binding feature information of the target thread is determined based on the core binding information; Generate core binding prompt information based on the second core binding feature information and the first core binding feature information of the already bound core thread; Output the core binding prompt information.
[0049] Among them, core-binding feature information refers to information reflecting the core-binding characteristics of the target thread. For example, this core-binding feature information includes, but is not limited to, the type of the target thread, the type of application corresponding to the thread, the usage frequency, and resource consumption. The first core-binding feature information is the core-binding feature information corresponding to the target thread, and the second core-binding feature information is the core-binding feature information of the thread that has completed core binding with the CPU.
[0050] The core binding suggestion information indicates whether core binding is suitable or unsuitable. It's understood that by comparing the first and second core binding characteristics, the differences between the target thread and the currently bound thread can be analyzed, thus generating a suitability suggestion. For example, if the difference between the first and second core binding characteristics is significant, it indicates that establishing a binding relationship with the current CPU is unsuitable. If the difference is small, it indicates that establishing a binding relationship with the current CPU is more suitable. It's understood that binding related threads to the same CPU can reduce cache misses caused by thread migration, thereby improving program execution efficiency.
[0051] Correspondingly, the kernel can determine whether to perform a core binding operation on the target thread through an asynchronous thread based on the core binding prompt information, or after the core binding prompt information is output, the user can reselect the core binding object of the target thread, that is, reselect which CPU to establish a core binding relationship with.
[0052] In summary, the embodiments of this application implement thread-core binding operation through asynchronous thread, so that thread-core binding operation does not depend on the switching and scheduling of other threads. This enables thread-core binding to be implemented even in scenarios where switching and scheduling are not allowed, improving the convenience of thread-core binding operation and enhancing user experience.
[0053] To facilitate better implementation of the thread processing method of this application, this application also provides an application processing device based on the above-described thread processing method. The meanings of the terms used are the same as in the thread processing method described above, and specific implementation details can be found in the descriptions of the method embodiments.
[0054] Please see Figure 3 , Figure 3 This is a schematic diagram of the structure of the thread processing device provided in the embodiments of this application, wherein the thread processing device may specifically be as follows: The determination module 301 is used to respond to the core binding request for the target thread through the kernel and determine the core binding information of the target thread; The core binding module 302 is used to perform core binding processing on the target thread using an asynchronous thread through the kernel and the core binding information, so as to obtain the thread core binding result.
[0055] Optionally, in some embodiments of this application, before obtaining the thread binding result by using an asynchronous thread to perform core binding processing on the target thread through the kernel and the core binding information, the method further includes: The kernel sends the kernel binding information to an information queue, which includes a first-in-first-out (FIFO) queue. The process of using the kernel and the kernel binding information to perform kernel binding on the target thread using an asynchronous thread to obtain the thread kernel binding result includes: The kernel controls the asynchronous thread to read the kernel binding information from the information queue; Furthermore, the kernel controls the asynchronous thread to perform core binding processing on the target thread based on the read core binding information, thereby obtaining the thread core binding result.
[0056] Optionally, in some embodiments of this application, the step of controlling the asynchronous thread through the kernel to perform core binding processing on the target thread based on the read core binding information, and obtaining the thread core binding result, includes: The kernel controls the asynchronous thread to call the core binding interface based on the read core binding information to perform core binding processing on the target thread, thereby obtaining the core binding result of the thread; The core binding interface includes an interface based on sched.
[0057] Optionally, in some embodiments of this application, the step of controlling the asynchronous thread through the kernel to read the kernel binding information from the information queue includes: If the core binding information is detected in the information queue, the asynchronous thread is invoked from the waiting queue, and the core binding information is read from the information queue through the asynchronous thread.
[0058] Optionally, in some embodiments of this application, the core binding information includes core binding instruction information or thread identification information. The core binding instruction information is used to indicate core binding or unbinding, and the thread identification information is used to identify the target thread to be bound to the core.
[0059] Optionally, in some embodiments of this application, the method further includes: The target thread's core binding status information is obtained in real time through the asynchronous thread; Output the core binding status information.
[0060] Optionally, in some embodiments of this application, the method further includes: The first core binding feature information of the target thread is determined based on the core binding information; Generate core binding prompt information based on the second core binding feature information and the first core binding feature information of the already bound core thread; Output the core binding prompt information.
[0061] In this embodiment, the determining module 301 first responds to the core binding request for the target thread through the kernel and determines the core binding information of the target thread. Then, the core binding module 302 uses the kernel and the core binding information to perform core binding processing on the target thread using an asynchronous thread to obtain the thread core binding result.
[0062] In summary, the embodiments of this application implement thread-core binding operation through asynchronous thread, so that thread-core binding operation does not depend on the switching and scheduling of other threads. This enables thread-core binding to be implemented even in scenarios where switching and scheduling are not allowed, improving the convenience of thread-core binding operation and enhancing user experience.
[0063] In addition, this application also provides an electronic device, such as Figure 4 As shown, it illustrates a structural schematic diagram of the electronic device provided in an embodiment of this application. Specifically: The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will understand that... Figure 4 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein: The processor 401 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines. By running or executing software programs and / or modules stored in the memory 402, and by calling data stored in the memory 402, it performs various functions and processes data, thereby providing overall monitoring of the electronic device. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 401.
[0064] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.
[0065] The electronic device also includes a power supply 403 that supplies power to the various components. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 403 may also include one or more DC or AC power supplies, recharging systems, power equipment debugging circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0066] The electronic device may also include an input unit 404, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0067] Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 401 in the electronic device loads the executable files corresponding to the processes of one or more applications into the memory 402 according to the following instructions, and the processor 401 runs the applications stored in the memory 402, thereby implementing the steps in any of the thread processing methods provided in the embodiments of this application.
[0068] In this embodiment, the kernel responds to the core binding request for the target thread and determines the core binding information of the target thread. Using the kernel and the core binding information, an asynchronous thread performs core binding processing on the target thread to obtain the thread core binding result.
[0069] In this embodiment, the thread-core binding operation is implemented through asynchronous threads, so that the thread-core binding operation does not depend on the switching and scheduling of other threads. This allows thread-core binding to be implemented even in scenarios where switching and scheduling are not allowed, improving the convenience of thread-core binding operation and enhancing the user experience.
[0070] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0071] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0072] To this end, this application provides a computer-readable storage medium storing a computer program that can be loaded by a processor to execute the steps of any of the thread processing methods provided in this application.
[0073] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0074] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0075] Since the instructions stored in the computer-readable storage medium can execute the steps in any of the thread processing methods provided in this application, the beneficial effects that any of the thread processing methods provided in this application can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.
[0076] The foregoing has provided a detailed description of a thread processing method, apparatus, electronic device, and computer-readable storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A thread processing method, characterized in that, The method includes: The kernel responds to the core binding request for the target thread and determines the core binding information of the target thread; Using the kernel and the kernel binding information, the target thread is bound to the kernel using an asynchronous thread to obtain the thread binding result.
2. The thread processing method according to claim 1, characterized in that, Before obtaining the thread binding result by using the kernel and the kernel binding information to perform kernel binding processing on the target thread using an asynchronous thread, the method further includes: The kernel sends the kernel binding information to an information queue, which includes a first-in-first-out (FIFO) queue. The process of using the kernel and the kernel binding information to perform kernel binding on the target thread using an asynchronous thread to obtain the thread kernel binding result includes: The kernel controls the asynchronous thread to read the kernel binding information from the information queue; Furthermore, the kernel controls the asynchronous thread to perform core binding processing on the target thread based on the read core binding information, thereby obtaining the thread core binding result.
3. The thread processing method according to claim 2, characterized in that, The step of controlling the asynchronous thread through the kernel to perform core binding processing on the target thread based on the read core binding information, and obtaining the thread core binding result, includes: The kernel controls the asynchronous thread to call the core binding interface based on the read core binding information to perform core binding processing on the target thread, thereby obtaining the core binding result of the thread; The core binding interface includes an interface based on sched.
4. The thread processing method according to claim 2, characterized in that, The step of controlling the asynchronous thread through the kernel to read the kernel binding information from the information queue includes: If the core binding information is detected in the information queue, the asynchronous thread is invoked from the waiting queue, and the core binding information is read from the information queue through the asynchronous thread.
5. The thread processing method according to claim 1, characterized in that, The core binding information includes core binding instruction information or thread identification information. The core binding instruction information is used to indicate core binding or unbinding, and the thread identification information is used to identify the target thread to be bound to the core.
6. The thread processing method according to claim 1, characterized in that, The method further includes: The target thread's core binding status information is obtained in real time through the asynchronous thread; Output the core binding status information.
7. The thread processing method according to claim 1, characterized in that, The method further includes: The first core binding feature information of the target thread is determined based on the core binding information; Generate core binding prompt information based on the second core binding feature information and the first core binding feature information of the already bound core thread; Output the core binding prompt information.
8. A thread processing device, characterized in that, The device includes: The determination module is used to respond to a core binding request for a target thread through the kernel and determine the core binding information of the target thread; The core binding module is used to perform core binding processing on the target thread using an asynchronous thread based on the kernel and the core binding information, so as to obtain the thread core binding result.
9. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the thread processing method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the thread processing method as described in any one of claims 1-7.