Task scheduling method, computer equipment and scheduling module

By introducing a token ring mechanism into the data center network card, dynamically manage the tokens of active queues and only scheduling queues to be scheduled, solving the problems of low task scheduling efficiency and waste of bandwidth, achieving more efficient task scheduling and performance improvement.

CN120469779APending Publication Date: 2025-08-12深圳市恒扬数据股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510576747.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-06
Publication Date
2025-08-12

AI Technical Summary

Technical Problem

In the prior art, the task scheduling efficiency of the data center network card is low and bandwidth waste is severe. The reason is that all queues supported by the hardware are scheduling and polling, resulting in inactive queues also participating in scheduling, which reduces efficiency.

Method used

The token ring mechanism is adopted, and the token is placed in the token ring of the corresponding priority when the queue is assigned the first task. The tokens of the active queue are dynamically managed, and only queues to which tasks are to be scheduled are scheduled, and the scheduling time is dynamically calculated based on the number of current valid queues.

Benefits of technology

Improve task scheduling efficiency, reduce the number of tokens in the token ring, improve performance and bandwidth utilization, reduce scheduling overhead, and adapt to dynamically changing resource environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120469779A_ABST
    Figure CN120469779A_ABST
Patent Text Reader

Abstract

The invention provides a task scheduling method, computer equipment and a scheduling module, and by adopting the method, when a first task is allocated to an activation queue, tokens of the queue are put into token rings of corresponding priorities according to the priorities of the queue. And when the token ring of any priority is non-empty, determining a target token ring of a target priority to be scheduled. And determining a to-be-scheduled target queue according to the target token ring. And calling a scheduling processing module to process the task of the target queue, and deleting the token of the target queue in the target token ring after the task of the target queue is scheduled. In this way, only the tokens of the active queues of the tasks to be scheduled exist in the token ring, and therefore only the active queues with the tasks to be scheduled need to be scheduled. The method can improve scheduling efficiency and performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to computer technology and cloud computing technology, and in particular to a task scheduling method, computer equipment, and scheduling module. Background Art

[0002] With the continuous development of cloud computing and server cluster technologies, the scale and complexity of computing resources have increased significantly, and task scheduling has become increasingly important in resource management. Task scheduling not only directly impacts the resource utilization and task response time of cloud computing platforms, but also impacts user experience and the operating costs of cloud service providers. Therefore, improving task scheduling efficiency to better adapt to dynamically changing resource environments and diverse task requirements has become a key issue that needs to be addressed in the cloud computing field.

[0003] Taking the data center network card as an example, by optimizing traffic distribution and scheduling strategies, it can reduce network congestion, reduce latency, and improve the network's effective bandwidth and forwarding delay stability. Currently, the network cards used in most data centers are standard network cards purchased from hardware manufacturers. The current implementation methods of multi-queue network cards that support multi-user functions in data centers are as follows: Figure 1 As shown in the figure, the SmartNIC hardware schedules all work queues simultaneously. However, in real-world applications, when multiple users use multiple queues, service traffic is uneven. Some queues may be active for extended periods but not always have traffic. Software-enabled queues are all included in queue scheduling, regardless of whether they are currently running services. This reduces scheduling efficiency.

[0004] For example, if the hardware supports 1000 queues, all queues on the hardware are scheduled in a round-robin fashion. Hardware queue scheduling determines whether a queue is empty and schedules the next one. If only one queue is enabled, the other 999 queues will take 1 to 2 clock cycles to determine if they are empty. While this allows for quick skipping, it still incurs bandwidth overhead. This type of scheduling requires all queues supported by the hardware to be included in the schedule.

[0005] Therefore, this method has the problems of low efficiency and bandwidth waste. Summary of the Invention

[0006] To solve existing technical problems, the present application provides a task scheduling method, computer equipment and scheduling module that can improve scheduling efficiency.

[0007] In a first aspect, a task scheduling method is provided, the method comprising:

[0008] When the activation queue is assigned the first task, the token of the queue is placed into the token ring of the corresponding priority according to the priority of the queue;

[0009] When the token ring of any priority is non-empty, determine the target token ring of the target priority to be scheduled;

[0010] Determining a target queue to be scheduled according to the target token ring;

[0011] The scheduling processing module is called to process the tasks of the target queue, and after the tasks of the target queue are scheduled, the token of the target queue is deleted from the target token ring.

[0012] In a second aspect, a computer device for implementing task scheduling is provided, comprising:

[0013] A processor and a memory connected to the processor, wherein the memory stores a computer program that can be executed by the processor, and when the computer program is executed by the processor, the steps of the task scheduling method of each embodiment described above are implemented.

