A task scheduling method, system, device and medium for a multi-level feedback queue

By adopting fixed priority and priority aging channels in the multi-level feedback queue scheduling algorithm, the problem of task scheduling complexity and low priority task hunger in the existing technology is solved, and the efficient task scheduling and the rational utilization of computing resources are achieved.

CN119179558BActive Publication Date: 2025-08-01THREE GORGES JINSHAJIANG CHUANYUN HYDROPOWER DEV CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411106959.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-13
Publication Date
2025-08-01
Estimated Expiration
2044-08-13

AI Technical Summary

Technical Problem

The existing multi-level feedback queue scheduling algorithm is complex in CPU task scheduling, resulting in increased system task load, and low-priority tasks are easily hungry due to high-priority tasks occupying resources, and low computing resource utilization rate.

Method used

Fixed priority strategy and priority aging channel are adopted, fixed priority queues are assigned according to task attribute parameters, and aging channels are designed between queues, and queue size and priority are dynamically adjusted to avoid frequent task switching and low-priority task hunger.

Benefits of technology

Improves the behavior predictability of tasks, reduces unnecessary context switching, avoids performance degradation, and improves the utilization rate of computing resources and system efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119179558B_ABST
    Figure CN119179558B_ABST
Patent Text Reader

Abstract

The present invention discloses a task scheduling method, system, device and medium for a multi-level feedback queue. The method includes: allocating each task to a queue corresponding to a priority according to different attribute parameters of each task to be executed in the CPU; designing a priority aging channel between different queues and allocating a corresponding global variable to each queue; determining a queue to be adjusted in a starvation state based on each global variable and the time point when the CPU executes the current queue; when the continuous starvation time of the queue to be adjusted exceeds a preset starvation threshold, adjusting the task 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 to obtain an adjusted second queue priority; and performing task scheduling according to the task execution sequence corresponding to the second queue priority. The method provided by the embodiments of the present invention can effectively improve the utilization rate of computing resources and reduce resource waste.
Need to check novelty before this filing date? Find Prior Art

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. It was initially used in the process scheduling of the CPU and later also used in the task scheduling of computing centers. This algorithm can dynamically adjust the priority of a 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 relatively fairly share CPU resources.

[0003] The existing multi-level feedback queue scheduling algorithm has a relatively low task scheduling efficiency and a complex design, resulting in an increase in 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, improve the flexibility of task priorities, and thus reduce the system task load in the CPU process has become a technical problem that needs to be urgently solved by those skilled in the art. 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 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] 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, allocate each of the tasks to a corresponding queue and determine a corresponding first queue priority;

[0008] Design a priority aging channel between different queues and allocate a corresponding global variable to each queue, where the global variable reflects the time point when the task scheduling was last executed for the current queue;

[0009] Based on each global variable and the time point when the CPU executes the current queue, determine a queue to be adjusted that is in a starvation state;

[0010] When the starvation time of the queue to be adjusted continues to exceed a preset starvation threshold, based on the corresponding priority aging channel and the first queue priority, adjust the task to be adjusted in the queue to be adjusted to the upper-level queue to obtain the adjusted second queue priority;

[0011] Perform task scheduling according to the task execution sequence corresponding to the second queue priority.

[0012] Further, the step 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] Allocate different queues according to the resource consumption, execution time, and execution urgency of each task to be executed; each queue reflects a different priority.

[0014] Further, it further includes:

[0015] Dynamically adjust the size of each queue according to the resource occupancy of the task and the historical task scheduling record.

[0016] Further, the step of designing a priority aging channel between different queues includes:

[0017] Set the threshold ratio of the starvation time between the queues according to the priority order of the first queue priority to obtain the starvation threshold of each queue;

[0018] Set the width ratio of the aging channel between the queues according to the number of tasks in each queue to obtain the aging channel width of each queue;

[0019] Construct a priority aging channel between different queues according to the starvation threshold and the aging channel width.

[0020] Further, the step of determining the queue to be adjusted in the starvation state based on each global variable and the time point when the CPU executes the current queue includes:

