Thread binding method, device and electronic device
Patent Information
- Application Number
- CN202111004253.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-30
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-08-30
AI Technical Summary
[0002]在linux操作系统中,每个CPU都有自己的运行队列,处于就绪态的线程共享某个CPU,这些线程在一个CPU周期内轮番获得调度,CPU根据线程拥有的优先级决定分配给每个线程的运行时间,线程优先级越高,在一个调度周期内可占有CPU运行的时间就越多,CPU在由一个线程调度到下一个线程时,需要执行线程上下文切换,过多的线程切换将导致频繁的上下文切换,使CPU浪费在业务无关的上下文切换过程中,影响CPU效率;
[0010]本申请通过筛选出相同数量的CPU以及线程,检查所述N个CPU与N个线程的绑定状态,使CPU占用率高的线程都能以一对一的方式绑定到CPU上,确保所述N个CPU与所述N个线程能够进行一对一的绑定,从而实现CPU与线程的双向绑定,使线程在CPU上可以高效执行,提高线程的执行效率以及CPU处理线程的效率。
Smart Images

Figure CN113672373B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data storage, and in particular to a thread binding method, device and electronic device. Background Art
[0002] In the Linux operating system, each CPU has its own run queue. Threads in the ready state share a CPU. These threads are scheduled in turn in a CPU cycle. The CPU determines the run time allocated to each thread based on the thread priority. The higher the thread priority, the more CPU run time it can occupy in a scheduling cycle. When the CPU schedules from one thread to the next, it needs to perform thread context switching. Excessive thread switching will lead to frequent context switching, which will waste the CPU in the process of context switching irrelevant to the business, affecting CPU efficiency.
[0003] At present, a method of binding a multi-queue network card to a CPU is adopted. A CPU can run multiple threads, and multiple threads in the CPU running queue can still run in turn. The network card packet receiving thread is frequently interrupted by other threads, resulting in low CPU processing efficiency for the network card packet receiving thread.
[0004] In addition, a data compression method is adopted to bind the CPU core and the compression transaction thread in advance, and other business threads with high CPU occupancy rates are not dynamically bound according to the actual business situation of the system. When the compression transaction thread finishes its work, it is still bound to the current CPU, so the current CPU will be idle. At this time, the thread with high CPU occupancy rate cannot be bound to the current CPU, resulting in low CPU processing efficiency for the thread. Summary of the invention
[0005] The present application provides a thread binding method, device and electronic device. Through a bidirectional binding method between CPU and thread, threads with high CPU occupancy rate are dynamically bound and monopolize the CPU, ensuring that threads with high CPU occupancy rate can be bound to corresponding CPUs, thus achieving efficient execution of threads on CPU, thereby improving the execution efficiency of threads and the efficiency of CPU processing threads.
[0006] In a first aspect, the present application provides a thread binding method, the method comprising:
[0007] Screening and isolating N CPUs from all CPUs according to preset rules, wherein the CPUs are multiple independent CPUs or multiple CPUs simulated by integrating multiple cores in a single independent CPU;
[0008] Sort all threads in descending order of CPU usage and select the top N threads;
[0009] The threads that are not bound to a CPU among the first N threads are bound to the CPUs that are not bound to the threads among the N CPUs.
[0010] The present application selects the same number of CPUs and threads, checks the binding status of the N CPUs and the N threads, so that threads with high CPU occupancy can be bound to the CPU in a one-to-one manner, ensures that the N CPUs and the N threads can be bound one-to-one, thereby realizing bidirectional binding of the CPU and the thread, allowing the thread to be efficiently executed on the CPU, thereby improving the execution efficiency of the thread and the efficiency of the CPU in processing the thread.
[0011] In a possible design, N CPUs are screened and isolated from all CPUs according to preset rules, wherein the CPUs are multiple independent CPUs or multiple CPUs simulated by integrating multiple cores in a single independent CPU, including:
[0012] The preset rule is to match the input CPU serial number with the preset CPU serial number, and filter out N CPUs that are consistent with the preset CPU serial number;
[0013] Or filter out N idle CPUs from all CPUs;
[0014] Or select N CPUs based on the number of threads whose CPU occupancy rates exceed a preset value;
[0015] The screened N CPUs are removed from the thread scheduler of the operating system to isolate the N CPUs.
[0016] In a possible design, binding the threads that are not bound to a CPU among the first N threads to the CPUs that are not bound to the threads among the N CPUs includes:
[0017] According to a preset cycle, cyclically obtain the top N threads with the highest CPU occupancy in the system and check the binding status of the N CPUs and the N threads;
[0018] If a CPU among the N CPUs has a bound thread, the CPU is bound according to a preset rule;
[0019] If a CPU among the N CPUs has no bound threads, then the threads among the first N threads that are not bound to a CPU are bound to the CPU.
[0020] In a possible design, binding the CPU according to a preset rule includes:
[0021] Determine whether the bound thread is a thread in the first N threads;
[0022] If yes, maintaining the binding state between the CPU and the thread;
[0023] If not, the thread bound to the CPU is unbound.
[0024] In a second aspect, the present application provides a thread binding device, the device comprising:
[0025] A screening module, used for screening and isolating N CPUs from all CPUs according to preset rules, wherein the CPUs are multiple independent CPUs or multiple CPUs simulated by integrating multiple cores inside a single independent CPU;
[0026] The sorting module is used to sort all threads in descending order of CPU usage and select the top N threads;
[0027] The binding module is used to bind the threads that are not bound to the CPU in the first N threads to the CPUs that are not bound to the threads in the N CPUs.
[0028] In a possible design, the screening module is specifically used for the preset rule of matching the serial number of the input CPU with the preset CPU serial number, and screening out N CPUs that are consistent with the preset CPU serial number; or screening out N CPUs that are in an idle state among all CPUs; or screening out N CPUs based on the number of threads whose CPU occupancy rates exceed a preset value; and removing the screened N CPUs from the thread scheduler of the operating system to isolate the N CPUs.
[0029] In a possible design, the binding module is specifically used to cyclically obtain the top N threads with the highest CPU occupancy in the system according to a preset period and check the binding status of the N CPUs and the N threads; if a CPU among the N CPUs has a bound thread, the CPU is bound according to a preset rule; if a CPU among the N CPUs has no bound thread, the threads among the top N threads that are not bound to a CPU are bound to the CPU.
[0030] In a possible design, the binding module is also used to determine whether the bound thread is a thread among the first N threads; if so, maintain the binding state between the CPU and the thread; if not, unbind the thread bound to the CPU.
[0031] In a third aspect, the present application provides an electronic device, including:
[0032] Memory, used to store computer programs;
[0033] The processor is used to implement the above-mentioned thread binding method steps when executing the computer program stored in the memory.
[0034] In a fourth aspect, a computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps of thread binding described above are implemented.
[0035] For each aspect from the first to the fourth aspect and the technical effects that may be achieved by each aspect, please refer to the above description of the technical effects that can be achieved by the first aspect or various possible schemes in the first aspect, and no further details will be given here. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 A flowchart of the thread binding method steps provided by this application;
[0037] Figure 2 A structural schematic diagram of a thread binding device provided by the present application;
[0038] Figure 3 A schematic diagram of the structure of an electronic device provided in this application. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The specific operating methods in the method embodiments can also be applied to device embodiments or system embodiments. It should be noted that in the description of the present application, "multiple" is understood as "at least two". "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. A is connected to B, which can represent: A is directly connected to B and A is connected to B through C. In addition, in the description of the present application, words such as "first" and "second" are only used to distinguish the purpose of description, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying order.
[0040] The embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0041] At present, a CPU is bound to multiple threads, and the CPU runs multiple threads in turn. The thread running is frequently interrupted by thread switching, which affects the execution speed of the thread, resulting in low CPU processing efficiency for the thread. Or a CPU is bound to one thread, and when the thread work is completed, it is still bound to the current CPU, so the current CPU is idle. At this time, other threads with high CPU occupancy cannot be bound to the current CPU, resulting in low CPU processing efficiency for the thread. Therefore, the low execution efficiency of the thread and the low CPU processing efficiency of the thread have become problems to be solved.
[0042] In order to solve the above problems, the embodiments of the present application provide a thread binding method to achieve bidirectional binding between CPU and thread, improve the execution efficiency of thread and improve the processing efficiency of CPU on thread. Among them, the method and device described in the embodiments of the present application are based on the same technical concept. Since the principles of the problems solved by the method and the device are similar, the embodiments of the device and the method can refer to each other, and the repeated parts will not be repeated.
[0043] Reference Figure 1 , the present application provides a thread binding method, which can improve the execution efficiency of threads and the processing efficiency of CPU on threads. The implementation process of the method is as follows:
[0044] Step S1: Screen and isolate N CPUs from all CPUs according to preset rules.
[0045] Before executing thread binding, it is first necessary to screen and isolate the CPUs that can be used to bind threads. In the embodiment of the present application, the CPU screening can be performed in the following manner, wherein the CPUs are multiple independent CPUs or multiple CPUs simulated by integrating multiple cores in a single independent CPU:
[0046] Method 1: In this method, the CPUs are screened according to the CPU serial number, that is, the serial number of the input CPU is matched with the serial number of the preset CPU. If N consistent serial numbers are matched, the required N CPUs are screened out, wherein the serial number of the preset CPU is automatically sorted by the system from 0 for all CPUs.
[0047] For example: the preset CPU serial numbers are {0, 1, 2, 3, 4, 5, 6, 7}, and the input CPU serial numbers are {2, 3, 5}. Compare {2, 3, 5} with {0, 1, 2, 3, 4, 5, 6, 7}, and the result of the comparison is {2, 3, 5}, so the CPUs corresponding to the serial numbers 2, 3, and 5 are selected.
[0048] By screening the CPUs according to their serial numbers in the above manner, the required CPUs can be quickly screened out, and the purpose of screening out the required CPUs can be achieved in a short time.
[0049] Method 2: In this method, the value of the number N of CPUs to be screened out is determined according to the number of CPUs in an idle state.
[0050] Read the current status of the CPU and determine the number of CPUs that are idle;
[0051] Read and record the serial numbers of the CPUs that are filtered out and in an idle state.
[0052] For example, the current CPU status is read. If there are 5 CPUs in an idle state, the number of CPUs to be screened out is determined to be 5, and the serial number of the currently screened out CPU is read and recorded.
[0053] In the above manner, CPUs are screened according to their idle states, so that CPUs in idle states can be screened out, thereby avoiding waste of CPU resources.
[0054] Method 3: In this method, the value of the number N of CPUs to be screened out is determined according to the number of threads whose CPU occupancy rates exceed a preset value;
[0055] Count the CPU usage of all threads, sort the CPU usage in descending order, and get the sorting result;
[0056] The number of CPUs with usage exceeding a preset value in the sorting results is counted and the counted number is used as the number of CPUs to be filtered out.
[0057] For example: the CPU occupancy rate is sorted from large to small as 45%, 32%, 23%, 12%, 8%, 7%, 6%, 5%, 4%, 3%..., and the corresponding threads are sorted as a, b, c, d, e, f, g, h, i, j..., the preset value is 30%, and there are two threads with CPU occupancy rate exceeding 30%: a and b. The value of the number N of CPUs screened out is determined to be 2.
[0058] In the above manner, the CPUs bound to threads with high CPU occupancy are screened out, the number N of CPUs that need to be isolated is determined, and the N CPUs with the last sequence numbers are screened out, which is conducive to screening and isolating a more appropriate number of CPUs according to the business load of the specific system.
[0059] Since the threads need to be bound to the isolated N CPUs through system calls of the operating system, the threads can be run on the isolated N CPUs. Therefore, N CPUs are screened out through the above three methods, and the serial number parameters of the N CPUs are input into the operating system. When the operating system is started next time, the CPU corresponding to the input serial number is removed from the thread scheduler, thereby isolating the N CPUs and realizing the two-way binding of CPU and thread.
[0060] Step S2: Sort all threads according to the CPU usage from large to small, and select the top N threads.
[0061] In order to ensure that threads with higher CPU occupancy rates can be bound or processed preferentially, the CPU occupancy rates of all threads are sorted from large to small, and the threads corresponding to the top N values are selected.
[0062] For example: when N is 8, the system has 8 CPUs or 8-core CPUs. All threads are sorted according to the CPU occupancy value. The current CPU occupancy values of all threads are sorted from high to low as follows: 23%, 12%, 9%, 8.5%, 8%, 7%, 6%, 5%, 4%..., and the corresponding threads are: a, b, c, d, e, f, g, h, i..., and the threads with the top 8 current CPU occupancy rates are screened out as: a, b, c, d, e, f, g, h.
[0063] By adopting the above method, N threads with high CPU occupancy rates are screened out, which is conducive to one-to-one binding of the N threads with high CPU occupancy rates with the N CPUs.
[0064] Step S3: Bind the threads that are not bound to a CPU among the first N threads to the CPUs that are not bound to a thread among the N CPUs.
[0065] Taking a preset period as a unit, the first N threads with the highest CPU occupancy rate in the system are cyclically obtained and the binding status between the N CPUs and the N threads is checked.
[0066] If a CPU among the N CPUs has a bound thread, the current CPU is in a bound state; extract the thread currently bound to the CPU, and read whether there is a consistent thread among the N threads; if not, unbind the current CPU from the thread, and bind the unbound thread among the N threads to the CPU; if yes, retain the thread currently bound to the CPU.
[0067] If a CPU among the N CPUs has no bound threads, the CPU is currently in an unbound state; and the threads in the unbound state among the N threads are bound to the CPU.
[0068] For example, the CPU occupancy rates of the threads are reordered according to a preset cycle, where the preset cycle time is 5 minutes, the current N threads are determined, and the binding status of the CPUs in the N CPUs and the N threads is checked.
[0069] If the detection is a binding state, it is determined whether the thread bound to the CPU is a thread in the N threads. If so, the binding state between the CPU and the thread is maintained; if not, the thread bound to the CPU is unbound.
[0070] In a possible design, after the thread bound to the CPU is unbound, in order to achieve bidirectional binding between the CPU and the thread, the thread in the unbound state among the N threads needs to be bound to the current CPU.
[0071] If it is detected as an unbound state, the thread in the unbound state among the N threads is bound to the current CPU.
[0072] Through the above method, the binding status of N CPUs and N threads is checked periodically and cyclically, so that threads with high CPU occupancy can be bound to the CPU and monopolize the CPU, so that the threads can be efficiently executed on the CPU.
[0073] The present application uses the method described above to periodically and cyclically check the binding status of the N CPUs and the N threads, confirm that the thread in the N threads is bound to the CPU in the N CPUs, and that the number of the CPUs is equal to the number of the threads, thereby ensuring a one-to-one binding between the CPUs and the threads, and realizing a two-way binding between the CPUs and the threads, so that the threads can be efficiently executed on the CPU, thereby improving the execution efficiency of the threads and the efficiency of the CPU in processing threads.
[0074] Based on the same inventive concept, a thread binding device is also provided in the embodiment of the present application. The thread binding device is used to implement the function of a thread binding method. Figure 2 , the device comprises:
[0075] A screening module 201 is used to screen and isolate N CPUs from all CPUs according to a preset rule;
[0076] The sorting module 202 is used to sort all threads in descending order of CPU usage, and select the top N threads;
[0077] The binding module 203 is used to bind the threads that are not bound to the CPU in the first N threads to the CPUs that are not bound to the threads in the N CPUs.
[0078] In a possible design, the screening module 201 is specifically used for the preset rule of matching the serial number of the input CPU with the preset CPU serial number, and screening out N CPUs that are consistent with the preset CPU serial number; or screening out N CPUs that are in an idle state among all CPUs; or screening out N CPUs based on the number of CPU occupancy rates ranked by threads that exceed a preset value; and removing the screened N CPUs from the thread scheduler of the operating system to isolate the N CPUs.
[0079] In one possible design, the binding module 203 is specifically used to cyclically obtain the top N threads with the highest CPU occupancy in the system according to a preset period and check the binding status of the N CPUs and the N threads. If a CPU among the N CPUs has a bound thread, the CPU is bound according to a preset rule. If a CPU among the N CPUs has no bound thread, the threads among the top N threads that are not bound to the CPU are bound to the CPU.
[0080] In a possible design, the binding module 203 is also used to determine whether the bound thread is a thread among the first N threads. If so, the binding state between the CPU and the thread is maintained; if not, the thread bound to the CPU is unbound.
[0081] Based on the same inventive concept, an electronic device is also provided in an embodiment of the present application, and the electronic device can realize the functions of the aforementioned thread binding device, referring to Figure 3 , the electronic device comprises:
[0082] At least one processor 301, and a memory 302 connected to the at least one processor 301. The specific connection medium between the processor 301 and the memory 302 is not limited in the embodiment of the present application. Figure 3 In the example, the processor 301 and the memory 302 are connected via the bus 300. The bus 300 is connected to the memory 302 via the bus 300. Figure 3 The bus 300 is represented by a bold line, and the connection between other components is only for schematic illustration and is not intended to be limiting. The bus 300 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. Alternatively, the processor 301 can also be called a controller, and there is no limitation on the name.
[0083] In the embodiment of the present application, the memory 302 stores instructions that can be executed by at least one processor 301. The at least one processor 301 can execute a thread binding method discussed above by executing the instructions stored in the memory 302. The processor 301 can implement Figure 2The functions of each module in the device shown.
[0084] Among them, the processor 301 is the control center of the device, and can use various interfaces and lines to connect the various parts of the entire control device. By running or executing instructions stored in the memory 302 and calling data stored in the memory 302, the various functions of the device and process data, the device can be monitored as a whole.
[0085] In one possible design, the processor 301 may include one or more processing units, and the processor 301 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the modem processor may not be integrated into the processor 301. In some embodiments, the processor 301 and the memory 302 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on separate chips.
[0086] The processor 301 may be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of a thread binding method disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0087] The memory 302 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 302 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (Random Access Memory, RAM), a static random access memory (Static Random Access Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 302 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 302 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.
[0088] By programming the processor 301, the code corresponding to the thread binding method described in the above embodiment can be fixed into the chip, so that the chip can execute the code when running. Figure 1 The embodiment shown is a thread binding step. How to design and program the processor 301 is a technology well known to those skilled in the art and will not be described in detail here.
[0089] Based on the same inventive concept, an embodiment of the present application further provides a storage medium, which stores computer instructions. When the computer instructions are executed on a computer, the computer executes a thread binding method discussed above.
[0090] In some possible implementations, various aspects of a thread binding method provided by the present application may also be implemented in the form of a program product, which includes program code. When the program product is run on an apparatus, the program code is used to enable the control device to execute the steps of a thread binding method according to various exemplary implementations of the present application described above in this specification.
[0091] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0092] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0093] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0094] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0095] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A thread binding method, characterized in that: include: Screening and isolating N CPUs from all CPUs according to preset rules, wherein the preset rules are to match the sequence number of an input CPU with the preset CPU sequence number, and screen out N CPUs that are consistent with the preset CPU sequence number; or to screen out N CPUs that are in an idle state from all CPUs; or to screen out N CPUs according to the number of threads ranking CPU occupancy rates that exceeds a preset value; the CPUs are multiple independent CPUs or multiple CPUs simulated by integrating multiple cores in a single independent CPU; Remove the selected N CPUs from the thread scheduler of the operating system to isolate the N CPUs. Sort all threads in descending order of CPU usage and select the top N threads; The threads that are not bound to a CPU among the first N threads are bound to the CPUs that are not bound to the threads among the N CPUs.
2. The method according to claim 1, characterized in that The step of binding the threads that are not bound to the CPU in the first N threads to the CPUs that are not bound to the threads in the N CPUs comprises: According to a preset cycle, cyclically obtain the top N threads with the highest CPU occupancy in the system and check the binding status of the N CPUs and the N threads; If a CPU among the N CPUs has a bound thread, the CPU is bound according to a preset rule; If a CPU among the N CPUs has no bound threads, then the threads among the first N threads that are not bound to a CPU are bound to the CPU.
3. The method according to claim 2, characterized in that Binding the CPU according to a preset rule includes: Determine whether the bound thread is a thread in the first N threads; If yes, maintaining the binding state between the CPU and the thread; If not, the thread bound to the CPU is unbound.
4. A thread binding device, characterized in that: The device comprises: A screening module is used to screen and isolate N CPUs from all CPUs according to a preset rule, wherein the preset rule is to match the sequence number of an input CPU with the preset CPU sequence number, and screen out N CPUs that are consistent with the preset CPU sequence number; or to screen out N CPUs that are in an idle state from all CPUs; or to screen out N CPUs according to the number of threads ranking CPU occupancy rates that exceeds a preset value; the CPUs are multiple independent CPUs or multiple CPUs simulated by integrating multiple cores in a single independent CPU; Remove the screened N CPUs from the thread scheduler of the operating system to isolate the N CPUs; The sorting module is used to sort all threads in descending order of CPU usage and select the top N threads; The binding module is used to bind the threads that are not bound to the CPU in the first N threads to the CPUs that are not bound to the threads in the N CPUs.
5. The device according to claim 4, characterized in that The binding module is specifically used to cyclically check the binding status of the N CPUs and the N threads according to a preset period. If a CPU among the N CPUs has a bound thread, the CPU is bound according to a preset rule. If a CPU among the N CPUs has no bound thread, the threads that are not bound to the CPU among the first N threads are bound to the CPU.
6. The device according to claim 4, characterized in that The binding module is further used to determine whether the bound thread is a thread in the first N threads, if so, maintain the binding state between the CPU and the thread, if not, unbind the thread bound to the CPU.
7. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 3 when executing the computer program stored in the memory.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Method for detecting and solving Linux system deadlock
CN103530197A
Scheduling method and device for multi central processing units (CPU)
CN104460934A
Method and system for acquiring and analyzing data on news client
CN104504006A
CPU resource distribution method and device under simultaneous running of multiple program examples
CN107479976A
A multi-core processing system and a task allocation method thereof
CN108958944A
