A task scheduling method, apparatus, device, and storage medium

By inserting tasks into the database in priority order, the problem of low task processing efficiency is solved, and timely processing and efficient management of tasks are achieved.

CN115686772BActive Publication Date: 2026-03-06GUANGZHOU WERIDE TECH LTD CO
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202211096281.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-08
Publication Date
2026-03-06
Estimated Expiration
2042-09-08

AI Technical Summary

Technical Problem

In a database, if a task cannot be processed within a specified time, its priority will be reduced or it will be canceled, affecting processing efficiency.

Method used

By determining the queue priority of tasks in the database at predetermined time points, high-priority tasks are inserted into high-priority queues, and low-priority tasks are inserted into low-priority queues, ensuring that tasks are processed in priority order.

Benefits of technology

Ensuring timely task processing improves the efficiency of database task processing and reduces the pressure on the database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115686772B_ABST
    Figure CN115686772B_ABST
Patent Text Reader

Abstract

This application discloses a task scheduling method, apparatus, device, and storage medium. The method involves determining a target queue currently in operation and assigning its priority as the first priority. At a predetermined time point, it checks if a first task with a priority higher than the first priority exists in the database. If it does, the first tasks with the highest priority are designated as first target tasks. A queue with the same priority as the first target task is designated as the first queue, and a new task is inserted into it. The operation of the target queue is stopped, and the operation of the first queue is started. If no task exists, it checks if a second target task corresponding to the first priority exists in the database. If it does, the second task is inserted into the target queue. This scheme ensures that tasks in the database are processed promptly, guaranteeing task processing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of task scheduling technology, specifically to a task scheduling method, apparatus, device, and storage medium. Background Technology

[0002] Priority is a convention where higher-priority tasks are processed first, and lower-priority tasks are processed later. Priority is a parameter used by a time-sharing operating system to determine the priority of system resources for each task when processing multiple tasks. In the field of task scheduling, each task in a database has its corresponding queue priority determined when it is generated. That is, each task in the database is inserted into a queue with the same priority according to its assigned priority, and the tasks in each queue are processed sequentially according to their respective priority levels.

[0003] However, task processing is time-sensitive. If the tasks that need to be processed in the database cannot be processed within the specified time, the original priority of these tasks will be reduced, or they may even be canceled, affecting the processing efficiency of the tasks. Summary of the Invention

[0004] In view of this, this application provides a task scheduling method, apparatus, device, and storage medium to solve the problem that if tasks that need to be processed in the database cannot be processed within a specified time, the original priority of these tasks will be reduced, or they may even be canceled, affecting the processing efficiency of the tasks.

[0005] To achieve the above objectives, the following solution is proposed:

[0006] Firstly, a task scheduling method includes:

[0007] Identify the target queue that is currently in a working state in the established queue set, wherein the queue set contains multiple queues, and each queue contains a corresponding queue priority;

[0008] The priority of the queue corresponding to the target queue shall be taken as the first priority;

[0009] At a predetermined time point, it is determined whether there are any first tasks to be inserted in the preset database that have a corresponding queue priority level higher than the first priority. The database contains multiple tasks, and each task contains a corresponding queue priority.

[0010] If they exist, the first tasks with the highest queue priority among the first tasks to be inserted are taken as the first target tasks; the queues in the queue set with the same queue priority as the first target tasks are taken as the first queue; each first new task is determined from the first target tasks and inserted into the first queue; the operation of the target queue is stopped and the operation of the first queue is started.

[0011] If not, then determine whether each of the second target tasks corresponding to the first priority exists in the database;

[0012] If the database contains various second target tasks corresponding to the first priority, then each second new task is determined from the various second target tasks and inserted into the target queue.

[0013] Preferably, determining each first new task from each of the first target tasks and inserting it into the first queue includes:

[0014] Determine the first number of tasks corresponding to the first queue; the first number of tasks is the number of the first new tasks that need to be inserted into the first queue.

[0015] Based on the first number of tasks, select from each of the first target tasks, and insert each of the selected first target tasks as a first new task into the first queue.

[0016] Preferably, determining the number of first tasks corresponding to the first queue includes:

[0017] Obtain the number of tasks consumed by the first queue between the two predetermined time nodes, and use the number of consumed tasks as the first consumption quantity;