[0021] Obtain the first time point when the current queue last performed task scheduling recorded by each global variable and the second time point when the CPU executes the current queue;

[0022] Compare the time difference between the first time point and the second time point to judge the starvation state of the current queue, and obtain the queue to be adjusted in the starvation state.

[0023] Further, the step of performing task scheduling according to the task execution sequence corresponding to the second queue priority includes:

[0024] Determine the space status of the target priority queue corresponding to the second queue priority being executed;

[0025] When the space status task is not full, determine the task execution status of the task pool;

[0026] When there is a task to be executed in the task pool, fill the task to be executed into the target priority queue.

[0027] Furthermore, it further includes:

[0028] Divide each queue of the second queue priority into a first queue and a second queue;

[0029] The first queue receives the task to be executed filled from the task pool, and the second queue receives the task to be adjusted adjusted from the queue to be adjusted.

[0030] Another embodiment of the present invention provides a task scheduling system for a multi-level feedback queue, including:

[0031] A preprocessing module, configured to allocate each of the tasks 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;

[0032] A priority aging channel construction module, configured to design a priority aging channel between different queues, and allocate a corresponding global variable to each queue, where the global variable reflects the time point when the task scheduling was last executed for the current queue;

[0033] A comparison module, configured to determine the queue to be adjusted in a starvation state based on each of the global variables and the time point when the CPU executes the current queue;

[0034] A priority update module, configured to, when the continuous 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, adjust the task to be adjusted in the queue to be adjusted to the upper-level queue to obtain an adjusted second queue priority;

[0035] A task scheduling module, configured to perform task scheduling according to the task execution sequence corresponding to the second queue priority.

[0036] Another embodiment of the present invention provides a computer device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the task scheduling method of the multi-level feedback queue as described above.

[0037] Another embodiment of the present invention provides a computer-readable storage medium storing a computer program. When the 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 beneficial effects of the embodiments of the present invention are at least one of the following:

[0039] (1) By using the fixed priority technology, the predictability of the behavior of tasks to be run is improved. For processes that need to respond quickly, by increasing their priority, it is ensured that they can be responded to within the shortest time. In addition, by reasonably setting the queue time slice and the priority of tasks, unnecessary context switches are reduced, especially in high-load situations, avoiding performance degradation caused by frequent switching.

[0040] (2) By using the priority aging technology and the elastic queue container, by dynamically setting the aging time threshold and the size of the elastic queue container, it is ensured that processes of various types can obtain reasonable CPU time. Especially for long-running jobs and I / O-intensive jobs, the occurrence of starvation is avoided, and the utilization rate of computing resources is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 is a flowchart of the task scheduling method of the multi-level feedback queue in one embodiment of the present invention;

[0042] Figure 2 is an architecture diagram of the task scheduling system in one embodiment of the present invention;

[0043] Figure 3 is a schematic diagram of the task priority update process in one embodiment of the present invention;

[0044] Figure 4 is a general flowchart of the task scheduling in one embodiment of the present invention;

[0045] Figure 5 is a block diagram of the task scheduling system of the multi-level feedback queue in one embodiment of the present invention;

[0046] Figure 6 is a block diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0047] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all 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 those of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present invention.

[0048] In the description of this application, the terms "first", "second", "third", etc. are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first", "second", "third", etc. may explicitly or implicitly include one or more of such features. In the description of this application, unless otherwise stated, the meaning of "a plurality" is two or more.

[0049] In the description of this application, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected" should be understood in a broad sense. For example, it may be a fixed connection, a detachable connection, or an integral connection; it may be a mechanical connection or an electrical connection; it may be directly connected, or indirectly connected through an intermediate medium, and it may be the communication inside two elements. The terms "vertical", "horizontal", "left", "right", "up", "down" and similar expressions used herein are only for the purpose of illustration, 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 thus cannot be understood as a limitation to the present invention. The term "and / or" used herein includes any and all combinations of one or more of the 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 commonly understood by those of ordinary skill in the technical field to which this invention belongs. The terms used in the description 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 according to specific circumstances.

