A multi-task system adaptive process scheduling method
By using an adaptive process scheduling method, CPU load and resource allocation are optimized, solving the problems of resource sharing and time allocation under multi-task and multi-process conditions, and improving system operating efficiency and performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2026-03-27
AI Technical Summary
In multi-tasking and multi-process scenarios, existing technologies struggle to effectively address issues related to resource sharing, resource occupancy, and time resource allocation, leading to low system operating efficiency.
By using an adaptive process scheduling method, the CPU's built-in parameters are used to determine the load status, optimize CPU load allocation and resource filling, form a queue to be transferred, and transfer processes according to priority and resource requirements, thereby optimizing resource allocation to reduce contention and latency.
It improves the operating efficiency of the CPU system under multi-tasking and multi-process conditions, reduces resource contention, shortens process execution latency, and improves system performance and resource utilization.
Smart Images

Figure CN119473605B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of computer operation control methods, and particularly relates to an adaptive process scheduling method for a multi-tasking system. Background Technology
[0002] With the continuous development of computer CPU design and manufacturing technology, CPU performance has advanced rapidly. Although the performance indicators of single-CPU technology are constantly being refreshed, in practical applications, to better balance CPU performance and heat generation under multi-tasking and multi-processing conditions, computer systems based on multi-core processors and multi-CPU operation remain the most prevalent system architecture on the market. Regardless of whether it's a single-CPU or multi-CPU system, the execution of a process is essentially a polling and utilization of process content and resources over CPU time. In multi-tasking and multi-processing scenarios, it's necessary to first address issues such as resource sharing, resource occupancy, and time resource allocation to ensure the smooth operation of multiple processes. Summary of the Invention
[0003] The purpose of this invention is to provide an adaptive process scheduling method for a multi-tasking system, based on actual needs, to improve the efficiency of system process scheduling and management and enhance system performance.
[0004] To achieve the above objectives, the present invention adopts the following technical solution.
[0005] An adaptive process scheduling method for a multi-tasking system includes the following steps:
[0006] Step S1: Determine if the CPU load is balanced. If yes, do not perform process scheduling and restore the original process scheduling; otherwise, proceed to step S2.
[0007] The CPU load status is retrieved by the CPU built-in parameters to identify the CPUs with the highest load. Based on the preset load threshold, it is determined whether the CPU is in an unbalanced load state. Several processes to be executed in the CPUs in the unbalanced state are extracted as processes to be transferred.
[0008] CPU load status can be represented as a load index. ;
[0009] ;
[0010] in It refers to the first The cumulative memory requirements of all processes on each CPU; For the first Available memory per CPU It refers to the first CPU utilization It refers to the first the length of the process queue of the CPU; for adjusting the coefficient;
[0011] In the process of generating the control block of the process, the addressing variable is configured and the initial value of the addressing variable is assigned as -1; each CPU is respectively assigned a unique number n; the available variable of the CPU resource is declared in the shared memory = 1, when the process to be transferred calls the CPU resource, firstly, the minus one operation is performed on the available variable, and different processing is performed according to the value of the available variable: if the available variable = 0, it means that the competition does not exist, and the process applying for occupying the resource obtains the CPU resource; if the available variable < 0, it means that the competition exists, and the process is placed in the queue to be transferred; when the process releases the CPU resource, the plus one operation is performed on the available variable, and the value of the available variable is checked again: if the available variable > 0, it means that there is no other process to apply for the resource in this period of time, that is, there is no competition, and the process is executed normally; if the available variable ≤ 0, it means that there is a process to apply for the resource in this period of time, that is, there is competition, and the process is placed in the queue to be transferred;
[0012] When a process no longer occupies the CPU resource, but the competition still exists, the current CPU number is obtained and is assigned to the addressing variable, and is transmitted to the addressing variable of the next process to be woken up as the transmission parameter of the wake-up program;
[0013] Step S2, the queue to be transferred is traversed, it is judged whether the addressing variable is equal to the local CPU number, if yes, the process is added to the transfer queue and step S3 is transferred, if not, step S3 is directly transferred;
[0014] Step S3, it is judged whether the traversal is completed, if not, step S2 is transferred to continue the traversal, if the traversal is completed, it is judged whether the transfer amount is insufficient, if not, the process scheduling is not executed and the original process scheduling is restored; if yes, the queue to be transferred is traversed, it is judged whether the addressing variable is equal to -1, if yes, the process is added to the transfer sequence and step S6 is transferred, if not, step S4 is directly transferred;
[0015] Step S4, it is judged whether the traversal is completed, if not, step S5 is transferred to continue the traversal, if the traversal is completed, it is continuously judged whether the transfer amount is insufficient, if not, the process scheduling is not executed; if yes, the queue to be transferred is sequentially traversed, and the process sequence to be transferred is formed;
[0016] Step S5, for a plurality of processes in the process sequence to be transferred, the waiting time of each process in the queue to be transferred is analyzed before the process transfer , and the priority coefficient of the process to be transferred is calculated , wherein is the initial priority of the th process, For the delay weight coefficient, the initial priority is preset based on the process default importance and urgency, representing the weight of the process delay; refers to the load index of the target CPU of the process, is the CPU load weight coefficient; the process transfer sequence is generated according to the order of the priority coefficients from large to small;
[0017] Step S6, the process transfer sequence is obtained, and the process a with the highest priority in the process sequence is read in sequence;
[0018] The required system resources of the process a with the highest priority are searched, and whether the CPU resources meet the demand of the required system resources is analyzed;
[0019] If there is a CPU that meets the demand of the required system resources, the process a is transferred to the CPU process queue; if there are multiple CPUs that meet the demand of the required system resources, the process a is transferred to the CPU process queue with the lowest load; if there is no CPU that meets the demand of the required system resources, step S7 is transferred;
[0020] Step S7, it is judged whether the process a is the last process in the process sequence, if not, the ability of the CPU to meet the demand of the required system resources is traversed, and the demand of the required system resources is met;
[0021] The load of each CPU group and the required resource shortage are calculated, the CPU group with the total load capacity not lower than the required resource shortage and the lowest average load value is selected as the CPU transfer group, the required resource shortage is extracted and distributed to the CPU transfer group, and the process a is distributed to the CPU group for execution; according to the required resource shortage distribution result, the resources are pre-distributed to the CPU, and the load and resource distribution information of each CPU are updated, and step S6 is returned;
[0022] If the process a is the last process in the process sequence, the load of each CPU group and the required resource shortage are calculated, the CPU group with the total load capacity not lower than the required resource shortage and the lowest average load value is selected as the CPU transfer group, the required resource shortage is extracted and distributed to the CPU transfer group, and the process a is distributed to the CPU group for execution; according to the required resource shortage distribution result, the resources are pre-distributed to the CPU, and the load and resource distribution information of each CPU are updated, and step S2 is returned.
[0023] Further improvement or preferred embodiment of the adaptive process scheduling method of the foregoing multi-task system, in step S2, if the destination CPU of the process to be transferred is in an unacceptable transfer state, the operation process of the standard kernel is executed, and the process is not added to the transfer queue.
[0024] Further improvement or preferred embodiment of the aforementioned system adaptive process scheduling method under multi-tasking, in step S7, for the CPU of the existing reserved task, remove it from the target CPU queue of the process to be transferred.
[0025] Further improvement or preferred embodiment of the aforementioned system adaptive process scheduling method under multi-tasking, in step S7, resource allocation is completed based on the following steps:
[0026] Analyze the resource deficiency information of the process, determine the required sub-resources, analyze the required runtime of each sub-resource, scan the process execution queue of each CPU in the group, count the idle period of process execution, and establish a sequence of sub-resources to be filled and a sequence of idle periods in order of time length from large to small, respectively;
[0027] Select sub-resource A from the sequence of sub-resources to be filled in order, and fill it into the sequence of idle periods in order until a sub-resource B cannot be completely filled into the corresponding idle period, or all idle periods have been filled once; select the first sub-resource B that has not been filled, and compare the remaining available time of each idle period after being filled in order of the sequence of idle periods to see if it meets the runtime requirement of the sub-resource B, if it does, fill it into the corresponding idle period, if all idle period sequences do not meet the requirement, place it at the end of the sequence of sub-resources to be filled; continuously update the idle period sequence information, and select the remaining sub-resource C one by one, repeat the above steps until all sub-resources have been filled.
[0028] Its beneficial effects are:
[0029] The multi-task system adaptive process scheduling method of the present application optimizes CPU load distribution and resource filling scheme, improves the efficiency of CPU system running under multi-task and multi-process, reduces resource competition, shortens process execution delay, and is beneficial to improve system performance and improve the utilization rate of system resources and performance. BRIEF DESCRIPTION OF DRAWINGS
[0030] Figure 1 is the main structure diagram of the control block of the current process. DETAILED DESCRIPTION
[0031] The present application will be described in detail below in combination with specific embodiments.
[0032] The multi-task system adaptive process scheduling method of the present application is mainly used in the case of a large number of tasks and a large number of processes needing to be processed at the same time, to further optimize the process and resource scheduling management effect between multiple CPUs, further reduce the average load size of CPU under high traffic, and enhance the performance of the computer system.
[0033] The multi-task system adaptive process scheduling method of the present application mainly includes the following contents:
[0034] In the actual scheduling process, due to the CPU process and the resource sharing mechanism, the process and resource scheduling once started will involve the management of the mobilization of multiple CPUs in the group, so a suitable mobilization starting mechanism should be set, and based on suitable standards to determine whether to start the process scheduling. In the present application, the load index of the CPU is mainly used for judgment, that is:
[0035] Step S1, judge whether the load has been balanced, if yes, do not execute the process scheduling and restore the original process scheduling; if not, go to step S2;
[0036] The CPU load state can be represented as load index ;
[0037] ;
[0038] Wherein is the cumulative value of the memory demand of all processes on the th CPU; is the available memory of the th CPU, is the utilization rate of the th CPU, is the length of the process queue of the th CPU; is the adjustment coefficient;
[0039] The CPU load state is retrieved through the built-in parameters of the CPU, a number of CPUs with the highest load are determined, and whether it is in a load imbalance state is judged according to a preset load threshold. A number of processes to be executed in the CPU in the imbalance state are extracted as the processes to be transferred;
[0040] For example Figure 1As shown, in the process of generating control block, configuration addressing variable, and give the addressing variable initial value is -1; for each CPU is allocated a unique number n; in the shared memory declaration CPU resource available variable = 1, when the process to be transferred to call CPU resource, first on the available variable minus one operation, and according to the value of the available variable for different processing: if the available variable = 0, then the absence of competition, the process to apply for occupation of the resource to get CPU resource; if the available variable < 0, then there is competition, the process into the queue to be transferred; in the process of releasing CPU resource, on the available variable plus one operation, check the value of the available variable: if the available variable > 0, then there is no other process to use the resource in this period, namely the absence of competition, the process normal execution; if the available variable ≤ 0, then there is a process to use the resource in this period, namely the existence of competition, the process into the queue to be transferred;
[0041] In certain process no longer occupies CPU resource, but still exists competition, then get the current CPU number and assign it to the addressing variable, and as the next process to be awakened to the addressing variable of the transfer parameter passed to the wake-up program;
[0042] Step S2, traversal of the queue to be transferred, to determine whether the addressing variable is equal to the local CPU number, if yes, then the process is added to the transfer queue and step S3, if not, directly to step S3;
[0043] In particular, if the destination CPU of the process to be transferred is in the state of unacceptable transfer, then according to the standard kernel operation process, the process is not added to the transfer queue;
[0044] Step S3, to determine whether to complete a traversal, if not, then step S2 continues to traverse, if complete traversal, then determine whether the transfer amount is short, if not, then no process scheduling is executed and the original process scheduling is restored; if yes, then traverse the queue to be transferred, to determine whether the addressing variable is equal to -1, if yes, then the process is added to the transfer sequence and step S6, if not, directly to step S4;
[0045] Step S4, to determine whether to complete a traversal, if not, then step S5 continues to traverse, if complete traversal, then continue to determine whether the transfer amount is short, if not, then no process scheduling is executed and the original process scheduling is restored; if yes, then the queue to be transferred is formed by traversing the queue to be transferred in turn;
[0046] Step S5, the priority of the queue to be transferred is sorted, for a number of processes in the queue to be transferred, the waiting time of each process in the queue to be transferred is analyzed before the process is transferred , and the priority coefficient of the process to be transferred is calculated , wherein is the first an initial priority of the process, is a delay weight coefficient, the initial priority is preset based on a default importance and urgency of the process; and the delay weight represents a weight of a delay of the process; refers to a target CPU of the process, is a load index of the target CPU of the process, is a CPU load weight coefficient; and the process sequence is generated according to the order of the priority coefficients from large to small;
[0047] In step S6, the process sequence is obtained, and the process a with the highest priority in the process sequence is read in sequence;
[0048] The system resources required by the process a with the highest priority are searched, and whether the CPU resources meet the requirements of the system resources are analyzed;
[0049] If there is a CPU meeting the requirements of the system resources, the process a is transferred to the CPU process queue; if there are multiple CPUs meeting the requirements of the system resources, the process a is transferred to the CPU process queue with the lowest load; and if there is no CPU meeting the requirements of the system resources, step S7 is performed;
[0050] In step S7, it is determined whether the process a is the last process in the process sequence, if not, the ability of the CPU meeting the requirements of the system resources is traversed, and the requirements of the system resources are met;
[0051] The load of each CPU group and the required resource shortage are calculated, the CPU group with the total load not lower than the required resource shortage and the lowest average load value is selected as the CPU transfer group, the required resource shortage is extracted and allocated to the CPU transfer group, and the process a is allocated to the CPU group for execution; according to the allocation result of the required resource shortage, the resources are pre-allocated to the CPU, and the load and resource allocation information of each CPU are updated, and step S6 is returned;
[0052] In particular, the resource allocation is completed based on the following steps: analyzing the resource shortage information of the process, determining the required sub-resources, analyzing the required running time of each sub-resource, scanning the CPU process execution queue in the group, counting the process execution idle period, and respectively establishing the sub-resource sequence to be filled and the idle period sequence in the order of time from large to small;
[0053] Select sub-resource A from the sequence of to-be-filled sub-resources in turn, and fill it into the sequence of idle periods in order until a sub-resource B cannot be completely filled into the corresponding idle period, or all idle periods have been filled once; select the first sub-resource B that has not been filled, and compare the remaining available time of each idle period after being filled with the runtime length requirement of the sub-resource B in order of the sequence of idle periods. If the requirement is met, fill it into the corresponding idle period. If all idle periods do not meet the requirement, place it at the end of the sequence of to-be-filled sub-resources; continuously update the sequence of idle periods, and select the remaining sub-resource C in turn, and repeat the above steps until all sub-resources have been filled.
[0054] Through the optimized resource allocation scheme, the idle periods can be fully utilized for resource filling during process execution, thereby effectively reducing resource scheduling delay during process execution, reducing idle machine time, and improving overall operation efficiency of the computer system.
[0055] If the process a is the last process in the process sequence, calculate the load of each CPU group and the required resource shortage, select a CPU group with a total load not lower than the required resource shortage and a lowest average load value as a CPU transfer group, extract the required resource shortage and distribute it to the CPU transfer group, and distribute the process a to the CPU group for execution; according to the required resource shortage distribution result, pre-distribute resources to the CPU, and update the load and resource allocation information of each CPU, and return to step S2.
[0056] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and are not intended to limit the scope of protection of the present application. Although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present application can be modified or replaced by equivalents without departing from the essence and scope of the technical solutions of the present application.
Claims
1. An adaptive process scheduling method for a multi-tasking system, characterized in that, Includes the following steps: Step S1: Determine if the CPU load is balanced. If yes, do not perform process scheduling and restore the original process scheduling. If no, proceed to step S2. CPU load status can be represented as a load index. ; ; in It refers to the first The cumulative memory requirements of all processes on each CPU; For the first Available memory per CPU It refers to the first CPU utilization It refers to the first The length of the process queue per CPU; This is the adjustment coefficient; The CPU load status is retrieved by the CPU built-in parameters to identify the CPUs with the highest load. Based on the preset load threshold, it is determined whether the CPU is in an unbalanced load state. Several processes to be executed in the CPUs in the unbalanced state are extracted as processes to be transferred. During the process control block generation, the addressing variable `index` is configured and initialized to -1; a unique number `n` is assigned to each CPU; the available CPU resource variable `futex` is declared as 1 in shared memory. When a process to be transferred calls CPU resources, the available variable `futex` is first decremented by one, and different processing is performed based on the value of `futex`: if `futex` = 0, it means there is no contention, and the process requesting the resource gets the CPU resource; if `futex` < 0, it means there is contention, and the process is placed in the transfer queue. When a process releases CPU resources, the available variable futex is incremented by one, and then the value of the variable futex is checked: if the available variable futex > 0, it means that no other process has competed for the CPU resources during the time the process released the CPU resources, that is, there is no competition, and the process executes normally. If the available variable futex ≤ 0, it means that a process has tried to use the CPU resource during the time that the process releases the CPU resource, that is, there is competition. In this case, the improved process is placed in the queue to be transferred. When a process no longer occupies CPU resources but there is still contention, the current CPU number is obtained and assigned to the addressing variable index, and then passed as a parameter to the wake-up program to the addressing variable index of the next process to be woken up. Step S2: Traverse the transfer queue and determine whether the addressing variable is equal to the local CPU number. If yes, add the process to the transfer queue and proceed to step S3; otherwise, proceed directly to step S3. Step S3: Determine whether a traversal has been completed. If not, proceed to step S2 to continue traversing. If the traversal is completed, determine whether the transfer amount is insufficient. If not, do not execute process scheduling and restore the original process scheduling. If yes, traverse the queue to be transferred and determine whether the addressing variable is equal to -1. If yes, add the process to the transfer sequence and proceed to step S6. If not, proceed directly to step S4. Step S4: Determine whether a traversal has been completed. If not, proceed to step S5 to continue traversing. If the traversal is completed, continue to determine whether the transfer amount is insufficient. If not, do not execute process scheduling and restore the original process scheduling. If so, traverse the queue to be transferred in sequence to form a sequence of processes to be transferred. Step S5: For several processes in the process sequence to be transferred, analyze the waiting time of each process in the queue to be transferred before performing the process transfer. And calculate the priority coefficient of the process to be transferred. ,in It refers to the first The initial priority of each process. The delay weight coefficient is the initial priority, which is preset based on the default importance and urgency of the process, and represents the weight of the process delay. It refers to the first The CPU load index of each process target. This refers to the CPU load weighting coefficient; a sequence of processes to be transferred is generated based on the priority coefficients from largest to smallest. Step S6: Obtain the process transfer sequence, and sequentially read the process a with the highest priority in the process sequence; Retrieve the system resources required by the highest priority process a, and analyze whether the CPU resources meet the system resource requirements. If a CPU exists that meets the required system resources, process a will be moved to the CPU process queue. If there are multiple CPUs that can meet the required system resources, process a will be moved to the process queue of the CPU with the lowest load. If no CPU is available to meet the required system resources, proceed to step S7; Step S7: Determine whether process a is the last process in the process sequence. If not, iterate through the CPU's ability to meet the required system resources and the ability to meet the required system resources. Calculate the load and required resource deficit of each CPU group, select the CPU group with the total load capacity not less than the required resource deficit and the lowest average load value as the CPU transfer group, extract the required resource deficit and allocate it to the CPU transfer group, and allocate process a to the CPU group for execution; according to the required resource deficit allocation result, pre-allocate resources to the CPU, update the load and resource allocation information of each CPU, and return to step S6. If process a is the last process in the process sequence, calculate the load and required resource deficit of each CPU group, select the CPU group with the total load capacity not lower than the required resource deficit and the lowest average load value as the CPU transfer group, extract the required resource deficit and allocate it to the CPU transfer group, and assign process a to the CPU group for execution; according to the required resource deficit allocation result, pre-allocate resources to the CPU, update the load and resource allocation information of each CPU, and return to step S2.
2. The adaptive process scheduling method for a multi-tasking system according to claim 1, characterized in that, In step S2, if the destination CPU of the process to be transferred is in an unacceptable transfer state, the process will not be added to the transfer queue for the time being.
3. The adaptive process scheduling method for a multi-tasking system according to claim 1, characterized in that, In step S7, for CPUs with existing scheduled tasks, they are removed from the target CPU queue of processes to be transferred.
4. The adaptive process scheduling method for a multi-tasking system according to claim 1, characterized in that, In step S7, resource allocation is completed based on the following steps: Analyze the resource shortage information of the process, determine the required sub-resources, analyze the runtime required for each sub-resource, scan the execution queue of each CPU process in the group, count the idle cycle of process execution, and establish the sequence of sub-resources to be filled and the idle cycle sequence in descending order of duration. Select sub-resources A sequentially from the sequence of sub-resources to be filled, and fill them into the idle cycle sequence in order, until a sub-resource B cannot be completely filled into its corresponding idle cycle, or all idle cycles have been filled once. Select the first unfilled sub-resource B, and compare the remaining available time of each filled idle cycle in the order of the idle cycle sequence with the runtime requirements of sub-resource B. If they meet the requirements, fill it into the corresponding idle cycle. If none of the idle cycle sequences meet the requirements, place it at the end of the sequence of sub-resources to be filled. Continuously update the idle cycle sequence information, select the remaining sub-resources C one by one, and repeat the above steps until all sub-resources have been filled.
Citation Information
Patent Citations
SMP dispatching system-oriented optimization method
CN104657222A
Processor provisioning by a middleware system for a plurality of logical processor partitions
US20140181833A1