[0018] Determine the number of tasks currently existing in the first queue, and use the number of existing tasks as the second consumption quantity;

[0019] The number of first tasks corresponding to the first queue is determined based on the first consumption quantity and the second consumption quantity.

[0020] Preferably, determining the number of first tasks corresponding to the first queue based on the first consumption quantity and the second consumption quantity includes:

[0021] If the second consumption quantity is greater than the first consumption quantity, then the first task quantity corresponding to the first queue is a first preset value;

[0022] If the second consumption quantity is the second preset threshold, then the first task quantity corresponding to the first queue is the product of the second task quantity and the third preset value;

[0023] If the second consumption quantity is greater than the second preset value and not less than the first consumption quantity, then the first consumption quantity is taken as the first task quantity corresponding to the first queue.

[0024] Preferably, the step of selecting from each of the first target tasks based on the first number of tasks, and inserting each selected first target task as a first new task into the first queue, includes:

[0025] Obtain the time when each of the first target tasks is generated;

[0026] Based on the time of each of the first target tasks, the first target tasks are sorted according to a preset sorting rule to obtain a first order;

[0027] Based on the first order and the first number of tasks, each first new task is selected from each of the first target tasks and inserted into the first queue.

[0028] Preferably, it further includes:

[0029] If the database does not contain any of the second target tasks corresponding to the first priority, then determine whether there are any second tasks to be inserted in the database whose corresponding queue priority level is lower than the first priority.

[0030] If there are second tasks to be inserted in the database whose corresponding queue priority level is lower than the first priority, then the second tasks to be inserted with the highest queue priority level among the second tasks to be inserted will be the third target tasks.

[0031] The queues in the queue set that have the same priority level as the queues corresponding to each of the third target tasks are designated as the second queues;

[0032] Each third new task is determined from each of the third target tasks and inserted into the second queue.

[0033] Secondly, a task scheduling device includes:

[0034] The target queue determination module determines the target queue that is currently in a working state in the established queue set. The queue set contains multiple queues, and each queue contains a corresponding queue priority.

[0035] The first priority determination module is used to determine the priority of the queue corresponding to the target queue as the first priority;

[0036] The first task to be inserted determination module is used to determine at a predetermined time node whether there are any first tasks to be inserted in the preset database that have a corresponding queue priority level higher than the first priority. The database contains multiple tasks, and each task contains its corresponding queue priority.

[0037] The first new task insertion module is used to, if present, select the first task to be inserted with the highest queue priority level among the first tasks to be inserted as the first target tasks; select the queue with the same priority level as the queue corresponding to the first target tasks as the first queue; determine the first new tasks from the first target tasks and insert them into the first queue; stop the operation of the target queue and start the operation of the first queue.

[0038] The second target task determination module is used to determine whether, if the target task does not exist, there are any second target tasks in the database corresponding to the first priority.

[0039] The second new task insertion module is used to determine each second new task from each second target task and insert it into the target queue if each second target task corresponding to the first priority exists in the database.

[0040] Preferably, the first new task insertion module includes:

[0041] The first task quantity determination module is used to determine the first task quantity corresponding to the first queue; the first task quantity is the number of the first new tasks that need to be inserted into the first queue.

[0042] The first new task selection module is used to select from each of the first target tasks based on the first number of tasks, and insert each of the selected first target tasks as a first new task into the first queue.

[0043] Thirdly, a task scheduling device includes a memory and a processor;

[0044] The memory is used to store programs;

[0045] The processor is configured to execute the program to implement the various steps of the task scheduling method as described in the first aspect.

[0046] Fourthly, a storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the task scheduling method as described in the first aspect.

[0047] As can be seen from the above technical solution, this application determines the target queue currently in working state in an established queue set, wherein the queue set contains multiple queues, each containing a corresponding queue priority; the queue priority corresponding to the target queue is taken as the first priority; at a predetermined time node, it is determined whether there are any first tasks to be inserted in a preset database with a corresponding queue priority level higher than the first priority, wherein the database contains multiple tasks, each containing a corresponding queue priority; if they exist, the first tasks to be inserted with the highest queue priority level among the first tasks to be inserted are taken as first target tasks; the queues in the queue set with the same queue priority level as the first target tasks are taken as first queues, and each first new task is determined from the first target tasks and inserted into the first queue, the operation of the target queue is stopped and the operation of the first queue is started; if they do not exist, it is determined whether there are any second target tasks corresponding to the first priority in the database; if there are any second target tasks corresponding to the first priority in the database, each second new task is determined from the second target tasks and inserted into the target queue. This scheme processes tasks in the database at predetermined time points and selects tasks in the database according to their priority level, inserting the selected tasks into queues with the same priority, thereby ensuring that tasks in the database can be processed in a timely manner and guaranteeing task processing efficiency. Attached Figure Description