[0051] Aiming at the problems that the existing multi-level feedback queue task scheduling algorithm has high design difficulty in the system construction process and will increase the system load when tasks migrate between multiple queues, an embodiment of the present invention provides a method. Specifically, please refer to Figure 1 , Figure 1The flowchart of the task scheduling method for the multi-level feedback queue in one embodiment of the present invention is shown, including the following steps:

[0052] S1. According to the different attribute parameters of each task to be executed in the CPU, allocate each of the tasks to the corresponding queue, and determine the corresponding first queue priority.

[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 of the queues reflects different priorities.

[0054] In the traditional multi-level feedback queue scheduling algorithm during task scheduling, the scheduled priority queue is determined by the time slice it requires. For example: when a certain task requires a longer time slice, the task starts execution from the highest priority queue, and when the queue time slice is completed, it is continuously scheduled to the lower-priority queues until the task is finally completed. When the above scheduling occurs, a task switches between different priority queues multiple times, resulting in waste of system resources in context switching and reduction of computing efficiency.

[0055] In the task scheduling of the CPU in this embodiment, the fixed priority policy adopted 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 places them in the queues with corresponding priorities. Here, the first queue priority means that tasks with different attributes are assigned to queues with different priorities, that is, each priority from high to low. In the fixed priority policy of the embodiment of the present invention, tasks will only be assigned to the queues with corresponding priorities. Compared with the traditional scheduling algorithm, this fixed priority policy 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 The architecture diagram of the task scheduling system in one embodiment of the present invention is shown.

[0057] From Figure 2It can be seen that in this embodiment, the classic structure of the multi-level feedback queue is still selected, that is, multiple queues with different priorities, and the processes in each queue have different priorities and time slice sizes. The high-priority queue has a shorter time slice, and the low-priority queue has a longer time slice. By adopting the fixed priority strategy, the entire scheduling process becomes efficient. It can be understood 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 priorities, the fixed priority strategy simplifies the scheduling algorithm and reduces the complexity of scheduling. In addition, in some cases, dynamically adjusting priorities may cause the problem of priority inversion, that is, low-priority tasks are blocked because they are waiting for resources occupied by high-priority tasks, resulting in high-priority tasks not being able to execute in time. The fixed priority strategy can effectively avoid such problems by predefining priorities.

[0058] Preferably, in the 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 ratio of the time slice sizes from high to low priority of the queue is 1:8:16:64:128.

[0059] Furthermore, according to the resource occupancy of the task and the historical task scheduling record, the size of each queue is dynamically adjusted.

[0060] Specifically, the system will dynamically adjust the size of each priority queue according to the current resource occupancy, including computing resources such as CPU and GPU, and storage resources such as memory and hard disk, as well as the historical task execution record. This step ensures that the system can optimize the efficiency of task scheduling according to the actual workload and resource status.

[0061] S2. Design a priority aging channel between different queues, and allocate a corresponding global variable to each queue, and the global variable reflects the time point when the previous task scheduling was performed for the current queue.

[0062] When using the traditional multi-level feedback queue algorithm for task scheduling, the following situation will occur: when high-priority tasks continuously enter the scheduling queue, low-priority tasks may be "starved to death" due to the continuous occupation of computing resources by high-priority tasks. Based on this, the embodiment of the present invention designs a priority aging channel between each priority queue. When the time that the low-priority queue cannot obtain CPU computing resources exceeds the set starvation time threshold of this queue, one or more tasks of this queue will be transferred to the 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 priority, set the threshold ratio of the starvation time between the queues to obtain the starvation threshold for each queue. According to the number of tasks in each queue, set the width ratio of the aging channel between the queues to obtain the width of the aging channel for each queue.

[0065] In this embodiment, this threshold ratio of the starvation time is used to determine how long each queue is considered to be in a starvation state after not obtaining CPU resources.

[0066] Preferably, since low-priority tasks often have characteristics such as time insensitivity, large load, and long calculation time, to prevent them from occupying the execution of the original tasks with higher priority when transferring to a higher-priority queue, in the embodiment of the present invention, the queue time threshold ratio is set as 1:10:100:1000:10000 in the priority order, and the ratio of the width of the aging channel (in units of the number of tasks) is set as 1:2:4:8:16, which reflects the rate or capacity of moving tasks from one queue to another queue (usually a queue with lower priority).

[0067] Finally, construct a priority aging channel between different queues according to the starvation threshold and the width of the aging channel.

[0068] Construct a priority aging channel between different queues according to the previously set starvation threshold and the width of the aging channel. These channels allow the queues to move tasks in the queue from one queue to another when specific conditions are met (such as reaching the starvation threshold), so as to avoid starvation and optimize the overall performance of the system.

[0069] Furthermore, in this embodiment, the prerequisite for detecting whether a queue is "starved" is to allocate a global variable (last_work_time) for each queue. In the scheduling system, the global variable of each priority queue is used to record the time point when the last task was executed and obtained CPU resources in the queue. 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 thus take corresponding adjustment measures.

[0070] S3. Based on each of the global variables and the time point when the CPU executes the current queue, determine the queue to be adjusted that is in a starvation state.

[0071] Specifically, obtain the first time point when the previous task scheduling was performed on the current queue recorded by each global variable and the second time point when the CPU executes the current queue; compare the time difference between the first time point and the second time point, and judge the starvation state of the current queue to obtain the queue to be adjusted in the starvation state.

[0072] In this embodiment, this first time point is usually updated when a certain task in the queue is selected by the scheduler and removed from the queue for execution 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 judge whether the queue is in a starvation state by comparing the first time point recorded by the global variable and the second time point of the current moment.

[0073] When it is judged that the queue is in starvation, the queue to be adjusted in the starvation state is obtained. Next, it is necessary to update the task priorities of these queues to solve the "starvation" problem.

[0074] S4. When the continuous starvation time of the queue to be adjusted exceeds the preset starvation threshold, based on the corresponding priority aging channel and the first queue priority, adjust the tasks to be adjusted in the queue to be adjusted to the upper-level queue to obtain the adjusted second queue priority.

[0075] Specifically, when the queue is already starved, the scheduler will pop up multiple previous tasks in the queue through the priority aging channel and fill them into the queue at the upper level of this queue. This process is carried out from bottom to top, that is, the tasks in the lowest priority queue will be popped up first, and the tasks in the highest priority queue will be popped up last.

[0076] Preferably, the second queue priority obtained at this time is the priority of the queue that solves the problem that the tasks in the low-priority queue are "starved" due to the continuous occupation of computing resources by the tasks in the high-priority queue. This process greatly improves the utilization rate of computing resources. For the specific process of task priority update, please refer to Figure 3 , Figure 3 which shows the schematic diagram of the task priority update process 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 up in the "starved" queue and filled into the queue at the next higher priority level of this queue. In this way, the tasks will be scheduled preferentially, thus avoiding being "starved".

[0078] S5. Perform task scheduling according to the task execution sequence corresponding to the second queue priority.

[0079] After the above adjustments, the upper-level 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 upper-level queue now becomes the new queue with updated priorities, and the system schedules tasks at this moment according to the task execution sequence corresponding to the second queue priority. Additionally, the system should continue to monitor the status of all queues, including starvation time, the number of tasks, etc., for further adjustments if necessary. If it is found that other queues also reach the starvation threshold, the above process can be repeated to adjust tasks to higher-level queues.

[0080] Furthermore, in this embodiment, the queue needs to be checked. Please refer to Figure 4 , Figure 4 which shows the overall flowchart of task scheduling in one embodiment of the present invention. Specifically:

[0081] First, determine the space status of the target priority queue corresponding to the second queue priority being executed;

[0082] The space status here refers to whether the task volume of each queue at this time has filled the queue. Since the entire scheduling process is dynamic, there will be idle positions in the queue when tasks are popped or adjusted.

[0083] Then, when the space status indicates that the tasks are not full, determine the task execution status of the task pool; when there are tasks to be executed in the task pool, fill the tasks to be executed into the target priority queue.

[0084] The task pool is a container in the scheduling system that stores tasks to be executed. When there are tasks waiting to be executed in the task pool and the space status of the target task queue being executed is not full at this time, the scheduler will take tasks from the task pool and fill them into this queue with "idle positions". This process ensures that the task queue always remains active and avoids waste of resources.

[0085] Furthermore, for the above process of priority update and task filling in the task pool, this embodiment sets up an elastic queue container, which is designed to specifically adapt to the priority aging channel and the entire scheduling process.

[0086] Specifically, in this embodiment, each queue with the second queue priority is divided 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, in the embodiments of the present invention, these queues with different priorities are divided into two types: elastic queues and rigid queues. In this embodiment, it can be understood that the above-mentioned first queue is a rigid queue, and the second queue is an elastic queue. The length of the rigid queue is fixed and filled with tasks from the task pool; the length of the elastic queue can be adjusted according to the current load of the system and the execution status of historical tasks, and is filled with 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 Serve principle. In the default settings of the embodiments of the present invention, the capacity ratios of the elastic queues and the rigid queues of each level of queues are the same: both are set to 1:10.

[0089] The existence of the elastic queue avoids the influence of low-priority tasks on the execution efficiency of originally high-priority tasks after promoting their own priorities through the aging channel; in addition, before each scheduling, the scheduler can adjust the elastic queue capacity of different priority queues in real time according to the resource utilization situation and load status of the current system, which further improves the control sensitivity of the scheduling algorithm to different types of tasks. Specifically, the specific structures of the rigid queue and the elastic queue can be referred to Figure 2 as shown.

[0090] When performing task scheduling, the embodiments of the present invention also take targeted measures to avoid the low efficiency 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 will select and execute the default idle task (idle_task) of the system to maintain the stable operation of the system. If there are non-empty queues, the system will select the first task from the non-empty queue with the current highest priority for execution. It can be understood that through the above measures, this embodiment can ensure the priority processing of urgent and important tasks and improve the operation efficiency of the system.

[0091] The embodiments of the present invention also conducted simulation experiments. In the simulation experiments of the simulator, the scheduling algorithm proposed by the embodiments of the present invention reduces the average turnaround time of tasks by 3.2%, reduces the average waiting time by 4.1%, and increases the system task throughput by 7.1%; the efficiency of the computing center is increased by about 6.1%, and the energy consumption is reduced by about 3.7%.

[0092] In summary, the task scheduling method for a multi-level feedback queue proposed in the embodiment of the present invention adopts a fixed priority strategy, which enables tasks to be targeted to be assigned to appropriate priority queues, reduces the number of unnecessary context switches of system resources, and also avoids the problems of resource waste and low computing efficiency generated during 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. By dynamically setting the aging time threshold and the size of the elastic queue container, it is ensured that various types of processes can obtain 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 scheduling efficiency, and significantly improve the utilization rate of computing resources.

[0093] An embodiment of the present invention provides a task scheduling system for a multi-level feedback queue. Specifically, please refer to Figure 5 , Figure 5 which is shown as the structural block diagram of the task scheduling system for the multi-level feedback queue in one embodiment of the present invention, including:

[0094] A preprocessing module M1, configured to assign each of the tasks 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] A priority aging channel construction module M2, configured to design a priority aging channel between different queues and assign a corresponding global variable to each queue, where the global variable reflects the time point when the current queue last performed task scheduling;