[0014] In a third aspect, a scheduling module is provided, including:

[0015] Multiple token rings, corresponding to queues of different priorities, are used to put tokens into the corresponding priority queues;

[0016] The task list of each queue is used to record the processing order of tasks in each queue;

[0017] The status table of each queue is used to record the attribute information of each queue;

[0018] Scheduling timer, used to manage the scheduling time of each queue;

[0019] Scheduling processing module, used for scheduling processing tasks;

[0020] The token state scheduler is used to implement the steps of the task scheduling method described in the above embodiments.

[0021] In the above-described task scheduling method, when the first task is assigned to an active queue, the queue's token is placed into a token ring of the corresponding priority based on the queue's priority. When the token ring of any priority is not empty, a target token ring of the target priority to be scheduled is determined. Based on the target token ring, the target queue to be scheduled is determined. A scheduling processing module is called to process the target queue's tasks, and after the target queue's tasks are scheduled, the target queue's token is deleted from the target token ring. This ensures that only the tokens of the active queues with tasks to be scheduled remain in the token ring, requiring scheduling only for the active queues with tasks to be scheduled. This method can improve scheduling efficiency and performance.

[0022] The computer device and scheduling module for implementing task scheduling provided in the above embodiments belong to the same concept as the corresponding task scheduling method embodiments, and thus have the same technical effects as the corresponding task scheduling method embodiments, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 Schematic diagram of the system architecture of the scheduling module in the prior art.

[0024] Figure 2 Schematic diagram of the system architecture of the scheduling module of an embodiment of the present application.

[0025] Figure 3 Schematic diagram of the task scheduling method according to an embodiment of the present application.

[0026] Figure 4 This is a flowchart of the steps of calling the scheduling processing module to process tasks in the target queue according to an embodiment of the present application.

[0027] Figure 5 A schematic diagram of the task allocation process of an embodiment of the present application.

[0028] Figure 6 This is a schematic diagram of the state changes of the token scheduling state machine in an embodiment of the present application. DETAILED DESCRIPTION

[0029] The technical solution of the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0030] In order to make the purpose, technical solutions and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limiting this application. All other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0031] In the following description, the expression "some embodiments" is involved, which describes a subset of all possible embodiments. It should be noted that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict.

[0032] In the following description, the terms "first, second, and third" are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It is understandable that "first, second, and third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0033] This application provides a task scheduling method that can improve the efficiency of task scheduling in task scheduling scenarios. This method can be used in different task scheduling scenarios, such as multi-tasking scenarios in distributed computing systems, for example, multi-tasking scenarios in data centers, or multi-tasking scenarios for clustered server task access.

[0034] From a device perspective, the task scheduling method is implemented using a computer device for implementing task scheduling. Specifically, the computer device includes a processor and a memory. The memory stores a computer program executable by the processor. When the computer program is executed by the processor, the steps of the task scheduling method of the present application are implemented. The computer device corresponds to different hardware devices in different application scenarios. For example, in a data center, the computer device is a smart network card.

[0035] From the perspective of system architecture, this method implements task scheduling by providing a scheduling module at the bottom layer and the business layer calling the interface or service provided by the scheduling module.

[0036] The business layer refers to the portion of the system that directly addresses user needs and business logic, primarily responsible for handling business-related operations and functions. The bottom layer provides basic functions and infrastructure, primarily responsible for implementing specific hardware operations, system resource management, and communication protocols. Understandably, the bottom layer's scheduling module relies on the hardware resources of the computer device.

[0037] In one embodiment, a scheduling module has a structure as follows: Figure 2 As shown, including:

[0038] Queue state table: A RAM table that stores queue attribute information. The RAM address is the queue ID or ID mapping, and its depth is generally the total number of queues supported by the computer device (such as a network card). The contents of the RAM are used to store the attribute information of each queue, as shown in Table 1. The attribute information of the queue state table includes but is not limited to the following:

[0039] Table 1 Queue status table

[0040]

[0041]

[0042] As you can see, the queue status table records the index of the head task of the queue, ensuring that the first task of the queue can be found, and records the index of the tail task of the queue, ensuring that the last task can be found.

[0043] The queue's task list is the random access memory (RAM) that stores each task in the queue. All queues share this RAM, which can better utilize RAM resources and enable queues to share the queue's task list RAM. This RAM has as many linked lists as there are queues.

[0044] As shown in Table 2, the task list of each queue contains at least the following two parts:

[0045] Table 2 Queue task list

[0046]