[0048] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0049] Figure 1 An optional flowchart of a task scheduling method provided in an embodiment of this application;

[0050] Figure 2 A structural block diagram of a task scheduling method provided in an embodiment of this application;

[0051] Figure 3 This is a schematic diagram of the structure of a task scheduling device provided in an embodiment of this application;

[0052] Figure 4 This is a schematic diagram of the structure of a task scheduling device provided in an embodiment of this application. Detailed Implementation

[0053] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0054] Priority is a convention where higher-priority tasks are processed first, and lower-priority tasks are processed later. Priority is a parameter used by a time-sharing operating system to determine the priority of system resources for each task when processing multiple tasks. In the field of task scheduling, each task in a database has its corresponding queue priority determined when it is generated. That is, each task in the database is inserted into a queue with the same priority according to its assigned priority, and the tasks in each queue are processed sequentially according to their respective priority levels.

[0055] However, task processing is time-sensitive. If the tasks that need to be processed in the database cannot be processed within the specified time, the original priority of these tasks will be reduced, or they may even be canceled, affecting the processing efficiency of the tasks.

[0056] To address the aforementioned shortcomings, this invention provides a task scheduling method. This method can be applied to various computer terminals or smart terminals. The executing entity can be the processor or server of the computer terminal or smart terminal, or a scheduler in the field of task scheduling technology. The flowchart of the method is shown below. Figure 1 As shown, it specifically includes:

[0057] S1: Determine the target queue that is currently in a working state in the established queue set. The queue set contains multiple queues, and each queue contains its corresponding queue priority.

[0058] In the embodiments provided in this application, a queue set containing multiple queues is pre-established. Each queue contains its own corresponding queue priority, which can include multiple levels, such as high, medium, and level one, or level one, level two, and level three, and so on. This embodiment does not impose any limitations on this.

[0059] Understandably, only one queue in a queue set can be active at a time (active: consuming tasks from the queue). In one example, if the queue set has three queues with priorities of high, medium, and low, and all three queues have tasks, the working order of these three queues is: high-priority first, then medium-priority, and finally low-priority. That is, the high-priority queue works first, and the medium-priority queue begins working after the tasks in the high-priority queue have been processed.

[0060] Therefore, the queues currently in a working state in the queue set are first identified and used as the target queues.

[0061] S2: Set the priority of the target queue as the first priority.

[0062] Preferably, this step includes: obtaining the queue priority corresponding to the target queue and taking that queue priority as the first priority.

[0063] S3: At a predetermined time point, determine whether there are any first tasks to be inserted in the preset database that have a queue priority level higher than the first priority. The database contains multiple tasks, and each task contains its corresponding queue priority.

[0064] In this application, multiple time points can be preset. In one example, five minutes is set as a time interval, so a time point will be reached every five minutes.

[0065] At each time point, it is determined whether there are any first tasks to be inserted in the preset database whose corresponding queue priority level is higher than the first priority. The database can be preset, and there are multiple tasks in the database. It can be understood that each task in the database has its corresponding queue priority, and each queue in the queue set has its corresponding queue priority. The queue priority of the queue and the queue priority of the task belong to the same priority. The task in the database can only be inserted into the queue with the same queue priority.

[0066] At the preset time point, it is determined whether there are any first tasks to be inserted in the preset database that have a queue priority level higher than the first priority. There may not be only one queue priority among the first tasks to be inserted. Some queue priorities of the first tasks to be inserted may be several levels higher than the first priority level, and some queue priorities of the first tasks to be inserted may be one level higher than the first priority level.

[0067] S4: If it exists, then take the first task to be inserted with the highest priority level in the queue corresponding to each first task to be inserted as each first target task; take the queue in the queue set with the same priority level as the queue corresponding to each first target task as the first queue; determine each first new task from each first target task and insert it into the first queue; stop the work of the target queue and start the work of the first queue.

