System adaptive process scheduling method under multiple tasks
By adopting adaptive process scheduling methods in a multi-task and multi-process environment, the CPU load allocation and resource filling are optimized, and the problems of CPU performance, heating balance and resource allocation in multi-task and multi-process are solved, and the system operation efficiency and resource utilization are improved. .
Patent Information
- Application Number
- CN202411556069.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-11-04
AI Technical Summary
In the case of multitasking and multiprocessing, the prior art is difficult to effectively balance CPU performance and heating, and there are challenges in resource sharing and time resource allocation, which affects the system operation efficiency.
The system adaptive process scheduling method is adopted under multi-task. By judging the CPU load status, extracting the process to be transferred, and optimizing the CPU load allocation and resource filling scheme based on the preset load threshold and resource requirements to realize process transfer and resource allocation.
It improves the operating efficiency of CPU system under multitasking and multi-processes, reduces resource competition, shortens process execution delay, and improves system performance and resource utilization.
Smart Images

Figure CN119473605A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of computer operation control methods, and in particular relates to a system adaptive process scheduling method under multi-task. Background Art
[0002] With the continuous development of computer CPU design and manufacturing technology, CPU performance has been rapidly developed. Although the various performance indicators of single CPU technology are constantly being refreshed, in actual application, in order to better balance CPU performance and heat generation under multi-task and multi-process, computer systems based on multi-core processors and multi-CPU operation are still the most important system structure on the market. Whether it is a single CPU or multi-CPU system, the execution operation of the process is essentially the polling and use of process content and resources during CPU running time. In the case of multi-task and multi-process, it is necessary to first solve the problems of resource sharing, occupation, time resource allocation, etc. to ensure the smooth progress of multiple processes. Summary of the invention
[0003] The purpose of the present invention is to provide a method for adaptively scheduling processes in a multi-tasking system based on actual needs in order to improve the efficiency of system process scheduling management and improve system operating performance.
[0004] To achieve the above purpose, the present invention adopts the following technical solution.
[0005] A method for adaptive process scheduling of a multi-task system comprises the following steps:
[0006] Step S1, determine whether the load is balanced. If so, do not execute process scheduling and restore the original process scheduling; if not, go to step S2;
[0007] Retrieve the CPU load status through the CPU built-in parameters, determine the CPUs with the highest load, determine whether they are in a load imbalance state according to the preset load threshold, and extract the CPUs to be executed in the imbalanced state as the processes to be transferred;
[0008] The CPU load status can be expressed as the load index L i ;
[0009]
[0010] Among them, M i Refers to the cumulative memory requirements of all processes on the i-th CPU; RAM i is the available memory of the ith CPU, U i refers to the utilization of the i-th CPU, L i It refers to the length of the process queue of the i-th CPU; k1, k2 are adjustment coefficients;
[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 -1; a unique number n is assigned to each CPU; the available variable of the CPU resource is declared in the shared memory as 1. When the process to be transferred calls the CPU resource, the available variable is first subtracted by one, and different processing is performed according to the value of the available variable: if the available variable = 0, it means that there is no competition, and the process applying for the resource obtains the CPU resource; if the available variable is <0, it means that there is competition, and the improved process is placed in the queue to be transferred; when the process releases the CPU resource, the available variable is incremented by one, and the value of the available variable is checked again: if the available variable is > 0, it means that no other process has requisitioned the resource during this period, that is, there is no competition, and the process is executed normally; if the available variable is ≤ 0, it means that there is a process requisitioning the resource during this period, that is, there is competition, and the improved process is placed in the queue to be transferred;
[0012] When a process no longer occupies CPU resources but there is still competition, the current CPU number is obtained and assigned to the addressing variable, and it is passed as a transfer parameter of the wake-up program to the addressing variable of the next awakened process;
[0013] Step S2, traverse the queue to be transferred, determine whether the addressing variable is equal to the local CPU number, if so, add the process to the transfer queue and go to step S3, if not, directly go to step S3;
[0014] Step S3, determine whether a traversal is completed. If not, go to step S2 to continue traversal. 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 go to step S6. If not, go directly to step S4.
[0015] Step S4, determine whether a traversal is completed. If not, go to step S5 to continue traversal. If the traversal is completed, continue to determine whether the transfer amount is insufficient. If not, do not execute process scheduling. If so, traverse the queue to be transferred in sequence to form a sequence of processes to be transferred.
[0016] Step S5: for several processes in the process sequence to be transferred, analyze the waiting time T of each process in the queue to be transferred before transferring the process. wait , and calculate the priority coefficient Y of the process to be transferred j,late =Y j +k3·T wait -k4L j ′, where T i It refers to the initial priority of the jth process, k3 is the delay weight coefficient, and the initial priority is pre-set based on the default importance and urgency of the process; it represents the weight of the process delay; L′j It refers to the load index of the target CPU of the jth process, and k4 is the CPU load weight coefficient; the sequence of processes to be transferred is generated in descending order according to the priority coefficient;
[0017] Step S6, obtaining a process transfer sequence, and sequentially reading the process a with the highest priority in the process sequence;
[0018] Retrieve the system resources required by process a with the highest priority, and analyze whether each CPU resource meets the required system resource requirements;
[0019] If there is a CPU that meets the requirements of the required system resources, process a is transferred to the CPU process queue; if there are multiple CPUs that meet the requirements of the required system resources, process a is transferred to the CPU process queue with the lowest load; if there is no CPU that meets the requirements of the required system resources, go to step S7;
[0020] Step S7, determine whether process a is the last process in the process sequence, if not, traverse the CPU's ability to meet the required system resources, and to meet the required system resources;
[0021] Calculate the load and required resource shortage of each CPU group, select the CPU group whose total load is not less than the required resource shortage and whose average load value is the lowest as the CPU transfer group, extract the required resource shortage and allocate it to the CPU transfer group, and allocate process a to the CPU group for execution; pre-allocate resources to the CPU according to the required resource shortage allocation result, and update the load and resource allocation information of each CPU, and return to step S6;
[0022] If process a is the last process in the process sequence, calculate the load and required resource shortage of each CPU group, select the CPU group with a total load not less than the required resource shortage and the lowest average load value as the CPU transfer group, extract the required resource shortage and allocate it to the CPU transfer group, and allocate process a to the CPU group for execution; according to the required resource shortage allocation result, pre-allocate resources to the CPU, and update the load and resource allocation information of each CPU, and return to step S2.
[0023] A further improvement or preferred implementation of the aforementioned system adaptive process scheduling method under multi-tasking is that in step S2, if the destination CPU of the process to be transferred is in a state that cannot accept the transfer, it is executed according to the operating process of the standard kernel and the process is not temporarily added to the transfer queue.
[0024] A further improvement or preferred implementation of the aforementioned adaptive process scheduling method for a multi-tasking system is that in step S7, for a CPU that has a scheduled task, it is removed from the target CPU queue for the process to be transferred.
[0025] A further improvement or preferred implementation of the aforementioned method for adaptive process scheduling in a multi-tasking system is that resource allocation is completed in step S7 based on the following steps:
[0026] Analyze the resource shortage information of the process, determine the required sub-resources, analyze the required running time of each sub-resource, scan the execution queues of each CPU process in the group, count the idle cycles of the process execution, and establish the sequence of sub-resources to be filled and the sequence of idle cycles in descending order of duration;
[0027] Select sub-resource A from the sequence of sub-resources to be filled in sequence, and fill them into the idle cycle sequence in order, until a sub-resource B cannot be completely filled into the 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 idle cycle after filling in the order of the idle cycle sequence to see if it meets the operating time requirement of sub-resource B. If it does, fill it into the corresponding idle cycle. If all idle cycle sequences do not 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.
[0028] Its beneficial effects are:
[0029] The system adaptive process scheduling method under multi-tasking of the present application improves the operating efficiency of the CPU system under multi-tasking and multi-process by optimizing CPU load distribution and resource filling scheme, reduces resource competition, shortens process execution delay, and is conducive to improving system performance and improving the utilization of system resources and performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 This is a schematic diagram of the main structure of the control block of the current process. DETAILED DESCRIPTION
[0031] The present invention is described in detail below in conjunction with specific embodiments.
[0032] The system adaptive process scheduling method under multi-tasking of the present application is mainly used to further optimize the process and resource scheduling management effect between multiple CPUs when a large number of tasks are concurrent and a large number of processes need to be processed at the same time, further reduce the average load size of the CPU under high traffic, and enhance the performance of the computer system.
[0033] The system adaptive process scheduling method under multi-task of the present application mainly includes the following contents:
[0034] In the actual scheduling process, due to the CPU process and resource sharing mechanism, once the process and resource scheduling is started, it will involve the mobilization management of multiple CPUs in the group. Therefore, a suitable mobilization startup mechanism should be set to decide whether to start the process scheduling based on appropriate standards. In this application, the judgment is mainly based on the CPU load index, that is:
[0035] Step S1, determine whether the load is balanced, if so, do not execute process scheduling and restore the original process scheduling; if not, go to step S2;
[0036] The CPU load status can be expressed as the load index L i ;
[0037]
[0038] Among them, M i Refers to the cumulative memory requirements of all processes on the i-th CPU; RAM i is the available memory of the ith CPU, U i refers to the utilization of the i-th CPU, L i It refers to the length of the process queue of the i-th CPU; k1, k2 are adjustment coefficients;
[0039] Retrieve the CPU load status through the CPU built-in parameters, determine the CPUs with the highest load, determine whether they are in a load imbalance state according to the preset load threshold, and extract the CPUs to be executed in the imbalanced state as the processes to be transferred;
[0040] like Figure 1 As shown, 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 -1; a unique number n is assigned to each CPU; the available variable of the CPU resource is declared in the shared memory = 1, and when the process to be transferred calls the CPU resource, the available variable is first subtracted by one, and different processing is performed according to the value of the available variable: if the available variable = 0, it means that there is no competition, and the process applying for occupying the resource obtains the CPU resource; if the available variable is <0, it means that there is competition, and the improved process is placed in the queue to be transferred; when the process releases the CPU resource, the available variable is incremented by one, and the value of the available variable is checked again: if the available variable is > 0, it means that no other process has requisitioned the resource during this period, that is, there is no competition, and the process is executed normally; if the available variable is ≤ 0, it means that there is a process requisitioning the resource during this period, that is, there is competition, and the improved process is placed in the queue to be transferred;
[0041] When a process no longer occupies CPU resources but there is still competition, the current CPU number is obtained and assigned to the addressing variable, and it is passed as a transfer parameter of the wake-up program to the addressing variable of the next awakened process;
[0042] Step S2, traverse the queue to be transferred, determine whether the addressing variable is equal to the local CPU number, if so, add the process to the transfer queue and go to step S3, if not, directly go to step S3;
[0043] In particular, if the destination CPU of the process to be transferred is in a state that cannot accept the transfer, the standard kernel operation process is followed and the process is not added to the transfer queue for the time being;
[0044] Step S3, determine whether a traversal is completed. If not, go to step S2 to continue traversal. 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 go to step S6. If not, go directly to step S4.
[0045] Step S4, determine whether a traversal is completed. If not, go to step S5 to continue traversal. 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 yes, traverse the queue to be transferred in sequence to form a sequence of processes to be transferred.
[0046] Step S5: Prioritize the process sequence to be transferred. For several processes in the process sequence to be transferred, analyze the waiting time T of each process in the queue to be transferred before transferring the process. wait , and calculate the priority coefficient Y of the process to be transferred j,late =Y j +k3·T wait -k4L′ j , where T i It refers to the initial priority of the jth process, k3 is the delay weight coefficient, and the initial priority is pre-set based on the default importance and urgency of the process; it represents the weight of the process delay; L′ j It refers to the load index of the target CPU of the jth process, and k4 is the CPU load weight coefficient; the sequence of processes to be transferred is generated in descending order according to the priority coefficient;
[0047] Step S6, obtaining a process transfer sequence, and sequentially reading the process a with the highest priority in the process sequence;
[0048] Retrieve the system resources required by process a with the highest priority, and analyze whether each CPU resource meets the required system resource requirements;
[0049] If there is a CPU that meets the requirements of the required system resources, process a is transferred to the CPU process queue; if there are multiple CPUs that meet the requirements of the required system resources, process a is transferred to the CPU process queue with the lowest load; if there is no CPU that meets the requirements of the required system resources, go to step S7;
[0050] Step S7, determine whether process a is the last process in the process sequence, if not, traverse the CPU's ability to meet the required system resources, and to meet the required system resources;
[0051] Calculate the load and required resource shortage of each CPU group, select the CPU group whose total load is not less than the required resource shortage and whose average load value is the lowest as the CPU transfer group, extract the required resource shortage and allocate it to the CPU transfer group, and allocate process a to the CPU group for execution; pre-allocate resources to the CPU according to the required resource shortage allocation result, and update the load and resource allocation information of each CPU, and return to step S6;
[0052] In particular, 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 execution queues of each CPU process in the group, counting the idle cycles of the process execution, and establishing the sequence of sub-resources to be filled and the sequence of idle cycles in descending order of duration;
[0053] Select sub-resource A from the sequence of sub-resources to be filled in sequence, and fill them into the idle cycle sequence in sequence, until a certain sub-resource B cannot be completely filled into the 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 idle cycle after filling in the order of the idle cycle sequence to see whether it meets the running time requirement of sub-resource B. If it meets the requirement, fill it into the corresponding idle cycle. If all idle cycle sequences do not meet the requirement, 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;
[0054] Through the optimized resource allocation scheme, we can make full use of idle cycles to fill resources during process execution, thereby effectively reducing resource scheduling delays during process execution, reducing idle time, and improving the overall operating efficiency of the computer system.
[0055] If process a is the last process in the process sequence, calculate the load and required resource shortage of each CPU group, select the CPU group with a total load not less than the required resource shortage and the lowest average load value as the CPU transfer group, extract the required resource shortage and allocate it to the CPU transfer group, and allocate process a to the CPU group for execution; according to the required resource shortage allocation result, pre-allocate 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 solution of the present invention, rather than to limit the scope of protection of the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the essence and scope of the technical solution of the present invention.
Claims
1. A method for adaptive process scheduling in a multi-task system, characterized in that: The steps include: Step S1, determine whether the load is balanced, if so, do not execute process scheduling and restore the original process scheduling; if not, go to step S2; The CPU load status can be expressed as the load index L i ; Among them, M i Refers to the cumulative memory requirements of all processes on the i-th CPU; RAM i is the available memory of the ith CPU, U i refers to the utilization of the i-th CPU, L i It refers to the length of the process queue of the i-th CPU; k1, k2 are adjustment coefficients; Retrieve the CPU load status through the CPU built-in parameters, determine the CPUs with the highest load, determine whether they are in a load imbalance state according to the preset load threshold, and extract the CPUs to be executed in the imbalanced state as the processes to be transferred; In the process of generating the control block of the process, the addressing variable index is configured, and the initial value of the addressing variable index is assigned to -1; a unique number n is assigned to each CPU; the available variable futex of the CPU resource is declared in the shared memory as 1. When the process to be transferred calls the CPU resource, the available variable futex is first decremented by one, and different processing is performed according to the value of the available variable futex: if the available variable futex = 0, it means that there is no competition, and the process applying for the resource obtains the CPU resource; if the available variable futex < 0, it means that there is competition, and the modified process is placed in the queue to be transferred; when the process releases the CPU resource, the available variable futex is incremented by one, and the value of the variable futex is checked: if the available variable futex > 0, it means that no other process has requisitioned the resource during this period, that is, there is no competition, and the process is executed normally; If the available variable futex≤0, it means that there is a process to requisition the resource during this period, that is, there is competition, and the improved process is placed in the queue to be transferred; When a process no longer occupies CPU resources but there is still competition, the current CPU number is obtained and assigned to the addressing variable index, and it is passed as a transfer parameter of the wake-up program to the addressing variable index of the next awakened process; Step S2, traverse the queue to be transferred, determine whether the addressing variable is equal to the local CPU number, if so, add the process to the transfer queue and go to step S3, if not, directly go to step S3; Step S3, determine whether a traversal is completed. If not, go to step S2 to continue traversal. 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 go to step S6. If not, go directly to step S4. Step S4, determine whether a traversal is completed. If not, go to step S5 to continue traversal. 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 yes, 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 T of each process in the queue to be transferred before transferring the process. wait , and calculate the priority coefficient Y of the process to be transferred j,late =Y j +k3×T wait -k4L j ¢, where T i It refers to the initial priority of the jth process, k3 is the delay weight coefficient, and the initial priority is pre-set based on the default importance and urgency of the process; it represents the weight of the process delay; L j ¢ refers to the load index of the target CPU of the jth process, and k4 is the CPU load weight coefficient; the sequence of processes to be transferred is generated in descending order according to the priority coefficient; Step S6, obtaining a process transfer sequence, and sequentially reading the process a with the highest priority in the process sequence; Retrieve the system resources required by process a with the highest priority, and analyze whether each CPU resource meets the required system resource requirements; If there is a CPU that meets the requirements of the required system resources, process a is transferred to the CPU process queue; If there are multiple CPUs that meet the requirements of the required system resources, process a is transferred to the process queue of the CPU with the lowest load; If there is no CPU that meets the requirements of the required system resources, go to step S7; Step S7, determine whether process a is the last process in the process sequence, if not, traverse the CPU's ability to meet the required system resources, and to meet the required system resources; Calculate the load and required resource shortage of each CPU group, select the CPU group whose total load is not less than the required resource shortage and whose average load value is the lowest as the CPU transfer group, extract the required resource shortage and allocate it to the CPU transfer group, and allocate process a to the CPU group for execution; pre-allocate resources to the CPU according to the required resource shortage allocation result, and 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 shortage of each CPU group, select the CPU group with a total load not less than the required resource shortage and the lowest average load value as the CPU transfer group, extract the required resource shortage and allocate it to the CPU transfer group, and allocate process a to the CPU group for execution; according to the required resource shortage allocation result, pre-allocate resources to the CPU, and update the load and resource allocation information of each CPU, and return to step S2.
2. The method for adaptive process scheduling in 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 a state that cannot accept the transfer, the operation flow of the standard kernel is followed and the process is not added to the transfer queue temporarily.
3. The method for adaptive process scheduling in a multi-tasking system according to claim 1, characterized in that: In step S7, the CPU that has a scheduled task is removed from the target CPU queue of the process to be transferred.
4. The method for adaptive process scheduling in 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 required running time of each sub-resource, scan the execution queues of each CPU process in the group, count the idle cycles of the process execution, and establish the sequence of sub-resources to be filled and the sequence of idle cycles in descending order of duration; Select sub-resource A from the sequence of sub-resources to be filled in sequence, and fill them into the idle cycle sequence in order, until a sub-resource B cannot be completely filled into the 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 idle cycle after filling in the order of the idle cycle sequence to see if it meets the operating time requirement of sub-resource B. If it does, fill it into the corresponding idle cycle. If all idle cycle sequences do not 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