[0047] Multiple token rings correspond to queues of different priorities and are used to store tokens from the corresponding priority queues. In one embodiment, the token ring is composed of FIFO resources. The number of FIFOs required is determined by the number of priority levels, typically 4 to 8, depending on business needs. The FIFOs in the token ring store the ID of the queue QP. The scheduling algorithm reads the contents of the FIFO, indicating which queue's task currently needs to be scheduled for transmission. After a task is sent, if there are still tasks in the queue, the token is written back to the FIFO. This token is then placed at the end of the token ring for that priority level. If the task is the last task in the queue when transmission is complete, the token is not written back, thus completing the dynamic deletion of the token.

[0048] The token scheduling state machine is used to implement the task scheduling method of this application.

[0049] The scheduling timer calculates in real time the maximum time that all current queues can be scheduled, that is, the scheduling time, which is calculated based on the timeout time. The system will give a timeout time, which indicates that the time it takes for the same queue to be scheduled twice must be this time, otherwise a timeout exception will occur at the business level. In this application, the scheduling time of the target queue is determined based on the number of currently valid queues. The scheduling mechanism of this application adopts dynamic queue scheduling, and the number of real-time queues in the token ring is dynamic and is less than or equal to the number of activated queues. Each time a new token is scheduled, a new scheduling time is calculated and obtained as the scheduling time of the queue corresponding to the new token.

[0050] The scheduling processing module is used to schedule processing tasks. Specific scheduling processing depends on the needs of the business layer. For example, in the data center network card module, the scheduling processing module is used to process packet outgoing packets.

[0051] The present application provides a task scheduling method, which is implemented by a computer device or a token scheduling state machine in the above-mentioned scheduling module, such as Figure 3 As shown, the method includes:

[0052] Step 302: When the activation queue is assigned the first task, the token of the queue is placed into the token ring of the corresponding priority according to the priority of the queue.

[0053] There are a number of token rings corresponding to the number of queue priorities. For example, if there are three different queue priorities, there are three corresponding token rings.

[0054] Activating a queue means enabling it. When the first task is assigned to an activated queue, its token is placed in the token ring corresponding to the priority level, based on the queue's priority. For example, if queue 1 is the first priority and is assigned the first task, its token is placed in the token ring corresponding to the first priority level. The queue's identifier can be used as a token in the token ring.

[0055] That is, even when a queue is activated, its token will not be placed in the token ring. Only when the queue is assigned its first task, that is, when there are tasks in the queue, will the queue's token be placed in the token ring for scheduling.

[0056] Step 304: When the token ring of any priority is not empty, determine the target token ring of the target priority to be scheduled.

[0057] When a token ring of any priority is not empty, it indicates that there is a task to be scheduled. At this time, the target token ring of the target priority to be scheduled is determined. The scheduling policy used to determine the target token ring to be scheduled is not limited in this embodiment and can be flexibly set according to business needs. Specifically, the target token ring of the target priority to be scheduled is determined based on the scheduling policy of the business layer. For example, absolute priority, proportional priority scheduling, and other scheduling policies can be used.

[0058] For example, according to the scheduling policy, it is determined that the target token ring to be scheduled is the token ring of the queue with the first priority, and the token ring corresponding to the queue with the first priority is used as the target token ring.

[0059] Step 306: Determine the target queue to be scheduled according to the target token ring.

[0060] The token ring includes multiple queues with the same priority level and scheduling tasks. Based on a preset scheduling policy, the target queue to be scheduled is determined from the target token ring. In one embodiment, the token ring employs a FIFO (First-In-First-Out) structure, and the queue corresponding to the first token in the target token ring is used as the target queue to be scheduled. In one embodiment, the token ring may also employ other queue structures. Based on the scheduling policy of the service layer, the queue corresponding to the target token in the target token ring is determined as the target queue to be scheduled.

[0061] Step 308: calling the scheduling processing module to process the tasks of the target queue, and after the tasks of the target queue are scheduled, deleting the token of the target queue in the target token ring.

[0062] The scheduling module's processing method is determined by the module's application scenario and business content, and is not limited here. For example, if the scheduling module is used in a data center network card, the scheduling module's processing method is to send tasks from the target queue to different servers for processing.

[0063] After the target queue's tasks are scheduled, the target queue's token is deleted from the target token ring. This way, when the first task is assigned to the active queue, its token is written to the token ring for scheduling. Once the tasks in that queue are scheduled, its token is deleted from the token ring. This ensures that only the tokens of the active queues with tasks to be scheduled exist in the token ring.

[0064] Compared to the prior art method of adding tokens from active queues to a token ring for scheduling, the method of the present application can reduce the number of tokens in the token ring and improve token scheduling efficiency. For example, when 100 queues are enabled, the number of active queues is currently 100. The prior art method places the 100 active queues into the token ring for scheduling, meaning that the prior art method schedules only the active, valid queues.