[0068] Specifically, if there are first tasks to be inserted in the database with a queue priority level higher than the first priority, since the first tasks to be inserted may contain multiple queue priority levels, based on the idea of ​​processing queues in order of priority, the first tasks to be inserted with the highest queue priority level are taken as the first target tasks, and the queues in the queue set with the same priority level as the first target tasks are taken as the first queue. Then, each new first task is determined from the first target tasks and inserted into the first queue. Since a new first task has been inserted into the first queue with a higher priority level, the work of the target queue is stopped and the work of the first queue is started.

[0069] S5: If it does not exist, then check if there are any second target tasks in the database that correspond to the first priority.

[0070] S6: If there are second target tasks in the database that correspond to the first priority, then determine each new second target task from the second target tasks and insert it into the target queue.

[0071] Specifically, if there are no first tasks to be inserted in the database that have a queue priority level higher than the first priority, there may be tasks that have the same queue priority level as the first priority level. These tasks will be used as second target tasks, and second new tasks will be determined from each second target task and inserted into the target queue. The target queue will continue to work.

[0072] As can be seen from the above technical solution, this application determines the target queue currently in working state in an established queue set, wherein the queue set contains multiple queues, each containing a corresponding queue priority; the queue priority corresponding to the target queue is taken as the first priority; at a predetermined time node, it is determined whether there are any first tasks to be inserted in a preset database with a corresponding queue priority level higher than the first priority, wherein the database contains multiple tasks, each containing a corresponding queue priority; if they exist, the first tasks to be inserted with the highest queue priority level among the first tasks to be inserted are taken as first target tasks; the queues in the queue set with the same queue priority level as the first target tasks are taken as first queues, and each first new task is determined from the first target tasks and inserted into the first queue, the operation of the target queue is stopped and the operation of the first queue is started; if they do not exist, it is determined whether there are any second target tasks corresponding to the first priority in the database; if there are any second target tasks corresponding to the first priority in the database, each second new task is determined from the second target tasks and inserted into the target queue. This scheme processes tasks in the database at predetermined time points and selects tasks in the database according to their priority level, inserting the selected tasks into queues with the same priority, thereby ensuring that tasks in the database can be processed in a timely manner and guaranteeing task processing efficiency.

[0073] On the other hand, tasks already inserted into the queue cannot change their corresponding queue priority. Therefore, this solution establishes a database in advance, stores the tasks that users want to process first in the database, assigns them a higher queue priority, and then inserts these tasks into queues with the same queue priority to achieve priority processing and meet user needs.

[0074] Furthermore, the task processing progress is updated to the database in real time. However, the database's concurrency capacity is not high, and frequent database updates under high concurrency can put enormous pressure on the database. This solution inserts tasks into queues with the same priority. When processing each task, data can be retrieved from the queues in descending order of priority. Finally, multiple independent processes update the task processing status back to the database, thereby reducing the pressure on the database.

[0075] The method provided in this embodiment of the invention, specifically the process of determining each first new task from each first target task and inserting it into the first queue, is described below:

[0076] S41: Determine the number of first tasks corresponding to the first queue; the number of first tasks is the number of first new tasks that need to be inserted into the first queue.

[0077] To determine the first new tasks from the first target tasks, we first need to determine the number of first new tasks that need to be inserted, and use that number as the number of first tasks.

[0078] Optionally, the process of determining the number of first tasks corresponding to the first queue may include:

[0079] S411: Obtain the number of tasks consumed by the first queue between the two predetermined time nodes, and use the number of consumed tasks as the first consumption quantity.

[0080] It is understandable that the number of tasks consumed is the number of tasks processed by the first queue between two predetermined time nodes. This can be understood as the work unit pulling tasks from each queue and processing them.

[0081] S412: Determine the number of tasks currently existing in the first queue, and use the number of existing tasks as the second consumption quantity.

[0082] S413: Determine the number of first tasks corresponding to the first queue based on the first consumption quantity and the second consumption quantity.

[0083] Optionally, based on the first consumption quantity and the second consumption quantity:

[0084] If the second consumption quantity is small and the first consumption quantity is large, it indicates that the first queue had a strong task processing capacity in the previous time period. Therefore, the number of first tasks can be increased to maintain the working status of the first queue. If the first consumption quantity is small and the second consumption quantity is large, it indicates that the first queue had a weak task processing capacity in the previous time period. Therefore, the number of first tasks can be reduced to prevent excessive pressure on the first queue and affect its normal operation.

