Task scheduling method and device, equipment, medium and product
By prioritizing the query of the retry queue and the initial queue in task scheduling, the problem of inflexible task scheduling in existing technologies is solved, thereby achieving greater flexibility in task scheduling and maximizing resource utilization, and improving supply chain efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING JINGDONG YUANSHENG TECH CO LTD
- Filing Date
- 2024-11-19
- Publication Date
- 2026-05-19
AI Technical Summary
Existing task scheduling methods only consider task priority and ignore scheduling flexibility, resulting in low supply chain efficiency.
During task scheduling, the system first checks the retry queue to see if there are any target tasks with resource consumption less than the current system's available resources. If not, it checks the initial queue, prioritizes tasks with resource consumption less than the available resources, and adds them to the retry queue to update the queue, ensuring the flexibility of task scheduling and maximizing resource utilization.
It improves the flexibility and adaptability of task scheduling, prevents system lag or crashes, ensures maximum utilization of system resources, and significantly improves supply chain efficiency.
Smart Images

Figure CN122064429A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a task scheduling method, apparatus, device, medium and product. Background Technology
[0002] In task scheduling, existing technologies typically add tasks to be consumed sequentially to a queue according to task priority, and then consume each task in the queue in turn based on the first-in-first-out principle.
[0003] However, in the process of realizing this invention, the inventors discovered at least the following problems in the prior art:
[0004] Existing task scheduling methods often only consider task priority without considering the flexibility of task scheduling. Task scheduling methods that lack scheduling flexibility are prone to causing low supply chain efficiency. Summary of the Invention
[0005] This invention provides a task scheduling method, apparatus, device, medium, and product to improve supply chain efficiency by enhancing the flexibility of task scheduling.
[0006] In a first aspect, embodiments of the present invention provide a task scheduling method, the method comprising:
[0007] In response to a task consumption signal, the system sequentially queries the retry queue for target tasks whose resource usage is less than the current system idle resource amount, wherein the target task includes the resource usage.
[0008] If no target task with a resource consumption less than the current system idle resource amount is found in the retry queue, then the target task with a resource consumption less than the current system idle resource amount is sequentially queried in the initial queue.
[0009] If a target task with a resource consumption amount less than the current system idle resource amount is found in the initial queue, then the target task is treated as a task to be consumed, and the target tasks distributed in the initial queue before the task to be consumed are added to the retry queue in order to update the retry queue.
[0010] Execute the task to be consumed.
[0011] Secondly, embodiments of the present invention also provide a task scheduling apparatus, the apparatus comprising:
[0012] The response module is used to respond to the task consumption signal by sequentially querying the retry queue for target tasks whose resource usage is less than the current system idle resource amount, wherein the target task includes the resource usage.
[0013] The first module is used to sequentially query the initial queue for target tasks whose resource usage is less than the current system idle resource amount if no target task with resource usage is found in the retry queue.
[0014] The second module is used to, if a target task with a resource occupancy less than the current system idle resource amount is found in the initial queue, then treat the target task as a task to be consumed, and add the target tasks in the initial queue before the task to be consumed to the retry queue in order to update the retry queue.
[0015] The consumption module is used to execute the task to be consumed.
[0016] Thirdly, embodiments of the present invention provide an electronic device, the electronic device comprising:
[0017] One or more processors;
[0018] Memory, used to store one or more programs;
[0019] When the one or more programs are executed by the one or more processors, the one or more processors implement the task scheduling method provided in any embodiment of the present invention.
[0020] Fourthly, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the task scheduling method provided in any embodiment of the present invention.
[0021] Fifthly, embodiments of the present invention also provide a computer program product, the computer program product including a computer program, which, when executed by a processor, implements the task scheduling method described in any embodiment.
[0022] The embodiments of the above invention have the following advantages or beneficial effects:
[0023] At the start of each task scheduling, the retry queue is first checked to see if there are any target tasks with resource consumption less than the current system's idle resources. This reflects that the retry queue has a higher priority than the sub-queues in the initial queue. Target tasks distributed before the tasks to be consumed in the initial queue are added to the retry queue to update it. This temporarily suspends the execution of target tasks that do not meet resource requirements, preventing system lag or crashes caused by executing such tasks and improving the flexibility of task scheduling. If a target task with resource consumption less than the current system's idle resources is found in the initial queue, it is treated as a task to be consumed and executed. This ensures that the highest priority target task that meets resource requirements is consumed in each task scheduling, improving the flexibility and adaptability of task scheduling. It also ensures that the system can execute tasks to be consumed without pressure while maximizing the utilization of system resources, achieving a balance between task priority and task consumption speed, and significantly improving supply chain efficiency. Attached Figure Description
[0024] Figure 1 This is a flowchart illustrating the task scheduling method provided in an embodiment of the present invention;
[0025] Figure 2 This is another flowchart illustrating the task scheduling method provided in this embodiment of the invention;
[0026] Figure 3 This is another flowchart illustrating the task scheduling method provided in this embodiment of the invention;
[0027] Figure 4 This is a schematic diagram of the structure of the task scheduling device provided in an embodiment of the present invention;
[0028] Figure 5 This is another structural schematic diagram of the task scheduling device provided in the embodiments of the present invention;
[0029] Figure 6 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation
[0030] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.
[0031] Figure 1This is a flowchart illustrating a task scheduling method provided in an embodiment of the present invention. This embodiment is applicable to situations where task scheduling flexibility is improved by balancing task priority and task consumption speed. The method can be executed by a task scheduling device integrated into an electronic device, which can be implemented in software and / or hardware. Figure 1 As shown, the method specifically includes the following steps:
[0032] S110. In response to the task consumption signal, sequentially query the retry queue for target tasks whose resource usage is less than the current system idle resource amount. The target task includes resource usage.
[0033] S120. If no target task with a resource consumption less than the current system's idle resources is found in the retry queue, then the target task with a resource consumption less than the current system's idle resources is searched in the initial queue in sequence.
[0034] S130. If a target task with a resource consumption amount less than the current system's idle resource amount is found in the initial queue, then the target task is treated as a task to be consumed, and the target tasks distributed before the tasks to be consumed in the initial queue are added to the retry queue in order to update the retry queue.
[0035] S140, Execute the task to be consumed.
[0036] Each target task in the retry queue and the initial queue may include only one item acquisition task or at least two item acquisition tasks.
[0037] The system needs to allocate corresponding system resources when executing each target task. Since the number of item acquisition tasks included in each target task may be the same or different, and the amount of system resources required for each item acquisition task may be the same or different, the amount of system resources allocated by the system when executing each target task may be the same or different.
[0038] In this embodiment, each target task in the retry queue and the initial queue includes the resource consumption required for its execution.
[0039] The resource consumption of the target task can be understood as the amount of system resources that the system needs to allocate when executing the corresponding target task. The system idle resource amount can be understood as the amount of currently available system resources, or the amount of currently remaining system resources. Since insufficient memory resources may lead to degradation of optimization results or even system crashes, the resource consumption in this embodiment includes at least the memory consumption, and the system idle resource amount includes at least the amount of idle memory resources.
[0040] Specifically, free memory resources equal the difference between total memory resources and occupied memory resources. In some embodiments, insufficient CPU resources can slow down problem solving, i.e., task consumption, therefore, the system's free resources include free memory resources and free CPU resources. Resource usage includes memory resource usage and CPU resource usage. Idle CPU resources equal the difference between total CPU resources and occupied CPU resources.
[0041] In one embodiment, the resource consumption is an estimated resource consumption. Specifically, the resource consumption is determined based on the number of item acquisition tasks involved in the target task, the process nodes corresponding to the item acquisition tasks, and the transportation information corresponding to the item acquisition tasks. It should be noted that this embodiment only needs to estimate the resource consumption required for the execution of each target task based on existing resource consumption estimation methods; the specific estimation methods will not be elaborated here.
[0042] In one embodiment, a scene identifier for an item acquisition task is determined, and the resource consumption required for the system to execute a single item acquisition task under that scene identifier is obtained. This resource consumption is then used as the unit resource consumption under the target scene. Thus, before adding the target task to the initial queue, the scene identifier corresponding to the target task, the unit resource consumption of the item acquisition tasks under that scene identifier, and the number of item acquisition tasks included in the target task are determined. Then, the resource consumption corresponding to the target task is determined based on the unit resource consumption and the number of item acquisition tasks. Specifically, in one embodiment, the product of the unit resource consumption and the number of items acquired is used as the resource consumption corresponding to the target task. In another embodiment, the product of the unit resource consumption and the number of items acquired is determined, and the product of this product and a set coefficient is used as the resource consumption corresponding to the target task, where the set coefficient is greater than 1 and less than or equal to 1.5. Increasing the resource consumption of the target task ensures that the system only executes the corresponding target task when the resource consumption is greater than the increased amount, thus guaranteeing the execution speed of the target task.
[0043] Once the resource requirements of the target task are determined, they are added to the target task list to update it; then, the updated target task is added to the initial queue. The target task also includes information such as item identifiers, item supplier identifiers, logistics node identifiers, and transportation information required for its execution.
[0044] The target tasks in the retry queue are those that were not consumed in time from the initial queue due to insufficient system resources. Therefore, the target tasks in the retry queue have a higher priority than those in the initial queue. The resource condition refers to the requirement that the amount of available system resources must be greater than the resource usage of the target task.
[0045] Given that the priority of the target task in the retry queue is higher than that of the target task in the current initial queue, this embodiment, upon detecting a task consumption signal, prioritizes querying the retry queue for target tasks with resource consumption less than the current system's idle resources. If no target task with resource consumption less than the current system's idle resources is found in the retry queue, then the initial queue is queried for target tasks with resource consumption less than the current system's idle resources.
[0046] Specifically, a task consumption signal is triggered based on the timing information output by the timer. In response to the timed task consumption signal, the system sequentially searches the retry queue for target tasks whose resource usage is less than the current system's available resources. If a target task with less resource usage is found in the retry queue, it is executed, and the task consumption process corresponding to the current task consumption signal ends. If no target task with less resource usage is found in the retry queue, a target task with less resource usage is sequentially searched in the initial queue. The timer can be set to trigger the task consumption signal every 0.5 seconds, 1 second, or even 2 seconds.
[0047] Furthermore, the first target task in the retry queue is taken as the current target task, meaning the task with the highest priority in the retry queue is taken as the current target task. Then, it is determined whether the current target task is null. If it is null, the initial queue is searched sequentially for target tasks with resource consumption less than the current system's idle resources. If the current target task is not null, it is determined whether the resource consumption corresponding to the current target task is less than the current system's idle resources. If so, the current target task is set as a task to be consumed and executed. If not, the current target task's position in the retry queue remains unchanged, the next task is taken as the current target task, and the process of determining whether the current target task is null is returned, until the current target task is a task to be consumed or the current target task is null. It can be understood that if the current target task is null, it means that the current target task does not actually exist; that is, the target tasks in the retry queue have been traversed, and the initial queue needs to be searched sequentially for target tasks with resource consumption less than the current system's idle resources.
[0048] In this embodiment, the resource usage of each target task in both the retry queue and the initial queue is compared with the system's idle resource quantity at the corresponding time. Since the system may add new tasks or terminate existing ones, the system's idle resource quantity is a dynamic value, not a fixed one. Therefore, the comparison between the resource usage of each target task in the retry queue and the initial queue is a dynamic value, not a fixed one. However, regardless of changes in the system's idle resource quantity, the resource usage of each target task in the retry queue is sequentially checked against the system's idle resource quantity at the corresponding time, according to task priority.
[0049] For example, the resource usage of the target task identified as A0 in the retry queue is Z1, and the resource usage of the target task identified as A2 in the retry queue is Z2. The priority of the target task identified as A0 is higher than that of the target task identified as A1, and Z1 is less than Z2. When the processor finds the target task identified as A0, its system idle resources are less than Z1, so the processor does not execute the target task identified as A0 but keeps it in the retry queue. When the processor finds the target task identified as A1, its system idle resources are greater than Z2, so the processor directly executes the target task identified as A1.
[0050] In this embodiment, when querying a target task whose resource usage is less than the current system's idle resources in the initial queue, if the target task whose resource usage is less than the current system's idle resources is not the first target task in the initial queue, then all target tasks distributed before the target task whose resource usage is less than the current system's idle resources are added sequentially to the tail of the retry queue before executing the target task whose resource usage is less than the current system's idle resources. Alternatively, while executing the target task whose resource usage is less than the current system's idle resources, all target tasks distributed before the target task whose resource usage is less than the current system's idle resources are added sequentially to the tail of the retry queue. Of course, the target task whose resource usage is less than the current system's idle resources can also be executed first, and then all target tasks distributed before the target task whose resource usage is less than the current system's idle resources are added sequentially to the tail of the retry queue.
[0051] In one embodiment, step a1: The first target task in the initial queue is taken as the current target task. Step a2: Determine whether the resource consumption of the current target task is less than the current system's idle resources. Step a3: If the resource consumption of the current target task is less than the current system's idle resources, then the current target task is taken as a task to be consumed. Step a4: If the resource consumption of the current target task is greater than or equal to the current system's idle resources, then the target task is added to the retry queue to update the retry queue, and the next target task is taken as the current target task. The process of determining whether the resource consumption of the current target task is less than the current system's idle resources is then repeated until the current target task is a task to be consumed or the current target task is null. This embodiment sequentially determines whether the resource consumption of each target task is less than the current system's idle resources, and consumes the target task or adds the target task to the retry queue based on the determination result, achieving the technical effect of performing corresponding processing operations on each determination result.
[0052] In another embodiment, a target task with a resource consumption less than the current system's idle resources is queried from the initial queue. If a target task with a resource consumption less than the current system's idle resources is found, and this target task is the first target task in the initial queue, then this target task is designated as a task to be consumed. If this target task is not the first target task in the initial queue, then this target task is designated as a task to be consumed, and all target tasks preceding this task are sequentially added to the tail of the retry queue. If no target task with a resource consumption less than the current system's idle resources is found in the initial queue, then all target tasks in the initial queue are sequentially added to the tail of the retry queue, ending the task consumption process corresponding to the current task consumption signal. It is understood that the priority order of the target tasks in the retry queue is consistent with their priority order in the initial queue. This embodiment only performs task consumption or task addition actions when a task to be consumed is found, or performs task addition actions when no task to be consumed is found in the initial queue, simplifying the process of adding each target task to the retry queue.
[0053] In one embodiment, such as Figure 2As shown, the process begins by taking the first target task in the retry queue as the current target task; determining if the current target task has a value; if it does, checking if its resource usage is less than the available system resources; if less, it is designated as a pending task and executed, ending the current task's consumption process; if its resource usage is greater than or equal to the available system resources, it is retained in the retry queue. If the current target task has no value, it indicates the retry queue has been traversed, so the highest-priority subqueue identifier is retrieved from the subqueue identifier combination; the first target task in the subqueue corresponding to this highest-priority identifier is taken as the current target task; the process continues by determining if it has a value; if no value, it indicates all subqueues in the initial queue have been traversed, ending the current task's consumption process. If the current target task has a value, it is determined whether the resource usage of the current target task is less than the current system's idle resources. If the resource usage is less than the idle resources, the current target task is set as a pending task and executed, ending the current task consumption process. If the resource usage is greater than or equal to the idle resources, the current target task is added to the tail of the retry queue, and the next target task is set as the current target task. The process returns to the step indicating whether the current target task has a value, continuing until the current target task becomes a pending task or has no value, ending the current task consumption process. It is understood that the premise for ending the current task consumption process when the current target task has no value is that the current target task is an empty task in the lowest priority sub-queue of the initial queue. An empty task is set after the last target task in the retry queue and each sub-queue. When an empty task is detected in a sub-queue that is not the lowest priority in the initial queue, a prompt message is sent to the sub-queue identifier group. This sub-queue identifier group outputs the group identifier of the next priority sub-queue, and the processor accesses the corresponding sub-queue based on this group identifier.
[0054] In this embodiment of the invention, at the start of each task scheduling, the retry queue is first queried to see if there are any target tasks with resource consumption less than the current system's idle resources. This reflects that the priority of the retry queue is higher than the priority of each sub-queue in the initial queue. Target tasks distributed before the tasks to be consumed in the initial queue are added to the retry queue to update it. This achieves the goal of temporarily suspending the execution of target tasks that do not meet resource requirements, preventing system lag or crashes caused by executing target tasks that do not meet resource requirements, and improving the flexibility of task scheduling. If a target task with resource consumption less than the current system's idle resources is found in the initial queue, it is treated as a task to be consumed and executed. This achieves the technical effect that the highest priority target task that meets resource requirements can be consumed in each task scheduling, improving the flexibility and adaptability of task scheduling. Moreover, it ensures that the system can execute tasks to be consumed without pressure, while maximizing the utilization of system resources. This achieves the technical effect of balancing task priority and task consumption speed, and can significantly improve supply chain efficiency.
[0055] Figure 3 This is another flowchart of the task scheduling method provided by an embodiment of the present invention. This embodiment adds a process for determining the initial queue based on the previous embodiments. Figure 3 As shown, the method includes:
[0056] S210. In response to the task consumption signal, query the retry queue for the target task whose resource usage is less than the current system idle resource usage. The target task includes the resource usage.
[0057] S220. If no target task with a resource consumption less than the current system's idle resources is found in the retry queue, then the target task with a resource consumption less than the current system's idle resources is searched in the initial queue in sequence. The initial queue includes at least two sub-queues arranged in a predetermined priority order. Different sub-queues in the initial queue correspond to different task type identifiers.
[0058] The target tasks to be added include: item supplier identifier, logistics node identifier, transportation information task identifier, resource usage information, etc. The item supplier identifier includes a task type identifier. For example, the item supplier identifier includes a task type identifier (such as a merchant type identifier) and a task supplier code.
[0059] Once the target task to be added is determined, it is added to the target sub-queue in the initial queue according to its task type identifier. The task type identifier of the target sub-queue is the same as that of the target task. In other words, target tasks in different sub-queues of the initial queue have different task type identifiers, while all target tasks in the same sub-queue have the same task type identifier. The initial queue prioritizes target tasks of different task types by sorting the priority of the different sub-queues.
[0060] Within the same sub-queue, the priority order of target tasks is the same as the order in which they were generated. By considering both task generation time and task type identifier to determine target task priority, the flexibility of target task priority determination is improved, thereby enhancing the flexibility of task scheduling.
[0061] In one embodiment, each sub-queue in the initial queue corresponds to a task group, and each sub-queue is assigned a corresponding identifier, which can be called a group identifier. Each sub-queue is assigned a group name, which can be set as a task type identifier. Each sub-queue corresponds to a group sort, such as 1, 2, etc. This group sort is the priority sorting among the sub-queues. The character length of the group identifier can be less than or equal to 50 characters, the character length of the group name can be less than or equal to 255 characters, and the character length of the group sort can be less than or equal to 5 characters.
[0062] Each sub-queue corresponds to a task type identifier, which includes 0 or more item acquisition tasks from item suppliers under that task type identifier. Each item supplier can have 0 or more item acquisition tasks. Each item supplier is configured with a unique item supplier identifier, which includes the task type identifier, and its character length can be less than or equal to 255 characters.
[0063] In one embodiment, information such as the group identifier, group name, and group order of sub-queues can be entered through a form on the UI page of a web system. The group identifier is generated by a UUID. UUID is an abbreviation for Universally Unique Identifier, a software construction standard and part of the Open Software Foundation in the field of distributed computing environments. Its purpose is to provide all elements in a distributed system with unique identification information without requiring a central control point to assign identification information.
[0064] Specifically, the UI page includes options for group identifier, group precedence, and task type identifier. When adding a new sub-queue to the initial queue, the user needs to fill in a predetermined task type identifier in the task type identifier option, then generate a group identifier for the sub-queue based on the UUID, and then fill in the group precedence in the group precedence option on the aforementioned UI page. The group precedence is the group identifier of the sub-queue with the expected priority one level lower than the newly added task combination. It can be understood that if the expected priority of the newly added sub-queue is 2, then its group precedence is 1; if the expected priority of the newly added sub-queue is 1, then its group precedence can be empty.
[0065] The processor obtains the task type identifier, group identifier, and group precedence. It uses the task type identifier as the task type identifier for the sub-queue to be added, and the group identifier as the group identifier for the sub-queue. The sub-queue to be added is then added to the initial queue after the sub-queue preceding the group, and the initial queue is updated. After the priorities of each sub-queue are determined, each target task is mapped to its corresponding sub-queue in the initial queue based on its task type identifier, thus determining the priorities among the target tasks.
[0066] In one embodiment, the retry queue and the initial queue can be created based on Redis (Remote Dictionary Server), for example, using Redis's LIST type as the queue carrier. Alternatively, they can be created based on MQ (message queue) or Kafka.
[0067] S230. If a target task with a resource consumption amount less than the current system's idle resource amount is found in the initial queue, then the target task is treated as a task to be consumed, and the target tasks distributed before the tasks to be consumed in the initial queue are added to the retry queue in order to update the retry queue.
[0068] S240, Execute the task to be consumed.
[0069] Compared to the first-in-first-out (FIFO) principle of existing technologies, this invention, by setting at least two sub-queues arranged in a predetermined priority order in the initial queue, and using different sub-queues to store target tasks of different task types, limits the priority and dequeue timing of target tasks of different task types, thereby achieving the technical effect of controlling the dequeue order of target tasks.
[0070] The following are embodiments of the task scheduling device provided in this invention. This device and the task scheduling method described in the above embodiments belong to the same inventive concept. For details not described in detail in the embodiments of the task scheduling device, please refer to the contents of the above embodiments.
[0071] Figure 4 This is a schematic diagram of the structure of a task scheduling device provided in an embodiment of the present invention. Figure 4 As shown, the device includes:
[0072] Response module 310 is used to respond to a task consumption signal by sequentially querying the retry queue for target tasks whose resource usage is less than the current system idle resource amount, wherein the target task includes the resource usage.
[0073] The first module 320 is used to sequentially query the initial queue for target tasks whose resource usage is less than the current system idle resource amount if no target task with resource usage is found in the retry queue.
[0074] The second module 330 is used to, if a target task with a resource occupancy less than the current system idle resource amount is found in the initial queue, then treat the target task as a task to be consumed, and add the target tasks in the initial queue before the task to be consumed to the retry queue in order to update the retry queue.
[0075] The consumption module 340 is used to execute the task to be consumed.
[0076] In one embodiment, the first module is further configured to:
[0077] If a target task with a resource consumption amount less than the current system's idle resource amount is found in the retry queue, then that target task is designated as the task to be consumed.
[0078] In one embodiment, the second module is specifically used for:
[0079] The first target task in the initial queue is taken as the current target task;
[0080] Determine whether the resource consumption of the current target task is less than the current system idle resource quantity;
[0081] If the resource consumption of the current target task is less than the current system idle resources, then the current target task will be designated as a task to be consumed.
[0082] If the resource usage of the current target task is greater than or equal to the current system idle resource amount, then the target task is added to the retry queue to update the retry queue, the next target task is taken as the current target task, and the system returns to determine whether the resource usage of the current target task is less than the current system idle resource amount, until the current target task is the task to be consumed or the current target task is null.
[0083] In one embodiment, the initial queue includes at least two sub-queues arranged in a predetermined priority order;
[0084] The different sub-queues in the initial queue correspond to different task type identifiers.
[0085] In one embodiment, the target task includes a task type identifier, such as... Figure 5 As shown, the device also includes a task adding module 300, which is used for:
[0086] Based on the task type identifier in the target task to be added, the target task to be added is added to the target sub-queue in the initial queue, and the task type identifier corresponding to the target sub-queue is the same as the task type identifier in the target task to be added.
[0087] In one embodiment, the resource usage includes memory resource usage, or includes both memory resource usage and CPU resource usage.
[0088] In this embodiment of the invention, at the start of each task scheduling, the retry queue is first queried to see if there are any target tasks with resource consumption less than the current system's idle resources. This reflects that the priority of the retry queue is higher than the priority of each sub-queue in the initial queue. Target tasks distributed before the tasks to be consumed in the initial queue are added to the retry queue to update it. This achieves the goal of temporarily suspending the execution of target tasks that do not meet resource requirements, preventing system lag or crashes caused by executing target tasks that do not meet resource requirements, and improving the flexibility of task scheduling. If a target task with resource consumption less than the current system's idle resources is found in the initial queue, it is treated as a task to be consumed and executed. This achieves the technical effect that the highest priority target task that meets resource requirements can be consumed in each task scheduling, improving the flexibility and adaptability of task scheduling. Moreover, it ensures that the system can execute tasks to be consumed without pressure, while maximizing the utilization of system resources. This achieves the technical effect of balancing task priority and task consumption speed, and can significantly improve supply chain efficiency.
[0089] The resource scheduling device provided in this embodiment of the invention can execute the resource scheduling method provided in this embodiment of the invention, and has the corresponding functional modules and beneficial effects of executing the resource scheduling method.
[0090] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Figure 6 A block diagram of an exemplary server 12 suitable for implementing embodiments of the present invention is shown. Figure 6 The server 12 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.
[0091] like Figure 6 As shown, server 12 is presented as a general-purpose computing device. The components of server 12 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and bus 18 connecting different system components (including system memory 28 and processing unit 16).
[0092] Bus 18 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. For example, these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.
[0093] Server 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by server 12, including volatile and non-volatile media, removable and non-removable media.
[0094] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Server 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media (… Figure 6 Not shown; usually referred to as a "hard drive"). Although Figure 6 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. System memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of the present invention.
[0095] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods described in the embodiments of the present invention.
[0096] Server 12 can also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), and with one or more devices that enable users to interact with server 12, and / or with any device that enables server 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 22. Furthermore, server 12 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with other modules of server 12 via bus 18. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with server 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0097] Processing unit 16 executes various functional applications and data processing by running programs stored in system memory 28, such as implementing the task scheduling method steps provided in this embodiment, which includes:
[0098] In response to a task consumption signal, the system sequentially queries the retry queue for target tasks whose resource usage is less than the current system's available resources. The target task includes the resource usage.
[0099] If no target task with a resource consumption less than the current system idle resource amount is found in the retry queue, then the target task with a resource consumption less than the current system idle resource amount is sequentially queried in the initial queue.
[0100] If a target task with a resource consumption amount less than the current system idle resource amount is found in the initial queue, then the target task is designated as a task to be consumed, and the target tasks distributed before the task to be consumed in the initial queue are added sequentially to the retry queue to update the retry queue.
[0101] Execute the task to be consumed.
[0102] Of course, those skilled in the art will understand that the processor can also implement the technical solution of the task skipping method provided in any embodiment of the present invention.
[0103] This embodiment provides a computer-readable storage medium storing a computer program thereon. When executed by a processor, the program implements the resource scheduling method steps provided in the foregoing embodiments of the present invention. The method includes:
[0104] In response to a task consumption signal, the system sequentially queries the retry queue for target tasks whose resource usage is less than the current system's available resources. The target task includes the resource usage.
[0105] If no target task with a resource consumption less than the current system idle resource amount is found in the retry queue, then the target task with a resource consumption less than the current system idle resource amount is sequentially queried in the initial queue.
[0106] If a target task with a resource consumption amount less than the current system idle resource amount is found in the initial queue, then the target task is designated as a task to be consumed, and the target tasks distributed before the task to be consumed in the initial queue are added sequentially to the retry queue to update the retry queue.
[0107] Execute the task to be consumed.
[0108] The computer storage medium of this invention can be any combination of one or more computer-readable media. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. For example, a computer-readable storage medium can be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0109] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.
[0110] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0111] Computer program code for performing the operations of this invention can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages—such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0112] Those skilled in the art will understand that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby allowing them to be stored in a storage device for execution by a computing device, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0113] This invention also provides a computer program product, including a computer program that, when executed by a processor, implements the task scheduling method provided in any embodiment of this application.
[0114] In implementing the computer program product, computer program code for performing the operations of this invention can be written in one or more programming languages or a combination thereof. Programming languages include object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0115] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.
Claims
1. A task scheduling method, characterized in that, The method includes: In response to a task consumption signal, the system sequentially queries the retry queue for target tasks whose resource usage is less than the current system's available resources. The target task includes the resource usage. If no target task with a resource consumption less than the current system idle resource amount is found in the retry queue, then the target task with a resource consumption less than the current system idle resource amount is sequentially queried in the initial queue. If a target task with a resource consumption amount less than the current system idle resource amount is found in the initial queue, then the target task is designated as a task to be consumed, and the target tasks distributed before the task to be consumed in the initial queue are added sequentially to the retry queue to update the retry queue. Execute the task to be consumed.
2. The method according to claim 1, characterized in that, After sequentially querying the retry queue for target tasks whose resource usage is less than the current system's available resources, the process further includes: If a target task with a resource consumption amount less than the current system's idle resource amount is found in the retry queue, then that target task is designated as the task to be consumed.
3. The method according to claim 1, characterized in that, If a target task with a resource consumption less than the current system's idle resource amount is found in the initial queue, then that target task is designated as a task to be consumed, and the target tasks distributed before the task to be consumed in the initial queue are sequentially added to the retry queue to update the retry queue, including: The first target task in the initial queue is taken as the current target task; Determine whether the resource consumption of the current target task is less than the current system idle resource quantity; If the resource consumption of the current target task is less than the current system idle resources, then the current target task will be designated as a task to be consumed. If the resource usage of the current target task is greater than or equal to the current system idle resource amount, then the target task is added to the retry queue to update the retry queue, the next target task is taken as the current target task, and the system returns to determine whether the resource usage of the current target task is less than the current system idle resource amount, until the current target task is the task to be consumed or the current target task is null.
4. The method according to claim 1, characterized in that, The initial queue includes at least two sub-queues arranged in a predetermined priority order; The different sub-queues in the initial queue correspond to different task type identifiers.
5. The method according to claim 4, characterized in that, The target task includes a task type identifier. The target task to be added is added to the corresponding sub-queue through the following steps: Based on the task type identifier in the target task to be added, the target task to be added is added to the target sub-queue in the initial queue, and the task type identifier corresponding to the target sub-queue is the same as the task type identifier in the target task to be added.
6. The method according to claim 4, characterized in that, The priority order of each target task in the sub-queue is the order in which the tasks were generated.
7. The method according to claim 1, characterized in that, The resource usage includes memory resource usage, and the system idle resource usage includes system idle memory resource usage; or The resource usage includes the memory resource usage and CPU resource usage; the system idle resource usage includes the system idle memory resource usage and the system idle CPU resource usage.
8. A task scheduling device, characterized in that, The device includes: The response module is used to respond to the task consumption signal by sequentially querying the retry queue for target tasks whose resource consumption is less than the current system idle resource amount, wherein the target task includes the resource consumption. The first module is used to sequentially query the initial queue for target tasks whose resource usage is less than the current system idle resource amount if no target task with resource usage is found in the retry queue. The second module is used to, if a target task with a resource occupancy less than the current system idle resource amount is found in the initial queue, then treat the target task as a task to be consumed, and add the target tasks in the initial queue before the task to be consumed to the retry queue in order to update the retry queue. The consumption module is used to execute the task to be consumed.
9. An electronic device, characterized in that, The electronic device includes: One or more processors; Memory, used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the task scheduling method as described in any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the task scheduling method as described in any one of claims 1-7.
11. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the task scheduling method according to any one of claims 1-7.