[0065] With the method of the present application, tokens are placed in the token ring only when there are queue tasks in the queue. Tokens for activated queues that have not yet received any tasks are not placed in the token ring. Furthermore, when a queue's task scheduling is complete, its tokens are deleted from the token ring. Therefore, only tokens for active queues with tasks remain in the token ring. Although 100 queues are enabled, the number of tokens in the token ring is less than or equal to the number of activated queues. Therefore, with the method of the present application, the number of tokens in the token ring can be reduced, improving the efficiency of token scheduling and enhancing performance.

[0066] The task scheduling method of the present application, when the first task is assigned to the activated queue, places the queue's token into the token ring of the corresponding priority according to the queue's priority. When the token ring of any priority is not empty, the target token ring of the target priority to be scheduled is determined. Based on the target token ring, the target queue to be scheduled is determined. The scheduling processing module is called to process the task of the target queue, and after the task of the target queue is scheduled, the token of the target queue is deleted from the target token ring. In this way, only the tokens of the active queues with tasks to be scheduled exist in the token ring, so only the active queues with tasks to be scheduled need to be scheduled. This method can improve scheduling efficiency and performance.

[0067] In the prior art, static time constraints are often used when processing tasks of the target queue. The static time is determined according to the timeout time set by the system. The system usually sets a timeout time. For example, the timeout time is 10 milliseconds, which means that if the business layer does not receive a new message within 10 milliseconds, the business processing will time out. Then, for the underlying queue scheduling, the interval between scheduling of the same queue cannot be less than 10 milliseconds. Still taking the activation of 100 queues as an example, processing the task of the target queue with static time constraints means calculating the static time that each queue can be scheduled in advance based on the timeout time, 10ms / 100=100us, then each scheduled time must not exceed 100us, otherwise there is a possibility that the total time will exceed 10 milliseconds, resulting in business timeout.

[0068] In this embodiment, the scheduling time of the target queue is determined according to the number of currently valid queues.

[0069] The number of currently valid queues refers to the number of queues in all token rings. Therefore, the number of currently valid queues is determined based on the number of all token rings and the number of queues in each token ring.

[0070] In other words, the queue scheduling time is dynamically determined based on the number of valid queues in real time. The target queue scheduling time also changes dynamically with the number of valid queues.

[0071] Therefore, the method of the present application is that for the target queue to be scheduled, its scheduling time is calculated in real time by a computer device (such as a smart network card chip) based on the timeout time and the current number of valid queues. Since the timeout time remains unchanged, but the number of queues to be scheduled is reduced, the scheduling time allocated to each queue can be increased. For example, if the timeout time is 10 milliseconds and 100 queues are activated, but the number of currently active queues is 10, then for the target queue to be scheduled, its scheduling time is 10ms / 10=1ms. For the target queue, there is a longer scheduling time, so that more business messages can be sent within the scheduling time without timeout. If the number of active queues changes in real time, the new dynamic scheduling time can be calculated at any time to fully utilize the scheduling performance and bandwidth without business timeout, thereby improving the scheduling efficiency and task scheduling performance of each queue.

[0072] Furthermore, due to the dynamic changes in scheduling time, the scheduling interval of the queue also changes dynamically. The dynamic interval refers to the time interval between the next scheduled requests for the same queue. This enables dynamic adjustment of the queue scheduling interval, providing higher scheduling performance and bandwidth.

[0073] Specifically, the steps of calling the scheduling processing module to process the tasks of the target queue are as follows: Figure 4As shown, including:

[0074] Step 402: read the status table of the target queue to obtain the target task currently to be scheduled.

[0075] The queue status table, shown in Table 1, stores various queue attributes. Read the target queue's status table to obtain the current task to be executed. Typically, the current task to be executed is the first task recorded in the queue status table. Using Table 1 as an example, by obtaining the address index of the first task based on the qp wqe head index field, the current target task to be scheduled can be obtained.

[0076] Step 404: According to the current target task to be scheduled, obtain the next task to be scheduled from the task list of the target queue.

[0077] Table 2 shows the target queue's task list, which records the order in which tasks are scheduled, based on the order in which they are assigned to the queue. Using the currently scheduled target task, the next task to be scheduled can be retrieved from the corresponding queue's task list. For example, if the target queue's task list records Task 1 - Task 3 - Task 5, and the target task currently being scheduled is Task 3, then the next task to be scheduled can be determined from the queue's task list to be Task 5.

[0078] Step 406: Call the scheduling processing module to process the target task.