[0085] Therefore, this step may include:

[0086] S4131: If the second consumption quantity is greater than the first consumption quantity, then the first task quantity corresponding to the first queue is a first preset value.

[0087] If the second consumption quantity is greater than the first consumption quantity, it indicates that the first queue has a weaker ability to process tasks. In this case, the first preset value can be set to a smaller value, such as 1 or 2.

[0088] S4132: If the second consumption quantity is a second preset threshold, then the first task quantity corresponding to the first queue is the product of the second task quantity and the third preset value.

[0089] The second preset threshold can be set to 0. It can be understood that when the second consumption quantity is 0, that is, there are no tasks in the first queue, it can be said that the task processing capacity of the first queue is strong. Therefore, the first task quantity can be set to a large value. Then the third preset value can be set to 2 or 3, that is, the first task quantity is 2 or 3 times the first consumption quantity. This embodiment does not limit this.

[0090] S4133: If the second consumption quantity is greater than the second preset value and not less than the first consumption quantity, then the first consumption quantity is used as the first task quantity corresponding to the first queue.

[0091] If the second consumption quantity is greater than zero and greater than or equal to the first consumption quantity, then the first consumption quantity will be used as the first task quantity corresponding to the first queue.

[0092] S42: Based on the first number of tasks, select from each of the first target tasks, and insert each of the selected first target tasks as a first new task into the first queue.

[0093] Let N be the number of first tasks. Then, select N first target tasks from the first target tasks as the first new tasks and insert these N first new tasks into the first queue.

[0094] The above embodiments illustrate how the present application determines each first new task from each first target task and inserts it into the first queue. The following describes in detail how the present application selects from each first target task based on the number of first tasks and inserts the selected first target tasks as each first new task into the first queue.

[0095] S421: Obtain the time of each of the first target tasks.

[0096] S422: Based on the time of each of the first target tasks, sort each of the first target tasks according to a preset sorting rule to obtain a first order.

[0097] S423: Based on the first order and the first number of tasks, select each first new task from each first target task and insert it into the first queue.

[0098] In another embodiment provided in this application, the task scheduling method may further include:

[0099] If the database does not contain any of the second target tasks corresponding to the first priority, then it is determined whether there are any second tasks to be inserted in the database whose corresponding queue priority level is lower than the first priority.

[0100] If there are second tasks to be inserted in the database whose corresponding queue priority level is lower than the first priority, then the second tasks to be inserted with the highest queue priority level among the second tasks to be inserted will be the third target tasks.

[0101] The queues in the queue set that have the same priority level as the queues corresponding to each of the third target tasks are designated as the second queues.

[0102] Each third new task is determined from each of the third target tasks and inserted into the second queue.

[0103] It is understandable that if there are second tasks to be inserted in the database with queue priorities lower than the first priority, then the second tasks with the highest queue priorities among the second tasks to be inserted are taken as third target tasks. From these third target tasks, new third tasks are determined and inserted into queues with the same queue priority as the third target tasks. The process of determining the new third tasks can refer to the process of determining the new first tasks described above, and will not be repeated here. It should be noted that inserting a new third task into the second queue does not mean that the second queue will start working. If there are no tasks in the target queue at this time, the second queue can start working. If there are still tasks in the target queue, the target queue will continue working. The second queue will only start working if the tasks in the target queue are processed before the next time node arrives. The structural diagram of the task scheduling method provided in this application can be seen as follows: Figure 2 As shown.

[0104] and Figure 1 Corresponding to the method described above, embodiments of the present invention also provide a task scheduling device for scheduling tasks. Figure 1 In the specific implementation of the method, the task scheduling device provided in this embodiment of the invention can be used in computer terminals or various mobile devices, combined with Figure 3 The task scheduling device will be introduced, such as... Figure 3 As shown, the device may include:

[0105] The target queue determination module 10 determines the target queue that is currently in a working state in the established queue set. The queue set contains multiple queues, and each queue contains a corresponding queue priority.

[0106] The first priority determination module 20 is used to take the priority of the queue corresponding to the target queue as the first priority.