[0096] A comparison module M3, configured to determine a queue to be adjusted in a starvation state based on each global variable and the time point when the CPU executes the current queue;

[0097] A priority update module M4, configured to, 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, adjust the task to be adjusted in the queue to be adjusted to the upper-level queue to obtain an adjusted second queue priority;

[0098] A task scheduling module M5, configured to perform task scheduling according to the task execution sequence corresponding to the second queue priority.

[0099] As Figure 6 shown, an embodiment of the present invention also provides a computer device, Figure 6A structural block diagram of a preferred embodiment of a computer device provided by the present invention. The computer device includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the task scheduling method of a multi-level feedback queue as described above.

[0100] Preferably, the computer program can be divided into one or more modules / units (such as computer program 1, computer program 2,...). 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 capable of performing specific functions, and these instruction segments are used to describe the execution process of the computer program in the computer device.

[0101] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor, or the processor can also be any conventional processor. The processor is the control center of the terminal device and connects various parts of the terminal device through various interfaces and circuits.

[0102] The memory mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function, etc., and the data storage area can store relevant 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, SmartMedia Card (SMC), Secure Digital (SD) 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 can understand that Figure 6The structural block diagram is only an example of the terminal device and does not constitute a limitation on the terminal device. It may include more or fewer components than those shown, or combine certain components, or different components. Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing 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 methods. Among them, the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.