[0079] According to the processing rules of the actual application scenario of the scheduling processing module, the target task is scheduled. Taking the scheduling module applied to a data center as an example, the target task is sent and scheduled to a target processing server.

[0080] After step 406 , step 408 is executed.

[0081] Step 408: Determine whether the tasks in the queue have been scheduled. If not, execute step 410; if so, execute step 409.

[0082] Step 410: Determine whether the scheduled time has arrived. If not, proceed to step 412. If yes, proceed to step 411.

[0083] In step 412, the next task to be scheduled is used as the target task to be scheduled. After step 412, the process returns to step 404 to process the next task until the task scheduling of the target queue is completed or the scheduling time is reached.

[0084] When it is determined in step 408 that the task in the queue has been completed, step 409 is executed to delete the token of the target queue in the target token ring and modify the target queue to a no-task state in the state table of the target queue.

[0085] Specifically, when a task in a queue is completed, the target queue's token is deleted from the target token ring. This ensures that only the tokens of queues with pending tasks remain in the token ring. This reduces the number of tokens in real time to significantly less than the number of enabled queues, effectively improving queue scheduling efficiency. Furthermore, the target queue's status table is modified to a task-free state, accurately recording the queue's real-time status.

[0086] When it is determined in step 410 that the scheduling time has arrived, step 411 is executed to write the token of the target queue back to the end of the token ring and to maintain the target queue in a task-having state in the state table of the target queue.

[0087] When the scheduling time is reached, it indicates that there are still tasks to be scheduled in the target queue. At this time, the token of the target queue is written back to the tail of the token ring. At the same time, in the status table of the target queue, the target queue is maintained in a task state to accurately record the actual state of the target queue while allowing the queue's token to continue to be scheduled and processed in the token ring.

[0088] Among them, after step 411 and step 409, continue to judge whether the token ring of any priority is empty. If not, determine the target token ring of the target priority to be scheduled according to the scheduling policy of the business layer to continuously schedule the queues in the token ring.

[0089] In the above-mentioned step of calling the scheduling processing module to process the tasks of the target queue, the token state scheduler sequentially calls the scheduling processing module to process the target tasks by combining the queue's state table and task chain list. When the tasks in the queue are processed, the target queue's token is deleted from the target token ring and the target queue is modified to a no-task state in the target queue's state table. Alternatively, when the scheduling time arrives, the target queue's token is written back to the end of the token ring and the target queue is maintained in a task-loaded state in the target queue's state table. Thus, on the one hand, the queue's state table and chain list, combined with the token scheduler, can be used to schedule the tasks in the queue. On the other hand, different strategies are adopted to record the completion status of the tasks in the queue in the state table to ensure the accuracy of the queue status record.

[0090] After the tasks of the target queue are scheduled, the token of the target queue is deleted from the target token ring, which includes: obtaining the scheduling completion result of the target task and updating the scheduling completion result of the target task to the state table of the target queue. When the scheduling completion result of the tail task of the target queue is received, it indicates that the task scheduling of the target queue is completed, and the token of the target queue is deleted from the target token ring.

[0091] The scheduling completion result refers to the feedback received from the module / server that executes the target task after the scheduling processing module processes the target task. Taking the data center network card application scenario, the processing of the scheduling processing module is the sending processing as an example. After the sending module sends the task to the target server, the target server will send a response message to the token state scheduler after receiving the task, indicating that the task has been successfully received. For the token state scheduler, the target task has been scheduled. The response information includes the task identifier or address index information. Based on the response information, the token state scheduler updates the scheduling completion field in the state table, such as the qp wqe send index field shown in Table 1, which is used to record the index of the address of the task that has been scheduled. For example, when the response information of task 3 is received, the address index of task 3 is updated in the qp wqe send index field in Table 1, which means that task 3 has been successfully scheduled.

[0092] When the scheduling completion result of the tail task of the target queue is received, it indicates that the task scheduling of the target queue is completed, the token of the target queue is deleted from the target token ring, and the target queue is modified to a no-task state in the state table of the target queue.

[0093] In this embodiment, the state table is used to record the scheduling completion result, and whether the scheduling of the target queue is completed is confirmed based on whether the scheduling completion result of the tail task of the queue is received, which can improve the accuracy of queue scheduling.

[0094] In one embodiment, when the first task is assigned to the activation queue, the token of the queue is placed into the token ring of the corresponding priority according to the priority of the queue, such as Figure 5 As shown, including:

[0095] Step 502: Get the task and assign an activation queue to the task.