[0107] The first task to be inserted determination module 30 is used to determine at a predetermined time node whether there are any first tasks to be inserted in the preset database that have a corresponding queue priority level higher than the first priority. The database contains multiple tasks, and each task contains a corresponding queue priority.

[0108] The first new task insertion module 40 is used to, if present, select the first task to be inserted with the highest queue priority level among the first tasks to be inserted as the first target tasks; select the queue with the same queue priority level as the first target tasks as the first queue; determine the first new tasks from the first target tasks and insert them into the first queue; stop the operation of the target queue and start the operation of the first queue.

[0109] The second target task determination module 50 is used to determine whether each second target task corresponding to the first priority exists in the database if it does not exist.

[0110] The second new task insertion module 60 is used to determine each second new task from each second target task and insert it into the target queue if each second target task corresponding to the first priority exists in the database.

[0111] As can be seen from the above technical solution, this application determines the target queue currently in working state in an established queue set, wherein the queue set contains multiple queues, each containing a corresponding queue priority; the queue priority corresponding to the target queue is taken as the first priority; at a predetermined time node, it is determined whether there are any first tasks to be inserted in a preset database with a corresponding queue priority level higher than the first priority, wherein the database contains multiple tasks, each containing a corresponding queue priority; if they exist, the first tasks to be inserted with the highest queue priority level among the first tasks to be inserted are taken as first target tasks; the queues in the queue set with the same queue priority level as the first target tasks are taken as first queues, and each first new task is determined from the first target tasks and inserted into the first queue, the operation of the target queue is stopped and the operation of the first queue is started; if they do not exist, it is determined whether there are any second target tasks corresponding to the first priority in the database; if there are any second target tasks corresponding to the first priority in the database, each second new task is determined from the second target tasks and inserted into the target queue. This scheme processes tasks in the database at predetermined time points and selects tasks in the database according to their priority level, inserting the selected tasks into queues with the same priority, thereby ensuring that tasks in the database can be processed in a timely manner and guaranteeing task processing efficiency.

[0112] In one example, the first new task insertion module 40 may include:

[0113] The first task quantity determination module is used to determine the first task quantity corresponding to the first queue; the first task quantity is the number of the first new tasks that need to be inserted into the first queue.

[0114] The first new task selection module is used to select from each of the first target tasks based on the first number of tasks, and insert each of the selected first target tasks as a first new task into the first queue.

[0115] In one example, the first task quantity determination module may include:

[0116] The first consumption quantity determination module is used to obtain the number of tasks consumed by the first queue between the two predetermined time nodes, and use the number of consumed tasks as the first consumption quantity.

[0117] The second consumption quantity determination module is used to determine the number of tasks currently existing in the first queue, and use the number of existing tasks as the second consumption quantity.

[0118] The first task quantity determination module is used to determine the first task quantity corresponding to the first queue based on the first consumption quantity and the second consumption quantity.

[0119] In one example, the first task quantity determination module may include:

[0120] The first determining submodule is configured to, if the second consumption quantity is greater than the first consumption quantity, then the first task quantity corresponding to the first queue is a first preset value.

[0121] The second determining submodule is configured to, if the second consumption quantity is a second preset threshold, then the first task quantity corresponding to the first queue is the product of the second task quantity and a third preset value.

[0122] The third determining submodule is used to determine the first consumption quantity as the first task quantity corresponding to the first queue if the second consumption quantity is greater than the second preset value and not less than the first consumption quantity.

[0123] In one example, the first new task selection module may include:

[0124] The acquisition module is used to acquire the time of each of the first target tasks.

[0125] The sorting module is used to sort the first target tasks according to the time they were generated, and according to a preset sorting rule, to obtain a first order.

[0126] The selection module is used to select each first new task from each first target task and insert it into the first queue based on the first order and the first number of tasks.

[0127] In one example, the device further includes:

[0128] The second task to be inserted determination module is used to determine whether there are any second target tasks in the database that have a queue priority level lower than the first priority if there are no second target tasks in the database that correspond to the first priority.

[0129] The third target task determination module is used to determine the second task to be inserted with the highest queue priority among the second tasks to be inserted if there are second tasks to be inserted in the database with a corresponding queue priority level lower than the first priority.

[0130] The second queue determination module is used to select the queues in the queue set that have the same priority level as the queues corresponding to each of the third target tasks as the second queues.