[0104] Correspondingly, an embodiment of the present invention provides a computer-readable storage medium. The computer-readable storage medium includes a stored computer program. When the computer program runs, it controls the device where the computer-readable storage medium is located to execute the steps of the task scheduling method of the multi-level feedback queue in the above embodiment, for example Figure 1 the steps S1 to S5 described therein.

[0105] The above embodiments only represent several implementation manners of the present invention. The description is relatively specific and detailed, but it should not be construed as a limitation on the scope of the patent of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present invention, several modifications and improvements can still be made, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention should be subject to the appended claims.

Claims

1. A task scheduling method for a multi-level feedback queue, characterized in that, include: 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; Priority aging channels are designed between different queues, and a corresponding global variable is assigned to each queue, where the global variable reflects the time point when the current queue last executed task scheduling. Specifically, 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 for each queue; according to the number of tasks in each queue, a width ratio of the aging channels between the queues is set to obtain an aging channel width for each queue; and priority aging channels are constructed between different queues according to the starvation threshold and the aging channel width. Based on each of the global variables and the time point when the CPU executes the current queue, a queue to be adjusted that is in a starving state is determined; specifically, the first time point when the current queue last executed task scheduling, as recorded by each of the global variables, and the second time point when the CPU executes the current queue are obtained; the time difference between the first time point and the second time point is compared to determine the starvation state of the current queue, thereby obtaining a queue to be adjusted that is in a starving state; 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 according to 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 scheduling of tasks according to the task execution sequence corresponding to the second queue priority includes: Determining a space status of a target priority queue corresponding to the executed second queue priority; 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.