[0096] When an application-layer task is received, it is assigned to an activation queue based on the application-layer service policy. For example, if a task has a higher priority, it can be assigned to the first-priority activation queue. As shown in Table 1, when the enable flag of a queue is valid, it indicates that the queue is enabled and is an active queue.

[0097] Step 504: Read the queue status table to determine whether the queue is in a no-task state and the task is the first task in the queue. If yes, execute step 506; if not, execute step 505.

[0098] Step 506: Update the queue to a task-filled state.

[0099] For the assigned activation queue, read its status table. If the queue is in a no-task state, the qp valid field shown in Table 1 is used for judgment. If the qp valid field is in a valid state (for example, 1), it means that the queue currently has a task. If the qp valid field is in an invalid state (for example, 0), it means that the queue currently has no task.

[0100] When the queue is in the task-free state and the task is the first task in the queue, the queue is updated to the task-fulfilled state, for example, the qp valid field in Table 1 may be set to 1.

[0101] Step 508: Update the queue head task in the queue status table according to the current task.

[0102] For the first task in the queue, update it to the relevant fields of the queue head task in the queue status table, such as qp wqe head index shown in Table 1, which is used to record the address index of the first head task in the queue.

[0103] Step 510: According to the priority of the queue, the token of the queue is placed into the token ring of the corresponding priority.

[0104] In one embodiment, the identifier of the queue may be used as a token and placed into a token ring of the corresponding priority according to the priority of the queue.

[0105] Step 512: Initialize the task list of the queue and use the current task as the first node of the task list.

[0106] For the queue that has been assigned the first task, its task list is initialized, and the current task is used as the first node of the task list. As shown in Table 2, the address index of the first task of the current queue is recorded in the task list.

[0107] Please continue reading Figure 5 If the result of step 504 is no, that is, the activation queue assigned to the task is in a valid state, indicating that the task is not the first task in the queue, step 505 is executed to update the tail task of the queue in the queue status table according to the current task.

[0108] When a new task is assigned to an existing queue, the tail task of the queue changes. Updating the tail task in the queue status table accurately records the real-time status of the task. As shown in Table 1, by updating the qp wqe tailindex field to the address index of the newly assigned task, new queue tasks can be continuously added to the tail of each queue.

[0109] Step 506: Insert the task node corresponding to the current task into the end of the task linked list.

[0110] At the same time, the task node corresponding to the current task is inserted into the tail of the task linked list, so that the scheduling order between tasks in the queue is recorded through the task linked list.

[0111] In this embodiment, upon receiving a task, the queue's task list and status table are combined to record queue information and the order in which tasks are processed within the queue, providing information for subsequent task scheduling. Furthermore, queue scheduling not only considers whether the queue is active but also whether the queue has any real-time tasks. Queue tokens are scheduled based on the number of active queues with tasks, improving task scheduling efficiency.

[0112] In summary, the task scheduling method of the present application improves the efficiency and performance of task scheduling from the two aspects of task allocation and task scheduling, by combining the task list and status table of the queue.

[0113] First, regarding task allocation, the task is acquired and the queue is activated for task allocation. The queue's status table is read. If the queue is in a taskless state and the task is the first task in the queue, the queue is updated to a tasked state. The queue's head task in the queue status table is updated based on the current task. Based on the queue's priority, the queue's token is placed into the token ring of the corresponding priority. The queue's task list is initialized, with the current task as the first node of the task list. If the queue is in a tasked state, the queue's tail task in the queue status table is updated based on the current task. The task node corresponding to the current task is inserted at the end of the task list.

[0114] In this way, when a task is received, the queue's task list and status table are combined to record queue information and the order in which tasks are processed within the queue, providing information for subsequent task scheduling. Furthermore, queue scheduling not only monitors whether the queue is active, but also whether the queue has any real-time tasks. Queue tokens are dispatched based on the number of active queues with tasks, improving task scheduling efficiency.

[0115] Secondly, in terms of task scheduling, when the token ring of any priority is non-empty, the target token ring of the target priority to be scheduled is determined. The target token ring uses a FIFO queue, and the queue corresponding to the first token in the target token ring is read as the target queue to be scheduled. The status table of the target queue is read to obtain the current target task to be scheduled. Based on the current target task to be scheduled, the next task to be scheduled is obtained from the task list of the target queue. The scheduling processing module is called to process the target task. If there are unscheduled tasks in the queue and the scheduling time has not arrived, the next task to be scheduled is used as the current target task to be scheduled, and the step of obtaining the next task to be scheduled from the task list of the target queue based on the current target task to be scheduled is returned until the task scheduling in the target queue is completed or the scheduling time is reached.