[0131] The third new task insertion module is used to determine each third new task from each of the third target tasks and insert it into the second queue.

[0132] Furthermore, embodiments of this application provide a task scheduling device. Optionally, Figure 4 The hardware structure block diagram of the task scheduling device is shown below. Figure 4 The hardware structure of the task scheduling device may include: at least one processor 01, at least one communication interface 02, at least one memory 03, and at least one communication bus 04.

[0133] In this embodiment, the number of processor 01, communication interface 02, memory 03 and communication bus 04 is at least one, and processor 01, communication interface 02 and memory 03 communicate with each other through communication bus 04.

[0134] Processor 01 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention.

[0135] Memory 03 may include high-speed RAM, and may also include non-volatile memory, such as at least one disk storage device.

[0136] The memory stores a program, which the processor can call to execute. The program is used to perform the following task scheduling methods, including:

[0137] Identify the target queue that is currently in a working state in the established queue set, wherein the queue set contains multiple queues, and each queue contains a corresponding queue priority;

[0138] The priority of the queue corresponding to the target queue shall be taken as the first priority;

[0139] At a predetermined time point, it is determined whether there are any first tasks to be inserted in the preset database that have a corresponding queue priority level higher than the first priority. The database contains multiple tasks, and each task contains a corresponding queue priority.

[0140] If they exist, the first tasks with the highest queue priority among the first tasks to be inserted are taken as the first target tasks; the queues in the queue set with the same queue priority as the first target tasks are taken as the first queue; each first new task is determined from the first target tasks and inserted into the first queue; the operation of the target queue is stopped and the operation of the first queue is started.

[0141] If not, then determine whether each of the second target tasks corresponding to the first priority exists in the database;

[0142] If the database contains various second target tasks corresponding to the first priority, then each second new task is determined from the various second target tasks and inserted into the target queue.

[0143] Optionally, the refined and extended functions of the program can be found in the description of the task scheduling method in the method embodiments.

[0144] This application embodiment also provides a storage medium that can store a program suitable for execution by a processor. When the program runs, it controls the device where the storage medium is located to execute the following task scheduling method, including:

[0145] Identify the target queue that is currently in a working state in the established queue set, wherein the queue set contains multiple queues, and each queue contains a corresponding queue priority;

[0146] The priority of the queue corresponding to the target queue shall be taken as the first priority;

[0147] At a predetermined time point, it is determined whether there are any first tasks to be inserted in the preset database that have a corresponding queue priority level higher than the first priority. The database contains multiple tasks, and each task contains a corresponding queue priority.

[0148] If they exist, the first tasks with the highest queue priority among the first tasks to be inserted are taken as the first target tasks; the queues in the queue set with the same queue priority as the first target tasks are taken as the first queue; each first new task is determined from the first target tasks and inserted into the first queue; the operation of the target queue is stopped and the operation of the first queue is started.

[0149] If not, then determine whether each of the second target tasks corresponding to the first priority exists in the database;

[0150] If the database contains various second target tasks corresponding to the first priority, then each second new task is determined from the various second target tasks and inserted into the target queue.

[0151] Specifically, the storage medium can be a computer-readable storage medium, which can be an electronic storage device such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM.

[0152] Optionally, the refined and extended functions of the program can be found in the description of the task scheduling method in the method embodiments.

[0153] Furthermore, the functional modules in the various embodiments of this disclosure can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part. If the function is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a live streaming device, or a network device, etc.) to execute all or part of the steps of the methods in the various embodiments of this disclosure.

