Task scheduling method, system and equipment for multi-stage feedback queue and medium
The task scheduling method optimizes multi-level feedback queue algorithms by assigning fixed priorities and using priority aging channels and elastic queues to enhance computing efficiency and resource utilization, addressing inefficiencies in existing algorithms.
Patent Information
- Application Number
- CN202411106959.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2044-08-13
AI Technical Summary
The existing multi-level feedback queue scheduling algorithm has low scheduling efficiency and high system task load due to complex design and frequent task migrations between queues, leading to resource waste and reduced computing efficiency.
A task scheduling method that assigns tasks to fixed priority queues based on attribute parameters, uses priority aging channels to prevent starvation, and employs elastic queue containers to dynamically adjust queue sizes and priorities, ensuring fair resource allocation.
Reduces unnecessary context switching, avoids starvation, and improves computing resource utilization by 6.1%, decreases turnaround time by 3.2%, and reduces energy consumption by 3.7%, enhancing overall system efficiency and throughput.
Smart Images

Figure CN119179558A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computing center scheduling algorithms, and in particular to a task scheduling method, system, device and medium for a multi-level feedback queue. Background Art
[0002] In recent years, the emergence of emerging technologies such as big data and cloud computing has brought new challenges to the research of task scheduling methods. The multi-level feedback queue scheduling algorithm is a dynamic scheduling algorithm that was first used in CPU process scheduling and later also used in task scheduling in computing centers. The algorithm can dynamically adjust the priority of the process according to its running characteristics, thereby improving the overall performance and efficiency of the system. The multi-level feedback queue scheduling algorithm balances the response time and throughput of the system; by dividing multiple priority queues, it ensures that different types of processes can share CPU resources relatively fairly.
[0003] The existing multi-level feedback queue scheduling algorithm has low scheduling efficiency for tasks and is complex in design, which increases the system task load in the CPU process.
[0004] It can be seen that how to optimize the processing efficiency of multiple tasks in the CPU and improve the flexibility of task priorities, thereby reducing the system task load in the CPU process, has become a technical problem that technical personnel in this field need to solve urgently. Summary of the invention
[0005] The present invention provides a task scheduling method, system, device and medium for a multi-level feedback queue to solve the problem of how to improve the multi-level feedback queue scheduling algorithm to improve the utilization rate of computing resources and reduce the system switching load.
[0006] In order to solve the above technical problems, an embodiment of the present invention provides a task scheduling method for a multi-level feedback queue, including:
[0007] According to different attribute parameters of each task to be executed in the CPU, each of the tasks is assigned to a corresponding queue, and a corresponding first queue priority is determined;
[0008] Designing priority aging channels between different queues, and allocating corresponding global variables to each queue, wherein the global variables reflect the time point when the current queue last executed task scheduling;
[0009] Determine a queue to be adjusted that is in a starving state based on each of the global variables and a time point when the CPU executes the current queue;
[0010] When the starvation time of the queue to be adjusted exceeds a preset starvation threshold, based on the corresponding priority aging channel and the first queue priority, the tasks to be adjusted in the queue to be adjusted are adjusted to the upper-level queue to obtain the adjusted second queue priority;
[0011] The tasks are scheduled according to the task execution sequence corresponding to the second queue priority.
[0012] Furthermore, the method of allocating each task to a corresponding queue according to different attribute parameters of each task to be executed in the CPU and determining the corresponding first queue priority includes:
[0013] Different queues are allocated according to the resource consumption, execution time and execution urgency of each task to be executed; each queue reflects a different priority.
[0014] Furthermore, it also includes:
[0015] The size of each queue is dynamically adjusted according to the resource occupancy of the task and historical task scheduling records.
[0016] Furthermore, the designing of priority aging channels between different queues includes:
[0017] According to the priority order of the first queue priorities, a threshold ratio of the starvation time between the queues is set to obtain a starvation threshold of each queue;
[0018] According to the number of tasks in each queue, setting the width ratio of the aging channels between the queues to obtain the aging channel width of each queue;
[0019] Priority aging channels are constructed between different queues according to the starvation threshold and the aging channel width.
[0020] Further, the determining of the queue to be adjusted in a starving state based on each of the global variables and the time point when the CPU executes the current queue includes:
[0021] Obtaining a first time point when the current queue of each global variable record last executed task scheduling and a second time point when the CPU executed the current queue;
[0022] The time difference between the first time point and the second time point is compared, the starvation state of the current queue is judged, and the queue to be adjusted in the starvation state is obtained.
[0023] Furthermore, the scheduling of tasks according to the task execution sequence corresponding to the second queue priority includes:
[0024] Determine a space status of a target priority queue corresponding to the second queue priority being executed;
[0025] When the space status tasks are not full, determining the task execution status of the task pool;
[0026] When there are tasks to be executed in the task pool, the tasks to be executed are filled into the target priority queue.
[0027] Furthermore, it also includes:
[0028] dividing each queue of the second queue priority into a first queue and a second queue;
[0029] The first queue receives the to-be-executed tasks filled from the task pool, and the second queue receives the to-be-adjusted tasks adjusted from the to-be-adjusted queue.
[0030] Another embodiment of the present invention provides a task scheduling system for a multi-level feedback queue, including:
[0031] A preprocessing module, for allocating each task to be executed in the CPU to a corresponding queue according to different attribute parameters of the task, and determining the corresponding first queue priority;
[0032] A priority aging channel construction module is used to design priority aging channels between different queues and allocate a corresponding global variable to each queue, wherein the global variable reflects the time point when the current queue last executed task scheduling;
[0033] A comparison module, used for determining a queue to be adjusted in a starving state based on each of the global variables and a time point when the CPU executes the current queue;
[0034] A priority updating module, configured to adjust the tasks to be adjusted in the queue to be adjusted to the upper queue based on the corresponding priority aging channel and the first queue priority when the starvation time of the queue to be adjusted exceeds a preset starvation threshold, so as to obtain an adjusted second queue priority;
[0035] The task scheduling module is used to schedule tasks according to the task execution sequence corresponding to the second queue priority.
[0036] Yet another embodiment of the present invention provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the task scheduling method of the multi-level feedback queue as described above when executing the computer program.
[0037] Yet another embodiment of the present invention provides a computer-readable storage medium storing a computer program, wherein when a device where the computer-readable storage medium is located executes the computer program, the task scheduling method of the multi-level feedback queue as described above is implemented.
[0038] Compared with the prior art, the embodiments of the present invention have the following advantages:
[0039] (1) Fixed priority technology is used to improve the predictability of the behavior of tasks to be run. For processes that require a quick response, their priority is increased to ensure that they can be responded to in the shortest possible time. In addition, by reasonably setting the queue time slice and task priority, unnecessary context switching is reduced, especially under high load conditions, avoiding performance degradation caused by frequent switching.
[0040] (2) By using priority aging technology and elastic queue containers, we can dynamically set the aging time threshold and elastic queue container size to ensure that all types of processes can get reasonable CPU time. This can avoid starvation and improve the utilization rate of computing resources, especially for long-term and I / O-intensive jobs. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 is a flow chart of a task scheduling method for a multi-level feedback queue in one embodiment of the present invention;
[0042] Figure 2 is a task scheduling system architecture diagram in one embodiment of the present invention;
[0043] Figure 3 is a schematic diagram of a task priority update process in one embodiment of the present invention;
[0044] Figure 4 is a general flow chart of task scheduling in one embodiment of the present invention;
[0045] Figure 5 It is a structural block diagram of a task scheduling system with a multi-level feedback queue in one embodiment of the present invention;
[0046] Figure 6 It is a block diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. The purpose of providing these embodiments is to make the disclosure of the present invention more thorough and comprehensive. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] In the description of this application, the terms "first", "second", "third", etc. are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first", "second", "third", etc. may explicitly or implicitly include one or more of the feature. In the description of this application, unless otherwise specified, "plurality" means two or more.
[0049] In the description of the present application, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be a connection between the two elements. The terms "vertical", "horizontal", "left", "right", "upper", "lower" and similar expressions used herein are only for illustrative purposes, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention. The term "and / or" used herein includes any and all combinations of one or more related listed items. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0050] In the description of this application, it should be noted that, unless otherwise defined, all technical and scientific terms used in the present invention have the same meaning as those commonly understood by those skilled in the art. The terms used in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood by specific circumstances.
[0051] In view of the high design difficulty of the existing multi-level feedback queue task scheduling algorithm during the system construction process, and the problem that the system load will be increased when tasks are migrated between multiple queues, an embodiment of the present invention provides a method. For details, please refer to Figure 1 , Figure 1The flowchart of the task scheduling method of the multi-level feedback queue in one embodiment of the present invention includes the following steps:
[0052] S1. According to different attribute parameters of each task to be executed in the CPU, each task is assigned to a corresponding queue, and the corresponding first queue priority is determined.
[0053] Specifically, in this embodiment, different queues are allocated according to the resource consumption, execution time and execution urgency of each task to be executed; each queue reflects a different priority.
[0054] In the traditional multi-level feedback queue scheduling algorithm, the priority queue to be scheduled is determined by the time slice required for the task. For example, when a task requires a long time slice, the task starts from the highest priority queue. When the queue time slice is completed, it is continuously scheduled to the lower priority queue until the task is finally completed. When the above scheduling occurs, a task switches between priority queues multiple times, resulting in a waste of system resources in context switching and reduced computing efficiency.
[0055] The fixed priority strategy adopted in the task scheduling of the CPU of this embodiment is an effective method to optimize resource allocation and improve system performance. This method assigns fixed priorities to tasks in advance according to specific attribute parameters of the tasks, such as resource consumption, execution time, execution urgency, etc., and puts them into queues of corresponding priorities. The first queue priority here means that tasks with different attributes are assigned to queues of different priorities, that is, from high priority to low priority. In the fixed priority strategy of the embodiment of the present invention, tasks will only be assigned to queues of corresponding priorities. Compared with the traditional scheduling algorithm, the fixed priority strategy avoids frequent switching of tasks between different queues and reduces the useless waste of system resources.
[0056] Specifically, please refer to Figure 2 , Figure 2 Shown is a task scheduling system architecture diagram in one embodiment of the present invention.
[0057] from Figure 2It can be seen that this embodiment still chooses to retain the classic structure of a multi-level feedback queue, that is, multiple queues with different priorities, and the processes in each queue have different priorities and time slice sizes. High-priority queues have shorter time slices, and low-priority queues have longer time slices. The adoption of a fixed priority strategy makes the entire scheduling process efficient. It is understandable that since the priority of the task is fixed, the behavior of the system becomes relatively predictable, and compared with the traditional strategy of adjusting priority, the fixed priority strategy simplifies the scheduling algorithm and reduces the complexity of scheduling. In addition, in some cases, dynamic adjustment of priority may cause priority inversion problems, that is, low-priority tasks are blocked due to waiting for resources occupied by high-priority tasks, resulting in the inability of high-priority tasks to be executed in time. The fixed priority strategy can effectively avoid such problems by pre-defining priorities.
[0058] Preferably, in an embodiment of the present invention, the improved multi-level feedback queue is set to have multiple queues with different priorities, for example, 5 queues can be set, and the default length of each queue can be set to an appropriate number of task units, for example, the length can be set to 200. Specifically, the time slice size ratio is 1:8:16:64:128 according to the queue priority from high to low.
[0059] Furthermore, the size of each queue is dynamically adjusted according to the resource occupancy of the task and historical task scheduling records.
[0060] Specifically, the system will dynamically adjust the size of each priority queue based on the current resource usage, including computing resources such as CPU and GPU, storage resources such as memory and hard disk, and historical task execution records. This step ensures that the system can optimize the efficiency of task scheduling based on the actual workload and resource status.
[0061] S2. Designing priority aging channels between different queues, and allocating corresponding global variables to each queue, wherein the global variables reflect the time point when the current queue last executed task scheduling.
[0062] When using the traditional multi-level feedback queue algorithm for task scheduling, the following situation may occur: when high-priority tasks continuously enter the scheduling queue, low-priority tasks may be "starved to death" because high-priority tasks continue to occupy computing resources. Based on this, the embodiment of the present invention designs a priority aging channel between each priority queue. When the time for which a low-priority queue cannot obtain CPU computing resources exceeds the starvation time threshold set by this queue, one or more tasks in this queue will be transferred to a higher-level queue through the "aging channel".
[0063] The following is a detailed description of the construction process of the above priority aging channel:
[0064] First, according to the priority order of the first queue priorities, the threshold ratio of the starvation time between the queues is set to obtain the starvation threshold of each queue. According to the number of tasks in each queue, the width ratio of the aging channel between the queues is set to obtain the aging channel width of each queue.
[0065] In this embodiment, the threshold ratio of the starvation time is used to determine how long each queue has not obtained CPU resources before being considered to be in a starvation state.
[0066] Preferably, since low-priority tasks often have the characteristics of being time-insensitive, heavy-loaded, and having a long computing time, in order to avoid encroaching on the execution of original priority tasks when they are transferred to high-priority queues, the embodiment of the present invention sets the queue time threshold ratio to 1:10:100:1000:10000 in order of priority, and the aging channel width is set (in terms of the number of tasks) in a ratio of 1:2:4:8:16, which reflects the rate or capacity of moving tasks from one queue to another (usually a queue with a lower priority).
[0067] Finally, priority aging channels are constructed between different queues according to the starvation threshold and the aging channel width.
[0068] According to the previously set starvation threshold and aging channel width, priority aging channels are built between different queues. These channels allow queues to move tasks from one queue to another when certain conditions are met (such as reaching the starvation threshold), thereby avoiding starvation and optimizing the overall performance of the system.
[0069] Furthermore, in this embodiment, the premise for detecting whether a queue is "starved" is to assign a global variable (last_work_time) to each queue. In the scheduling system, the global variable of each priority queue is used to record the time point when a task in the queue was last executed and obtained CPU resources. The allocation of global variables enables the system to track the activity and starvation level of each queue. By comparing these variables with the current time, the system can quickly identify which queues have not obtained CPU resources for a long time, and take corresponding adjustment measures.
[0070] S3. Determine the queue to be adjusted that is in a starving state based on each of the global variables and the time point when the CPU executes the current queue.
[0071] Specifically, obtain the first time point when the current queue last executed task scheduling and the second time point when the CPU executed the current queue recorded by each global variable; compare the time difference between the first time point and the second time point, judge the starvation state of the current queue, and obtain the queue to be adjusted in the starvation state.
[0072] In this embodiment, the first time point is usually when a task in the queue is selected by the scheduler and removed from the queue so as to be updated when executed on the CPU, and the second time point refers to the time point when the current queue is executed. Therefore, in subsequent scheduling cycles, the scheduler can determine whether the queue is in a starvation state by comparing the first time point recorded by the global variable with the second time point at the current moment.
[0073] When it is determined that the queue is in a starvation state, the queues to be adjusted in the starvation state are obtained. Next, the priorities of the tasks in these queues need to be updated to solve the "starvation" problem.
[0074] S4. When the starvation time of the queue to be adjusted exceeds a preset starvation threshold, based on the corresponding priority aging channel and the first queue priority, the tasks to be adjusted in the queue to be adjusted are adjusted to the upper-level queue to obtain the adjusted second queue priority.
[0075] Specifically, when the queue is hungry, the scheduler will pop out multiple predecessor tasks in the queue through the priority aging channel and fill them into the queue of the upper level of the queue. This process is carried out from bottom to top, that is, the tasks in the lowest priority queue will be popped out first, and the tasks in the highest priority queue will be popped out last.
[0076] Preferably, the second queue priority obtained at this time is the queue priority that solves the problem that tasks in the low-priority queue are "starved" due to the continuous occupation of computing resources by tasks in the high-priority queue. This process greatly improves the utilization of computing resources. For details on the task priority update process, please refer to Figure 3 , Figure 3 The figure shows a task priority updating process diagram in one embodiment of the present invention.
[0077] It can be seen that due to the performance of the priority aging channel, one or more tasks are popped out of the "starved" queue and filled into the queue of the previous priority of this queue. In this way, the tasks will be scheduled with priority to avoid being "starved to death".
[0078] S5. Schedule tasks according to the task execution sequence corresponding to the priority of the second queue.
[0079] After the above adjustments, the previous queue now contains the tasks to be adjusted that originally belonged to the current queue, as well as the tasks it originally had. This adjusted previous queue now becomes a new queue with an updated priority. The system now schedules tasks according to the task execution sequence corresponding to the priority of the second queue. In addition, the system should continue to monitor the status of all queues, including starvation time, number of tasks, etc., so as to make further adjustments when necessary. If it is found that other queues have also reached the starvation threshold, the above process can be repeated to adjust the tasks to a higher-level queue.
[0080] Furthermore, this embodiment requires checking the queue, please refer to Figure 4 , Figure 4 The following is a general flow chart of task scheduling in one embodiment of the present invention. Specifically:
[0081] First, determining a space status of a target priority queue corresponding to the second queue priority being executed;
[0082] The space status here refers to whether the number of tasks in each queue at this time is sufficient to fill the queue. Because the entire scheduling process is dynamic, when tasks are popped out or adjusted, there will be free space in the queue.
[0083] Then, when the space status tasks are not full, the task execution status of the task pool is determined; when there are tasks to be executed in the task pool, the tasks to be executed are filled into the target priority queue.
[0084] The task pool is a container for storing tasks to be executed in the scheduling system. When there are tasks waiting to be executed in the task pool, and the space status of the target task queue to be executed is not full at this time, the scheduler will take the tasks from the task pool and fill them into the queue with "free space". This process ensures that the task queue always remains active and avoids waste of resources.
[0085] Furthermore, in view of the above-mentioned priority update and task pool task filling process, this embodiment provides a flexible queue container, which is intended to specifically adapt the priority aging channel and the entire scheduling process.
[0086] Specifically, this embodiment divides each queue of the second queue priority into a first queue and a second queue; the first queue receives the tasks to be executed filled from the task pool, and the second queue receives the tasks to be adjusted adjusted from the queue to be adjusted.
[0087] Preferably, the embodiment of the present invention divides these queues of different priorities into two types: elastic queues and rigid queues. In this embodiment, it can be understood that the first queue mentioned above is a rigid queue and the second queue is an elastic queue. The rigid queue has a fixed length and is filled by tasks from the task pool; the elastic queue length can be adjusted according to the current load of the system and the execution of historical tasks, and is filled by tasks from the priority aging channel.
[0088] Preferably, the elastic queue and the rigid queue have the same priority and follow the first-come-first-served principle. In the default setting of the embodiment of the present invention, the capacity ratio of the elastic queue and the rigid queue of each level of queue is the same: both are set to 1:10.
[0089] The existence of elastic queues prevents low-priority tasks from affecting the execution efficiency of high-priority tasks after their priorities are increased through the aging channel; in addition, the scheduler can adjust the elastic queue capacity of different priority queues in real time according to the current system resource utilization and load status before each scheduling, which further improves the control sensitivity of the scheduling algorithm to different types of tasks. Specifically, the specific structure of rigid queues and elastic queues can be referred to Figure 2 shown.
[0090] When performing task scheduling, the embodiment of the present invention also takes targeted measures to avoid the inefficiency of system operation. Specifically: during the execution process, the system will check the status of all priority queues. If all queues are empty, the system default idle task (idle_task) is selected to execute to maintain the stable operation of the system. If there is a non-empty queue, the system will select the first task from the current highest priority non-empty queue for execution. It can be understood that this embodiment can ensure the priority processing of urgent and important tasks through the above measures, thereby improving the efficiency of system operation.
[0091] The embodiments of the present invention were also simulated. In the simulation experiment of the simulator, the scheduling algorithm proposed in the embodiments of the present invention reduced the average turnaround time of tasks by 3.2%, reduced the average waiting time by 4.1%, and increased the system task throughput by 7.1%. The efficiency of the computing center was increased by about 6.1%, and the energy consumption was reduced by about 3.7%.
[0092] In summary, a task scheduling method for a multi-level feedback queue proposed in an embodiment of the present invention adopts a fixed priority strategy, so that tasks are targetedly assigned to appropriate priority queues, reducing the number of unnecessary context switches of system resources, and avoiding the problems of resource waste and low computing efficiency caused by the process; at the same time, a priority aging channel and an elastic queue container are designed to specifically solve the starvation problem of low-priority queues, and by dynamically setting the aging time threshold and the elastic queue container size, it is ensured that each type of process can obtain a reasonable CPU time. Compared with the prior art, the scheduling method of the embodiment of the present invention can reduce the complexity of scheduling, improve the efficiency of scheduling, and significantly improve the application rate of computing resources.
[0093] An embodiment of the present invention provides a task scheduling system for a multi-level feedback queue. For details, see Figure 5 , Figure 5 The structure block diagram of the task scheduling system of the multi-level feedback queue in one embodiment of the present invention is shown, including:
[0094] The preprocessing module M1 is used to allocate each task to a corresponding queue according to different attribute parameters of each task to be executed in the CPU, and determine the corresponding first queue priority;
[0095] The priority aging channel construction module M2 is used to design priority aging channels between different queues and allocate a corresponding global variable to each queue, wherein the global variable reflects the time point when the current queue last executed task scheduling;
[0096] A comparison module M3, used to determine the queue to be adjusted in a starving state based on each of the global variables and the time point when the CPU executes the current queue;
[0097] The priority updating module M4 is used to adjust the tasks to be adjusted in the queue to be adjusted to the upper-level queue based on the corresponding priority aging channel and the first queue priority when the starvation time of the queue to be adjusted exceeds a preset starvation threshold, so as to obtain the adjusted second queue priority;
[0098] The task scheduling module M5 is used to schedule tasks according to the task execution sequence corresponding to the second queue priority.
[0099] like Figure 6 As shown, the embodiment of the present invention further provides a computer device, Figure 6A structural block diagram of a preferred embodiment of a computer device provided by the present invention, wherein the computer device includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and the processor implements the task scheduling method of a multi-level feedback queue as described above when executing the computer program.
[0100] Preferably, the computer program can be divided into one or more modules / units (such as computer program 1, computer program 2, ...), and the one or more modules / units are stored in the memory and executed by the processor to complete the present invention. The one or more modules / units can be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the computer program in the computer device.
[0101] The processor may be a central processing unit (CPU), or other general-purpose processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor, or the processor may be any conventional processor. The processor is the control center of the terminal device, and various parts of the terminal device are connected using various interfaces and lines.
[0102] The memory mainly includes a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function, etc., and the data storage area can store related data, etc. In addition, the memory can be a high-speed random access memory, or a non-volatile memory, such as a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, and a flash card (Flash Card), etc., or the memory can also be other volatile solid-state storage devices.
[0103] It should be noted that the above terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art will understand that Figure 6The structural block diagram is only an example of a terminal device and does not constitute a limitation on the terminal device. It may include more or fewer components than shown in the figure, or combine certain components, or different components. A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it may include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium may be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0104] Accordingly, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to perform the steps of the task scheduling method of the multi-stage feedback queue in the above embodiment, for example Figure 1 Steps S1 to S5 described in .
[0105] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A task scheduling method for a multi-level feedback queue, characterized in that: include: According to different attribute parameters of each task to be executed in the CPU, each of the tasks is assigned to a corresponding queue, and a corresponding first queue priority is determined; Designing priority aging channels between different queues, and allocating corresponding global variables to each queue, wherein the global variables reflect the time point when the current queue last executed task scheduling; Determine a queue to be adjusted that is in a starving state based on each of the global variables and a time point when the CPU executes the current queue; When the starvation time of the queue to be adjusted exceeds a preset starvation threshold, based on the corresponding priority aging channel and the first queue priority, the tasks to be adjusted in the queue to be adjusted are adjusted to the upper-level queue to obtain the adjusted second queue priority; The tasks are scheduled according to the task execution sequence corresponding to the second queue priority.
2. The task scheduling method of the multi-level feedback queue according to claim 1, characterized in that: The method of allocating each task to a corresponding queue according to different attribute parameters of each task to be executed in the CPU and determining the corresponding first queue priority includes: Different queues are allocated according to the resource consumption, execution time and execution urgency of each task to be executed; each queue reflects a different priority.
3. The task scheduling method of the multi-level feedback queue as claimed in claim 2, characterized in that: Also includes: The size of each queue is dynamically adjusted according to the resource occupancy of the task and historical task scheduling records.
4. The task scheduling method of the multi-level feedback queue according to claim 1, characterized in that: The designing of priority aging channels between different queues includes: According to the priority order of the first queue priorities, a threshold ratio of the starvation time between the queues is set to obtain a starvation threshold of each queue; According to the number of tasks in each queue, setting the width ratio of the aging channels between the queues to obtain the aging channel width of each queue; Priority aging channels are constructed between different queues according to the starvation threshold and the aging channel width.
5. The task scheduling method of the multi-level feedback queue according to claim 1, characterized in that: The step of determining a queue to be adjusted in a starving state based on each of the global variables and a time point when the CPU executes the current queue includes: Obtaining a first time point when the current queue of each global variable record last executed task scheduling and a second time point when the CPU executed the current queue; The time difference between the first time point and the second time point is compared, the starvation state of the current queue is judged, and the queue to be adjusted in the starvation state is obtained.
6. The task scheduling method of the multi-level feedback queue according to claim 1, characterized in that: The scheduling of tasks according to the task execution sequence corresponding to the second queue priority includes: Determine a space status of a target priority queue corresponding to the second queue priority being executed; When the space status tasks are not full, determining the task execution status of the task pool; When there are tasks to be executed in the task pool, the tasks to be executed are filled into the target priority queue.
7. The task scheduling method of the multi-level feedback queue according to claim 6, characterized in that: Also includes: dividing each queue of the second queue priority into a first queue and a second queue; The first queue receives the to-be-executed tasks filled from the task pool, and the second queue receives the to-be-adjusted tasks adjusted from the to-be-adjusted queue.
8. A task scheduling system for a multi-level feedback queue, characterized in that: include: A preprocessing module, for allocating each task to be executed in the CPU to a corresponding queue according to different attribute parameters of the task, and determining the corresponding first queue priority; A priority aging channel construction module is used to design priority aging channels between different queues and allocate a corresponding global variable to each queue, wherein the global variable reflects the time point when the current queue last executed task scheduling; A comparison module, used for determining a queue to be adjusted in a starving state based on each of the global variables and a time point when the CPU executes the current queue; A priority updating module, configured to adjust the tasks to be adjusted in the queue to be adjusted to the upper queue based on the corresponding priority aging channel and the first queue priority when the starvation time of the queue to be adjusted exceeds a preset starvation threshold, so as to obtain an adjusted second queue priority; The task scheduling module is used to schedule tasks according to the task execution sequence corresponding to the second queue priority.
9. A computer device, characterized in that: It comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and when the processor executes the computer program, it implements the task scheduling method of the multi-stage feedback queue as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the device where the computer-readable storage medium is located executes the computer program, the task scheduling method of the multi-stage feedback queue according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Multi-task management method combining time slice rotation with extended interruption
CN112596891A
Heterogeneous multi-robot task scheduling method and system based on multistage feedback queue
CN114691340A
Backup task scheduling method and system based on time slice
CN117742910A
Cited By
Task-based resource scheduling method, electronic equipment and computer readable medium
CN120371484A
Task processing method and system, electronic equipment, medium and product
CN120386607A
Scheduling instance generation method and device, scheduling degradation method and device, equipment and medium
CN120523579A
Operation request execution method, transaction operation system and computing device
CN120596232A
Method of operating request execution and transaction operation system, computing device
CN120596232B