[0116] If the scheduled time is reached, the target queue's token is written back to the end of the token ring and the target queue's status table, maintaining the target queue in a task-filled state. If the target queue's tasks are scheduled, the target queue's token is deleted from the target token ring and the target queue's status table is changed to a task-free state.

[0117] Specifically, the scheduling completion result of the target task is obtained, and the scheduling completion result of the target task is updated to the status table of the target queue.

[0118] When the scheduling completion result of the tail task of the target queue is received, it indicates that the task scheduling of the target queue is completed, the token of the target queue is deleted from the target token ring, and the target queue is modified to a no-task state in the state table of the target queue.

[0119] When the task scheduling in the target queue is completed or the scheduling time is reached, the scheduling of the target queue is ended, and the token ring of any priority is monitored again to see if it is non-empty to determine the next target queue to be scheduled and schedule the tasks in the target queue.

[0120] Thus, the task scheduling method of this application not only considers whether a queue is enabled, but also whether the queue has real-time queue tasks. It schedules queue tokens based on the number of active queues with queue tasks. Because of the dynamic scheduling scheme based on the number of active queues, token scheduling gaps can also be dynamically calculated and scheduled, providing higher scheduling performance and bandwidth.

[0121] Token reading and storage are dynamic, so the queue priority is not limited to the specified priority token ring. Specifically, when a queue first writes a task, its token is placed in the token ring for scheduling, and when the queue task is completed, its token is deleted from the token ring. Therefore, active queue tokens are frequently created and deleted. Each time a new queue token is created, a new priority can be assigned to it based on the needs of the business layer. At the same time, the token ring is designed to be divided into multiple token rings with different priorities. In this way, a newly created queue token can enter a different priority token ring each time based on the new token priority, thereby achieving real-time adjustment of the queue priority without affecting business operations.

[0122] These changes improve the performance of queue tasks at the application layer. The performance improvement is directly proportional to the ratio of the number of enabled queues to the number of active queues. They also provide more flexible scheduling policies and priorities, allowing them to be changed without shutting down the queues.

[0123] To better explain the task scheduling method of the present application, this embodiment is described using a task scheduling implementation method of a smart network card in a data center.

[0124] The token scheduling state machine implements the algorithm for scheduling tokens and the implementation of the scheduling state machine. The algorithm for token scheduling is defined according to the business implementation, such as absolute priority, priority proportional scheduling, etc. This application does not restrict the priority algorithm. The purpose of the algorithm is mainly to calculate which priority token ring needs to be scheduled next. After determination, the operation of the scheduling state machine begins, such as Figure 6 As shown,

[0125] The token scheduling state machine initially enters the Schedule Trigger Monitoring state, monitoring the empty signals of all priority token ring FIFOs in real time. If a token ring FIFO is not empty, the state machine transitions to the Token Ring Confirmation state. In the Token Ring Confirmation state, the business layer's scheduling token algorithm is used to calculate which priority token ring FIFO to schedule. After determining the target token ring, the state machine enters the Queue Confirmation state, reading a token ring's token (e.g., queue ID) to indicate the start of scheduling for that queue. This state also determines the number of currently active queues based on the count of active queues in each token ring and calculates the current queue's scheduling time. The state machine then enters the Read State Table state to retrieve the current task. After retrieval of the current task, the state machine enters the Read Task Linked List state to retrieve the next task. After retrieval of the next task, the state machine enters the Task Sending state to send the current task. Based on the next task pointed to by the current task linked list, the state machine enters the Read Task Linked List state again to retrieve the next task, and then enters the Task Sending state again to send the next task. This process continues until the last task in the target queue is dispatched, or the scheduling time is reached. The state machine then returns to the Schedule Trigger Monitoring state, ending the current scheduling phase and allowing the next task to proceed.

[0126] It should be noted that there is a difference between the completion of the target queue's task scheduling and the return to the scheduling trigger monitoring state when the scheduling time is reached. The completion of the target queue's task scheduling indicates that there are no new queue tasks. At this time, it is necessary to delete the token of the corresponding queue in the token ring (such as the queue id) and modify the target queue to a no-task state in the target queue's status table. For example, write qp valid in the queue status table to 0. Returning to the scheduling trigger monitoring state when the scheduling time is reached indicates that there are still tasks. At this time, the target queue's token is written back to the end of the token ring, and in the target queue's status table, the target queue is maintained in a task state. For example, the qp valid field in the queue status table continues to remain at 1.

[0127] The task scheduling method of the present application can be used in Internet data centers and cloud computing, and applied to standard network cards and smart network cards in servers in data centers that support virtualization and multi-user, and has the following technical effects:

[0128] 1. It can switch the priority of the queue in real time without affecting the business department's flow, and the priority management is implemented by the network card hardware.

[0129] 2. The network card hardware does not add all software-activated queues to the schedule. Instead, it schedules only queues with business traffic. The hardware can add queues with business traffic to the schedule in real time and remove queues without business traffic from the schedule in real time. The control accuracy can reach the microsecond level, realizing dynamic queue scheduling, significantly reducing scheduling overhead, and effectively improving scheduling performance.

[0130] 3. By offloading queue management and scheduling to the network card hardware, CPU usage can be further reduced, thereby increasing CPU business utilization and reducing costs.

[0131] On the other hand, the embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process of the above-mentioned task scheduling method embodiment is implemented, and the same technical effect is achieved. To avoid repetition, it is not described here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0132] On the other hand, an embodiment of the present application further provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the various processes of the task scheduling method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0133] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.

[0134] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), including a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0135] The above are only specific embodiments of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.

Claims

1. A task scheduling method, characterized in that: The method comprises: When the activation queue is assigned the first task, the token of the queue is placed into the token ring of the corresponding priority according to the priority of the queue; When the token ring of any priority is non-empty, determine the target token ring of the target priority to be scheduled; Determining a target queue to be scheduled according to the target token ring; The scheduling processing module is called to process the tasks of the target queue, and after the tasks of the target queue are scheduled, the token of the target queue is deleted from the target token ring.

2. The method according to claim 1, characterized in that The method further includes: determining a scheduling time for the target queue based on the number of currently valid queues; The calling of the scheduling processing module to process the tasks of the target queue includes: calling the scheduling processing module to process the tasks of the target queue within the scheduling time.

3. The method according to claim 2, characterized in that The calling scheduling processing module processes the task of the target queue, including: Read the status table of the target queue to obtain the target task currently to be scheduled; According to the target task currently to be scheduled, obtain the next task to be scheduled from the task list of the target queue; Calling the scheduling processing module to process the target task; If there are unscheduled tasks in the queue and the scheduling time has not arrived, the next task to be scheduled will be used as the current target task to be scheduled, and the process returns to the step of obtaining the next task to be scheduled from the task list of the target queue based on the current target task to be scheduled, until the tasks in the queue are scheduled completely or the scheduling time is reached.

4. The method according to claim 2 or 3, characterized in that The method further comprises: If the scheduling time is reached, the token of the target queue is written back to the tail of the token ring, and the target queue is maintained in a task state in the state table of the target queue; and / or, After the tasks of the target queue are scheduled, the target queue is modified to a no-task state in the state table of the target queue.

5. The method according to claim 1, wherein The target token ring adopts a FIFO queue, and the reading of the target token ring to determine the target queue to be scheduled includes any one of the following methods: The queue corresponding to the first token in the target token ring is read as the target queue to be scheduled.

6. The method according to claim 1, characterized in that When the activation queue is assigned the first task, the token of the queue is placed into the token ring of the corresponding priority according to the priority of the queue, including: Obtaining a task and assigning an activation queue to the task; Read the state table of the queue, and if the queue is in a no-task state and the task is the first task in the queue, update the queue to a task-having state; Update the queue head task in the status table of the queue according to the current task; According to the priority of the queue, the queue token is placed into the token ring of the corresponding priority; Initialize the task linked list of the queue and use the current task as the first node of the task linked list.

7. The method according to claim 6, characterized in that The method further comprises: If the queue is in a task state, then update the tail task of the queue in the state table of the queue according to the current task; Insert the task node corresponding to the current task into the tail of the task linked list.

8. The method according to claim 3, characterized in that After the task scheduling of the target queue is completed, deleting the token of the target queue in the target token ring includes: Obtaining the scheduling completion result of the target task, and updating the scheduling completion result of the target task to the status table of the target queue; When the scheduling completion result of the tail task of the target queue is received, it indicates that the task scheduling of the target queue is completed, and the token of the target queue is deleted from the target token ring.

9. A computer device for implementing task scheduling, comprising: A processor and a memory connected to the processor, wherein the memory stores a computer program executable by the processor, and when the computer program is executed by the processor, the steps of the task scheduling method according to any one of claims 1 to 8 are implemented.

10. A scheduling module, comprising: Multiple token rings, corresponding to queues of different priorities, are used to put tokens into the corresponding priority queues; The task list of each queue is used to record the processing order of tasks in each queue; The status table of each queue is used to record the attribute information of each queue; Scheduling timer, used to manage the scheduling time of each queue; Scheduling processing module, used for scheduling processing tasks; A token state scheduler is used to implement the steps of the task scheduling method described in any one of claims 1 to 8.