[0154] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0155] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0156] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A task scheduling method, characterized by, The method comprises the following steps: determining a target queue currently in a working state in an established queue set, wherein the queue set is provided with a plurality of queues, and each of the queues comprises a queue priority corresponding to the queue; taking the queue priority corresponding to the target queue as a first priority; at a predetermined time node, judging whether each first to-be-inserted task with a queue priority level higher than the first priority exists in a preset database, wherein the database is provided with a plurality of tasks, and each of the tasks comprises a queue priority corresponding to the task; if the first to-be-inserted task exists, taking each first to-be-inserted task with the highest queue priority level as each first target task, taking a queue with the same queue priority level as the first target task in the queue set as a first queue, determining each first new task to be inserted into the first queue from the first target task, stopping the work of the target queue and starting the work of the first queue; the method comprises the following steps: obtaining the number of tasks consumed by the first queue between two predetermined time nodes, taking the number of consumed tasks as a first consumption number; determining the number of tasks existing in the first queue, taking the number of existing tasks as a second consumption number; if the second consumption number is greater than the first consumption number, the first task number corresponding to the first queue is a first preset value; if the second consumption number is a second preset value, the first task number corresponding to the first queue is a product of the second consumption number and a third preset value; if the second consumption number is greater than the second preset value and is not less than the first consumption number, the first consumption number is taken as the first task number corresponding to the first queue; the first task number is the number of first new tasks to be inserted into the first queue; based on the first task number, each selected first target task is taken as each first new task to be inserted into the first queue; if the first to-be-inserted task does not exist, judging whether each second target task corresponding to the first priority exists in the database; if each second target task corresponding to the first priority exists in the database, determining each second new task to be inserted into the target queue from each second target task.

2. The method of claim 1, wherein, The method for selecting each first target task from each first target task based on the first task number and taking each selected first target task as each first new task to be inserted into the first queue comprises the following steps: obtaining the time when each first target task is generated; sorting each first target task according to a preset sorting rule based on the time when each first target task is generated to obtain a first order; selecting each first new task to be inserted into the first queue from each first target task based on the first order and the first task number.

3. The method of claim 1, wherein, The method further comprises the following steps: If there is no second target task corresponding to the first priority in the database, it is determined whether there is a second to-be-inserted task corresponding to a queue priority level lower than the first priority in the database; If there is a second to-be-inserted task corresponding to a queue priority level lower than the first priority in the database, the second to-be-inserted task corresponding to the highest queue priority level is taken as a third target task; Queues in the queue set corresponding to the queue priority level of the third target task are taken as a second queue; A third new task is inserted into the second queue from the third target task.

4. A task scheduling apparatus characterized by comprising: Comprise: A target queue determination module is configured to determine a target queue currently in a working state in a queue set, wherein the queue set is provided with a plurality of queues, and each queue comprises a queue priority corresponding thereto; A first priority determination module is configured to take the queue priority corresponding to the target queue as a first priority; A first to-be-inserted task determination module is configured to determine, at a predetermined time node, whether there is a first to-be-inserted task corresponding to a queue priority level higher than the first priority in a preset database, wherein the database is provided with a plurality of tasks, and each task comprises a queue priority corresponding thereto; A first new task insertion module is configured to take, if there is, the first to-be-inserted task corresponding to the highest queue priority level as a first target task; take the queue in the queue set corresponding to the queue priority level of the first target task as a first queue; determine a first new task inserted into the first queue from the first target task; stop the working of the target queue and start the working of the first queue; comprise: a first task quantity determination module is configured to obtain the number of tasks consumed by the first queue between two predetermined time nodes, take the number of consumed tasks as a first consumption quantity; determine the number of tasks currently existing in the first queue, take the number of existing tasks as a second consumption quantity; if the second consumption quantity is greater than the first consumption quantity, the first task quantity corresponding to the first queue is a first preset value; if the second consumption quantity is a second preset value, the first task quantity corresponding to the first queue is the product of the second consumption quantity and a third preset value; if the second consumption quantity is greater than the second preset value and not less than the first consumption quantity, the first consumption quantity is taken as the first task quantity corresponding to the first queue; the first task quantity is the number of first new tasks that need to be inserted into the first queue; a first new task selection module is configured to select, based on the first task quantity, from each first target task, take each selected first target task as each first new task inserted into the first queue. a second target task determination module, configured to determine whether each second target task corresponding to the first priority exists in the database if the first target task does not exist; a second new task insertion module, configured to determine each second new task inserted into the target queue from each second target task if each second target task corresponding to the first priority exists in the database.

5. A task scheduling device characterized by comprising: comprising a memory and a processor; the memory, configured to store a program; the processor, configured to execute the program to implement each step of the task scheduling method according to any one of claims 1-3.

6. A storage medium having stored thereon a computer program, characterized in that the computer program, when executed by the processor, implements each step of the task scheduling method according to any one of claims 1-3.

Citation Information

Patent Citations

  • Task processing method and system

    CN109814988A

  • Tax control equipment control method and device, storage medium and electronic equipment

    CN112395107A

  • Task scheduling method and device

    CN113157424A