CPU load balancing method, system and related equipment
By cutting the execution time of the CPU into time slices and automatically allocating tasks, the problems of cumbersome and unpredictable CPU load balancing process in the prior art are solved, and a fast and predictable load balancing effect is achieved.
Patent Information
- Application Number
- CN202411728844.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-03-21
AI Technical Summary
In the prior art, load balancing is achieved by manually trying to allocate CPU tasks, which is cumbersome, has high repetition, is large and unpredictable.
By cutting the CPU's continuous execution time into several time slices, and configuring each time slice into a task container of a fixed time size, the task is automatically allocated to the corresponding task container based on the task execution time and cycle until the load rate is less than the target load rate.
Fast, predictable and quantifiable CPU load balancing is achieved, reducing manual intervention and improving efficiency and speed.
Smart Images

Figure CN119668773A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to data extrapolation technology, and in particular to CPU load balancing technology. Background Art
[0002] As we all know, products with data processing capabilities need to be equipped with corresponding CPUs; at the same time, based on cost considerations, the performance of the main CPU selected for current products is insufficient, and complex software algorithms require a CPU with stronger computing power. In order to effectively balance cost and CPU computing power, it is necessary to make full use of the CPU computing power resources; in order to make full use of the CPU computing power resources, it is necessary to effectively balance the CPU load and prevent the CPU from being overloaded.
[0003] The existing method of balancing CPU load is to manually try to allocate CPU tasks and verify the CPU load balance through testing. If the requirements are not met, tasks need to be reallocated until the test meets the balance requirements. This method of manually repeatedly trying to allocate tasks to determine whether the CPU load is balanced is cumbersome and unpredictable, and it brings a huge workload due to repeated operations.
[0004] Therefore, how to efficiently achieve a set balance effect for CPU load balancing is a technical problem that urgently needs to be solved in this field. Summary of the invention
[0005] In view of the problems in existing solutions that manual attempts to allocate CPU tasks are cumbersome, repetitive, heavy and unpredictable, the purpose of the present invention is to provide a CPU load balancing solution, which can quickly determine through simulation whether the task allocation solution can meet the requirements of CPU load balancing, does not require manual repeated task allocation, and the balancing effect is predictable and quantifiable.
[0006] In order to achieve the above object, the present invention provides a method for CPU load balancing, the method comprising:
[0007] The continuous execution time of the CPU is divided into several time slices, and each time slice is configured as a task container of fixed time size;
[0008] Based on the task execution time and execution cycle of all tasks, each task is assigned to the corresponding task container, and the load of each task container is calculated until the load rate is less than the target load rate to complete the task allocation;
[0009] Poll each task until all tasks have completed their assignment successfully.
[0010] In some embodiments of the present invention, the CPU load balancing method uses the lowest common divisor of the task cycles of all tasks as the discretization cycle, and discretizes the continuous execution time of the CPU based on the discretization cycle, dividing the continuous execution time of the CPU into several time slices.
[0011] In some embodiments of the present invention, when performing task allocation, the CPU load balancing method first determines the number of task containers required in a task allocation cycle based on the maximum task cycle of all tasks and the divided time slices, and numbers the containers in sequence according to the time axis;
[0012] Next, get the execution time of all tasks in a task allocation cycle, and start the task allocation from the first task in turn. Find the task container that should be placed according to the execution cycle of each task and the time axis of the CPU execution time, and determine whether the remaining size of the found task container can accommodate the current task:
[0013] If the remaining size of the task container is greater than the execution time of the current task, it is considered that the current task can place the task container, otherwise the next task container that can place this task is found;
[0014] Each task is polled in this way until all tasks are assigned to the corresponding task container, then the task allocation is considered successful, otherwise the allocation is considered failed.
[0015] In order to achieve the above object, the present invention provides a CPU load balancing system, the CPU load balancing system comprising:
[0016] A time discretization module, wherein the time discretization module is configured to obtain the continuous execution time of the CPU, cut it into a number of time slices, and configure each time slice into a task container of a fixed time size;
[0017] A task information collection module, wherein the task information collection module is configured to collect task execution time and cycle of the task to be assigned;
[0018] A task allocation module, wherein the task allocation module is configured to allocate each task to a corresponding task container based on the task execution time and cycle of the task to be allocated collected by the task information collection module, and perform load calculation on the time slice until the load rate is less than the target load rate to complete the task allocation;
[0019] The polling module is configured to interact with the task information collection module and the task allocation module to poll each task until all tasks are successfully allocated.
[0020] In some embodiments of the present invention, the time discretization module is configured to use the lowest common divisor of the task cycles of all tasks as the discretization cycle, and discretize the continuous execution time of the CPU based on the discretization cycle to divide the continuous execution time of the CPU into several time slices.
[0021] In some embodiments of the present invention, the task allocation module is configured to, when performing task allocation, first determine the number of task containers required in a task allocation cycle based on the maximum task cycle of all tasks and the divided time slices, and number the containers in sequence according to the time axis;
[0022] Next, get the execution time of all tasks in a task allocation cycle, and start the task allocation from the first task in turn. Find the task container that should be placed according to the execution cycle of each task and the time axis of the CPU execution time, and determine whether the remaining size of the found task container can accommodate the current task:
[0023] If the remaining size of the task container is greater than the execution time of the current task, it is considered that the current task can place the task container, otherwise the next task container that can place this task is found.
[0024] In order to achieve the above object, the present invention also provides a computer-readable storage medium, on which a program is stored, and when the program is executed by a processor, the steps of the above CPU load balancing method are implemented.
[0025] In order to achieve the above object, the present invention also provides a processor, which is used to run a program, and the steps of the above CPU load balancing method are executed when the program is running.
[0026] In order to achieve the above-mentioned purpose, the present invention also provides a terminal device, which includes a processor, a memory, and a program stored in the memory and executable on the processor, wherein the program code is loaded and executed by the processor to implement the steps of the above-mentioned CPU load balancing method.
[0027] In order to achieve the above object, the present invention also provides a computer program product, which is suitable for executing the steps of the above CPU load balancing method when executed on a data processing device.
[0028] Compared with the prior art, the CPU load balancing solution provided by the present invention can quickly determine through simulation whether the task allocation solution can meet the requirements of CPU load balancing, without the need for manual repeated task allocation. The balancing effect is predictable and quantifiable, the speed is fast and the efficiency is high, which can effectively overcome the problems existing in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments.
[0030] Figure 1 This is a schematic diagram of CPU load balancing in the present invention;
[0031] Figure 2 This is an example diagram of the CPU load balancing system in the present invention;
[0032] Figure 3 This is a flow chart for performing task allocation and achieving CPU load balancing in the present invention. DETAILED DESCRIPTION
[0033] In order to make the technical means, creative features, objectives and effects achieved by the present invention easy to understand, the present invention is further explained below with reference to specific diagrams.
[0034] The CPU load balancing involved in the solution of the present invention specifically means that the CPU usage rate in any time slice is relatively balanced, and the CPU will not be fully loaded.
[0035] As we all know, the functional tasks that the CPU needs to perform are periodic. Therefore, as long as a certain period T can be determined and the CPU load is balanced within the period T, the CPU load will be balanced throughout the entire running time.
[0036] Specifically, when the CPU executes program tasks, it is periodic, and the maximum task cycle T is a complete execution cycle. Therefore, within the time 2T, 3T..., the CPU simply repeats all the tasks within the first T time. Therefore, as long as the CPU load is balanced within the time T, then the time 2T, 3T... all cycles are equivalent, so the CPU load will also be balanced during the entire processing time.
[0037] The solution of the present invention innovatively discretizes the CPU execution time and divides it into several time slices. At the same time, each time slice formed by dividing the CPU execution time is configured as a task container with a fixed size and equal to the period of the time slice. On this basis, for the tasks that need to be executed, they are evenly placed in several task containers formed based on the time slices according to their running time, so that the purpose of load balancing can be achieved.
[0038] Accordingly, see Figure 1 The present invention provides a method for CPU load balancing, which specifically includes:
[0039] For the continuous execution time of the CPU, the maximum task cycle T is used as a task processing cycle, and the continuous execution time of the CPU within each maximum task cycle T (i.e., task processing cycle) is cut into several time slices, and each time slice is configured as a task container of a fixed time size;
[0040] In each maximum task cycle T of the CPU, for each task to be assigned, based on the task execution time and cycle of the task to be assigned, the time slice corresponding to each task to be assigned is determined; and task assignment is attempted for the determined time slice, and load calculation is performed for each time slice until the load rate is less than the target load rate, thereby completing task assignment;
[0041] Poll each task until all tasks are assigned successfully.
[0042] As a further explanation, the scheme of the present invention is for the CPU execution time to be an infinite continuous time state. In order to effectively distribute the CPU load at each time point, the scheme of the present invention discretizes the running time of the entire CPU based on the fixed cycle when the CPU executes the program running task and the fixed maximum time when the program is running.
[0043] Furthermore, the scheme of the present invention targets all program running tasks that need to be executed by the CPU. Since different tasks have different running cycles and running times, but the running cycle and running time of each task are fixed; accordingly, the scheme of the present invention obtains the execution cycles of all tasks, and uses the lowest common divisor of all task cycles as the discretization cycle, and discretizes the CPU execution time based on the discretization cycle, and divides the CPU execution time into a number of time slices (time slice 1, time slice 2, time slice 3 ... time slice N), and each time slice is configured as a task container (i.e., time container) of a fixed time size, and the size of each task container is equal to the cycle (i.e., size) of the time slice; at the same time, the several task containers formed by the division are distributed in sequence according to the time axis of the CPU execution time.
[0044] On this basis, the scheme of the present invention is based on the fact that the CPU executes each program running task with a fixed running cycle and running time, and further configures the maximum task cycle T in the CPU executing the program running task into a task allocation cycle. Within the task allocation cycle, the CPU will repeatedly execute all program running tasks within the time corresponding to the execution cycle T, and can complete all program running tasks that need to be executed at least once according to their corresponding cycles and running times. For example, the program running task with the maximum task cycle T will be run once, and the program running task with the minimum task cycle will be run multiple times.
[0045] In this way, the execution running time of the entire CPU will form several task allocation cycles according to its time axis. The running time of each task allocation cycle is fixed and is the same as the running time corresponding to the maximum task cycle T of the CPU execution program running task.
[0046] Furthermore, for the determined task allocation cycle, within each task allocation cycle, the number of task containers (i.e., time slices) required within this task allocation cycle is determined based on the corresponding maximum task cycle T and the determined time slice, and the determined multiple task containers are numbered in sequence according to the timeline of the CPU execution time.
[0047] Furthermore, for each program running task (i.e., task to be assigned) within the task allocation cycle, it is allocated to the corresponding task container (i.e., time slice) based on the task execution time and cycle corresponding to each program running task, ensuring that each task can run according to the required execution cycle, thereby meeting the execution needs of all tasks and keeping the CPU load balanced.
[0048] by Figure 1 The figure is taken as an example to illustrate the process of implementing CPU load balancing in the solution of the present invention.
[0049] In the illustrated scheme, the CPU needs to execute N program running tasks (hereinafter referred to as tasks), and each task has a different running cycle and running time. The CPU periodically executes each task according to its running time and running cycle.
[0050] Based on this, first obtain the execution cycle of all the tasks that need to be executed by the CPU, extract the lowest common divisor of the execution cycle of all these tasks, and use the lowest common divisor as the discretization cycle to discretize the CPU execution time, divide it into several time slices (time slice 1, time slice 2, time slice 3...time slice N, time slice N+1...), and configure a time slice into a time container, and the container size is equal to the size of the time slice.
[0051] Next, the corresponding task allocation cycle is configured according to the maximum task cycle T of the CPU executing the program running task, so that the execution running time of the entire CPU forms a number of task allocation cycles according to its time axis.
[0052] Next, in each task allocation cycle, the maximum task cycle T of the maximum cycle task is obtained, and the maximum task cycle is divided by the determined time slice to obtain the number of time containers (i.e., the number of task containers) N required in the task allocation cycle, and the containers are numbered in sequence along the time axis.
[0053] Next, the execution time of all tasks is obtained and arranged by the execution time size. The tasks are arranged from large to small as a priority to ensure allocation efficiency, and tasks are allocated starting from the first task in sequence. The time container that should be placed is found according to the execution cycle of the task and the time axis of the CPU execution time, and it is determined whether the size of the found time container can accommodate the current task: if the remaining size of the time container is greater than the execution time of the current task, it is considered that the current task can be placed in the time container, otherwise, the next time container that can be placed in this task is found; each task is polled in this way until all tasks are assigned to the corresponding time container, then the task allocation is considered successful, otherwise the allocation is considered failed.
[0054] Further integration Figure 1 As shown, for the N time slices determined based on the maximum cycle task, each time slice can accommodate a certain number of tasks. As long as the sum of the running time of all tasks in the time slice does not exceed the time cycle, the CPU can run all the tasks in the time slice.
[0055] Based on this, after completing the task allocation through the above-mentioned CPU load balancing method, in each task allocation cycle, in the corresponding 1 to N time slices, all tasks are placed in the corresponding time slices and each time slice has remaining capacity. Then the CPU can complete all the allocated tasks in each time slice. In this way, it is considered that the CPU will not be overloaded during the entire time, that is, the CPU load is balanced.
[0056] As a further explanation, when the CPU load balancing method provided by the present invention is implemented, it is possible to calculate the execution time of all assigned tasks in each time slice through simulation, so that the CPU utilization of all time slices can be accurately calculated, so that as long as the CPU utilization of all time slices tends to be the same, the CPU load is balanced. In this way, the scheme of the present invention can quickly determine whether the task allocation scheme can meet the requirements of CPU load balancing through simulation, so that there is no need to manually repeatedly allocate tasks, and the effect of achieving balancing is predictable and quantifiable.
[0057] The predictability mentioned here means that it is possible to know whether the CPU load is balanced through simulation without running the program on actual hardware; the quantifiability mentioned here means that the CPU load size of each time slice can be calculated through simulation.
[0058] The CPU load balancing method given in this example solution can be used as a corresponding software program to form a corresponding CPU load balancing system when it is applied. When the software program is running, it will execute the above CPU load balancing method and store it in a corresponding storage medium for the processor to call and execute.
[0059] See also Figure 2 The CPU load balancing system 100 formed in this way mainly includes four functional modules: a time discretization module 110, a task information collection module 120, a task allocation module 130, and a polling module 140.
[0060] Among them, the time discretization module 110 in this system serves as a basic functional module for system operation, which is configured to obtain the continuous execution time of the CPU, cut it into several time slices, and configure each time slice into a task container of fixed time size.
[0061] The task information collection module 120 in the system serves as a data acquisition module of the system, which is configured to collect the task execution time and cycle of the task to be assigned, and input the collected task execution time and cycle as data input to the task assignment module.
[0062] The task allocation module 130 in the system is a core module of the system and is used to allocate tasks, effectively balance the load of the CPU, and prevent the CPU from being overloaded.
[0063] The task allocation module 130 here is configured to interact with the time discretization module 110 and the task information collection module 120, and use the task execution time and cycle of the task to be assigned collected by the task information collection module 120 as input to attempt to allocate tasks for each time slice, and at the same time perform load calculation on the time slice until the load rate is less than the target load rate to complete the task allocation.
[0064] The polling module 140 in the system is configured to interact with the task information collection module 120 and the task allocation module 130 to poll each task until all tasks are allocated successfully.
[0065] As a further explanation, in the specific implementation of this system solution, the time discretization module 110 is configured to discretize the CPU execution time based on the fixed cycle when the CPU executes the program running task and the fixed time when the program is running, and cut it into several time slices.
[0066] Specifically, the time discretization module 110 in the present system solution obtains the execution cycle of all CPU execution program running tasks, takes the lowest common divisor of all task cycles as the discretization cycle, and discretizes the CPU execution time based on the discretization cycle, thereby dividing the CPU execution time into a number of time slices; on this basis, each time slice is further configured as a task container (i.e., time container) of a fixed time size, and the size of each task container is equal to the cycle (i.e., size) of the time slice; at the same time, the several task containers formed by the division are distributed in sequence according to the time axis of the CPU execution time.
[0067] As a further explanation, when the system solution is implemented, the task allocation module 130 specifically constructs a corresponding balancing algorithm to complete task allocation and ensure CPU load balancing. Specifically, the process of the task allocation module 130 performing load balancing task allocation based on the balancing algorithm is as follows:
[0068] First, by obtaining the maximum task cycle T of the CPU executing the program running task, the corresponding task allocation cycle is configured according to the maximum task cycle T. In the task allocation cycle, the CPU will repeatedly execute all program running tasks within the time corresponding to the cycle T.
[0069] Then, on this basis, the task allocation module 130 obtains the maximum task cycle T of the maximum cycle task for each configured task allocation cycle, and divides the maximum task cycle by the determined time slice to obtain the number of time containers (i.e., the number of task containers) N required within the task allocation cycle, and numbers the containers in sequence along the time axis.
[0070] Next, the execution time of all tasks within the task allocation cycle is obtained, and they are arranged from large to small according to the execution time. Task allocation is started from the first task in sequence. The time container that should be placed is found according to the execution cycle of the task and the time axis of the CPU execution time, and it is determined whether the size of the found time container can accommodate the current task: if the size of the time container is greater than the execution time of the current task, it is considered that the current task can be placed in the time container, otherwise, the next time container that can be placed in this task is found; each task is polled in this way until all tasks are assigned to the corresponding time container, then the task allocation is considered successful, otherwise, the allocation is considered failed.
[0071] In order to further illustrate the CPU load balancing solution provided by the present invention, the solution of the present invention and corresponding technical features are further illustrated by using specific application examples as follows.
[0072] When this CPU load balancing solution is implemented, a corresponding CPU load balancing software system is built based on the above solution, and the software system is run in the corresponding product, which can be called and run by the CPU configured in the product.
[0073] On this basis, this CPU load balancing software system cooperates with the CPU to automatically allocate tasks, combined with Figure 3 As shown, the corresponding processing process is as follows:
[0074] First, the program running tasks (hereinafter referred to as tasks) that the CPU needs to execute, the execution cycle of each program running task and the corresponding execution running time are obtained.
[0075] On this basis, all tasks are numbered, and a corresponding task index number X is formed for each task, where the maximum task number is X_max; at the same time, a corresponding task number T_id(x) is configured for each task, and the task execution time T_t(x) and task execution period T_p(x) of the corresponding task are configured for each task number T_id(x).
[0076] Furthermore, based on the execution cycles of all tasks, the corresponding time containers are determined, and the number of time containers (hereinafter referred to as containers) required in a task allocation cycle is determined. The specific process is as above.
[0077] Each container is numbered to form a corresponding container index number y, where the maximum container index number is Y_max; on this basis, a container number C_id(y) is formed for each container, and at the same time, the container number C_id(y) of each container is respectively configured to correspond to the container available capacity C_a(y) of the corresponding container.
[0078] After completing the above data preparation, the process of automatic task allocation using the above prepared data as input is as follows:
[0079] (1) Based on the established task index number X, starting from the first task X=1, the task number T_id(x) of the current task is obtained, and based on the task number T_id(x), the task execution time T_t(x) and the task execution period T_p(x) of the task are obtained.
[0080] (2) Starting from the first container y=1, search for container y in sequence, obtain the container number C_id(y) of the current container, and obtain the available capacity C_a(y) of the current container according to the container number C_id(y).
[0081] (3) Determine whether the remaining capacity C_a(y) of the current container y is greater than the running time T_t(x) of the current task, that is, whether it can accommodate the current task:
[0082] If the remaining capacity C_a(y) of the current container y is greater than the running time T_t(x) of the current task, go to step (4); if the remaining capacity C_a(y) of the current container y is less than the running time T_t(x) of the current task, go to step (2).
[0083] (4) According to the execution period T_p(x) of the current task, find all the container sets Gc to which this task should be assigned.
[0084] (5) Calculate whether the remaining capacity of each container in the container set Gc is greater than the running time T_t(x) of the current task: if so, proceed to step (6); if not, proceed to step (2).
[0085] (6) It is determined that this task can be successfully allocated, and the remaining capacity in the container set Gc is subtracted from the running time of the allocated task to obtain the updated container remaining capacity, and this task group is marked as placed, that is, allocated.
[0086] (7) Repeat the above steps in order according to the task number until all tasks are assigned to the corresponding containers. The allocation is considered successful. Otherwise, the allocation is considered a failure.
[0087] After successfully allocating tasks through the above algorithm, it can be confirmed that each time container will not exceed its capacity, so that the CPU has remaining time in each time slice, thereby ensuring that the CPU will not be overloaded in the task time slice, thereby ensuring the balance of the CPU load.
[0088] It can be seen from the above examples that the scheme of the present invention can realize the task allocation by collecting simulation algorithms, which can avoid the process of repeated manual attempts to verify, has a fast speed and high efficiency, and greatly reduces the problem of heavy workload caused by manual work.
[0089] Furthermore, the operating results of the scheme of the present invention are highly predictable, avoiding the influence of human and system deviations in the test and verification process.
[0090] Based on the above CPU load balancing solution, an embodiment of the present invention further provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the steps of the above CPU load balancing method are implemented.
[0091] An embodiment of the present invention further provides a processor, which is used to run a program, wherein the program executes the steps of the above-mentioned CPU load balancing method when running.
[0092] An embodiment of the present invention also provides a terminal device, which includes a processor, a memory, and a program stored in the memory and executable on the processor, wherein the program code is loaded and executed by the processor to implement the steps of the above-mentioned CPU load balancing method.
[0093] The present invention also provides a computer program product, which, when executed on a data processing device, is suitable for executing the steps of the above-mentioned CPU load balancing method.
[0094] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0095] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and modules described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0096] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0097] The present invention is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products of the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks 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.
[0098] 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.
[0099] 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.
[0100] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0101] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0102] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.
[0103] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0104] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0105] The above-mentioned method of the present invention, or a specific system unit, or a part of the same, is a pure software architecture, which can be arranged on a physical medium, such as a hard disk, an optical disk, or any electronic device (such as a smart phone, a computer-readable storage medium) through program code. When the machine loads the program code and executes it (such as a smart phone loading and executing it), the machine becomes a device for implementing the present invention. The above-mentioned method and device of the present invention can also be transmitted in the form of program code through some transmission media, such as cables, optical fibers, or any transmission mode. When the program code is received, loaded and executed by a machine (such as a smart phone), the machine becomes a device for implementing the present invention.
[0106] The above shows and describes the basic principles, main features and advantages of the present invention. It should be understood by those skilled in the art that the present invention is not limited to the above embodiments, and the above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention to be protected. The scope of protection of the present invention is defined by the attached claims and their equivalents.
Claims
1. A method for CPU load balancing, characterized in that: The method comprises: The continuous execution time of the CPU is divided into several time slices, and each time slice is configured as a task container of fixed time size; Based on the task execution time and execution cycle of all tasks, each task is assigned to the corresponding task container, and the load of each task container is calculated until the load rate is less than the target load rate to complete the task allocation; Poll each task until all tasks have completed their assignment successfully.
2. The method for CPU load balancing according to claim 1, characterized in that: The CPU load balancing method uses the lowest common divisor of the task cycles of all tasks as a discretization cycle, and discretizes the continuous execution time of the CPU based on the discretization cycle, thereby dividing the continuous execution time of the CPU into a number of time slices.
3. The method for CPU load balancing according to claim 1, characterized in that: When performing task allocation, the CPU load balancing method first determines the number of task containers required in a task allocation cycle based on the maximum task cycle of all tasks and the divided time slices, and numbers the containers in sequence according to the time axis; Next, get the execution time of all tasks in a task allocation cycle, and start to allocate tasks from the first task in turn. Find the task container that should be placed according to the execution cycle of each task and the time axis of the CPU execution time, and determine whether the remaining size of the found task container can accommodate the current task: If the remaining size of the task container is greater than the execution time of the current task, it is considered that the current task can place the task container, otherwise the next task container that can place this task is found; Each task is polled in this way until all tasks are assigned to the corresponding task container, then the task allocation is considered successful, otherwise the allocation is considered failed.
4. A CPU load balancing system, characterized in that: The CPU load balancing system comprises: A time discretization module, wherein the time discretization module is configured to obtain the continuous execution time of the CPU, cut it into a number of time slices, and configure each time slice into a task container of a fixed time size; A task information collection module, wherein the task information collection module is configured to collect task execution time and cycle of the task to be assigned; A task allocation module, wherein the task allocation module is configured to allocate each task to a corresponding task container based on the task execution time and cycle of the task to be allocated collected by the task information collection module, and perform load calculation on the time slice until the load rate is less than the target load rate to complete the task allocation; The polling module is configured to interact with the task information collection module and the task allocation module to poll each task until all tasks are allocated successfully.
5. The CPU load balancing system according to claim 4, characterized in that: The time discretization module is configured to use the lowest common divisor of the task cycles of all tasks as the discretization cycle, and discretize the continuous execution time of the CPU based on the discretization cycle to divide the continuous execution time of the CPU into a number of time slices.
6. The CPU load balancing system according to claim 4, characterized in that: The task allocation module is configured to, when performing task allocation, first determine the number of task containers required in a task allocation cycle based on the maximum task cycle of all tasks and the divided time slices, and number the containers in sequence according to the time axis; Next, get the execution time of all tasks in a task allocation cycle, and start to allocate tasks from the first task in turn. Find the task container that should be placed according to the execution cycle of each task and the time axis of the CPU execution time, and determine whether the remaining size of the found task container can accommodate the current task: If the remaining size of the task container is greater than the execution time of the current task, it is considered that the current task can place the task container, otherwise the next task container that can place this task is found.
7. A computer-readable storage medium having a program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method for CPU load balancing described in any one of claims 1 to 3 are implemented.
8. A processor, the processor being used to run a program, characterized in that: When the program is running, the steps of the CPU load balancing method described in any one of claims 1 to 3 are executed.
9. A terminal device, comprising a processor, a memory, and a program stored in the memory and executable on the processor, characterized in that: The program code is loaded and executed by the processor to implement the steps of the CPU load balancing method according to any one of claims 1 to 3.
10. A computer program product, characterized in that When executed on a data processing device, the method is suitable for executing the steps of the CPU load balancing method according to any one of claims 1 to 3.
Citation Information
Cited By
Detection task allocation and progress tracking method based on big data management system
CN120448124A