5. The task scheduling method of the multi-level feedback queue according to claim 4, wherein 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.

6. A task scheduling system with a multi-level feedback queue, characterized in that, include: A pre-processing module, configured 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; Priority aging channel construction module, which is used to design a priority aging channel between different queues and allocate corresponding global variables to each queue. The global variable reflects the time point when the current queue last executed task scheduling. Specifically: according to the priority order of the first queue priority, set the threshold ratio of the starvation time between the queues to obtain the starvation threshold of each queue; according to the number of tasks in each queue, set the width ratio of the aging channel between the queues to obtain the aging channel width of each queue; construct a priority aging channel between different queues according to the starvation threshold and the aging channel width; Comparison module, which is used to determine the queue to be adjusted in the starvation state based on each global variable and the time point when the CPU executes the current queue. Specifically: obtain the first time point when the current queue last executed task scheduling recorded by each global variable and the second time point when the CPU executes the current queue; compare the time difference between the first time point and the second time point to judge the starvation state of the current queue, and obtain the queue to be adjusted in the starvation state; Priority update module, which is used to, when the continuous starvation time of the queue to be adjusted exceeds the preset starvation threshold, based on the corresponding priority aging channel and the first queue priority, adjust the task to be adjusted in the queue to be adjusted to the upper-level queue to obtain the adjusted second queue priority; Task scheduling module, which is used to schedule tasks according to the task execution sequence corresponding to the second queue priority.

7. A computer device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the task scheduling method of the multi-level feedback queue according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program. When the device where the computer-readable storage medium is located executes the computer program, it implements the task scheduling method of the multi-level feedback queue according to any one of claims 1 to 5.

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