Task scheduling device and method, storage medium and equipment
By obtaining the earliest expected start time of the task scheduling queue, tasks can be executed or deleted in a timely manner, thus solving the problem of task delays affecting system stability and achieving real-time and stable task scheduling.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING HORIZON INFORMATION TECH CO LTD
- Filing Date
- 2026-02-03
- Publication Date
- 2026-05-19
AI Technical Summary
In terminal devices or on-chip systems, existing technologies struggle to effectively schedule critical tasks, leading to task delays that affect the real-time performance of overall data processing tasks, thereby impacting system stability and security.
By obtaining the earliest expected start time of the task scheduling queue, and responding to the relationship between the current time and the earliest expected start time, tasks are executed or deleted in a timely manner, and timeout exception information is generated to ensure the real-time performance and stability of task scheduling.
This improves the real-time performance of task scheduling, avoids the impact of task delays, and ensures the stability and security of the system.
Smart Images

Figure CN122064447A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to computer technology, and in particular to a task scheduling apparatus, method, storage medium, and device. Background Technology
[0002] In terminal devices or Systems on Chips (SoCs), there are often certain requirements for the real-time performance of data processing tasks. For example, some critical tasks are expected to be completed before a specific deadline. If they cannot be completed before the deadline, it can easily affect the execution of other tasks, thereby affecting the real-time performance of the overall data processing tasks and adversely impacting the stable and secure operation of the entire system. Therefore, how to effectively schedule anticipated critical tasks has become an urgent technical problem to be solved. Summary of the Invention
[0003] The embodiments of this disclosure provide a task scheduling apparatus, method, storage medium, and device that can improve the real-time performance of task execution, thereby enhancing the security and stability of the overall system operation.
[0004] A first aspect of this disclosure provides a task scheduling apparatus, comprising: obtaining the earliest expected start time corresponding to a task scheduling queue; the earliest expected start time being determined based on the expected start time of tasks in the task scheduling queue; in response to a task timeout condition being met by the relationship between the current time and the earliest expected start time, deleting a first task corresponding to the earliest expected start time from the task scheduling queue and generating timeout exception information for the first task; or, in response to a task triggering condition being met by the relationship between the current time and the earliest expected start time, executing the first task.
[0005] A second aspect of this disclosure provides a task scheduling method, comprising: obtaining the earliest expected start time corresponding to a task scheduling queue; the earliest expected start time being determined based on the expected start time of tasks in the task scheduling queue; in response to the current time and the earliest expected start time satisfying a task timeout condition, deleting a first task corresponding to the earliest expected start time from the task scheduling queue and generating timeout exception information for the first task; or, in response to the current time and the earliest expected start time satisfying a task triggering condition, executing the first task.
[0006] A third aspect of this disclosure is to provide a computer-readable storage medium storing a computer program that is executed by a processor to perform the task scheduling method described in any of the above embodiments of this disclosure.
[0007] A fourth aspect of this disclosure provides an electronic device, the electronic device comprising: a processor; a memory for storing executable instructions of the processor; the processor being configured to read the executable instructions from the memory, the processor executing the executable instructions to implement the task scheduling method described in any of the above embodiments of this disclosure.
[0008] A fifth aspect of this disclosure provides a computer program product that, when instructions in the computer program product are executed by a processor, performs the task scheduling method provided in any of the above embodiments of this disclosure.
[0009] The task scheduling apparatus, method, storage medium, and device provided in the above embodiments of this disclosure can obtain the earliest expected start time of the task scheduling queue. When the relationship between the current time and the earliest expected start time satisfies the task triggering condition, the first task can be executed in a timely manner, ensuring the real-time performance of the first task. Furthermore, when the relationship between the current time and the earliest expected start time satisfies the task timeout condition, the first task that cannot be executed at the expected time can be promptly removed from the task scheduling queue, avoiding impact on the execution of other tasks in the task scheduling queue. Timeout exception information for the first task can also be generated promptly, enabling the on-chip system or electronic device where the task scheduling apparatus resides to detect and resolve exceptions in a timely manner, further ensuring the real-time performance of the expected tasks and effectively improving the stability and security of the on-chip system or electronic device. Attached Figure Description
[0010] Figure 1 This is an exemplary application scenario of the task scheduling device provided in this disclosure; Figure 2 This is a schematic diagram of the structure of a task scheduling apparatus provided in an exemplary embodiment of the present disclosure; Figure 3 This is a schematic diagram of the structure of a task scheduling apparatus provided in another exemplary embodiment of the present disclosure; Figure 4 This is a schematic diagram of the structure of a processor provided in an exemplary embodiment of this disclosure; Figure 5 This is a flowchart illustrating a task scheduling method provided in an exemplary embodiment of this disclosure; Figure 6 This is a flowchart illustrating a task scheduling method provided in another exemplary embodiment of this disclosure; Figure 7 This is a flowchart illustrating a task scheduling method provided in yet another exemplary embodiment of this disclosure; Figure 8 This is a flowchart illustrating a task scheduling method provided in yet another exemplary embodiment of this disclosure; Figure 9This is a flowchart illustrating a task scheduling method provided in yet another exemplary embodiment of this disclosure; Figure 10 This is a structural diagram of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0011] To explain this disclosure, exemplary embodiments of the disclosure will now be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the disclosure, and not all of them. It should be understood that the disclosure is not limited to exemplary embodiments.
[0012] It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of this disclosure.
[0013] This disclosure outlines In terminal devices or on-chip systems, there are usually certain requirements for the real-time performance of data processing tasks. For example, it is expected that certain critical tasks can be completed before a specific deadline. If they cannot be completed before the deadline, it will easily affect the execution of other tasks, thereby affecting the real-time performance of the overall data processing tasks and adversely affecting the stable and secure operation of the overall system.
[0014] In related technologies, various data processing tasks are typically scheduled by the CPU (Central Processing Unit) of the terminal device or system-on-a-chip based on pre-configured task scheduling rules. For example, the task scheduling rules might calculate the latest start time based on the task's deadline and schedule tasks according to that latest start time. However, if a task cannot be executed by the latest start time, it can easily lead to task execution delays, affecting the execution of other tasks and consequently impacting the task's real-time performance.
[0015] For example, in intelligent driving scenarios, during operation, the on-board terminal or its on-chip system schedules various data processing tasks based on pre-configured task scheduling rules. These tasks include, but are not limited to, computational tasks related to one or more neural network models and other tasks related to intelligent driving functions. Neural network models include, but are not limited to, object detection models, semantic segmentation models, and trajectory prediction models. Intelligent driving scenarios place high demands on the real-time performance of various tasks. If task scheduling is based on the latest start time, and a task cannot be executed when the latest start time arrives, it could affect the execution of other tasks and potentially severely impact the driving safety of the intelligent driving vehicle.
[0016] Exemplary Overview Figure 1 This is an exemplary application scenario of the task scheduling device provided in this disclosure. For example... Figure 1 As shown, in terminal devices such as vehicle terminals, mobile phones, tablets, wearable devices, and embody intelligent agents, the relevant functions of the terminal devices are mainly implemented through the System-on-Chip 10. The System-on-Chip 10 may include a task scheduling device 11 and one or more computing elements 12. The task scheduling device 11 can write the tasks to be scheduled into a task scheduling queue, and schedule the computing elements 12 to execute the tasks based on the task scheduling queue. The computing elements 12 include, but are not limited to, one or more of the following types of computing elements: Central Processing Unit (CPU), Neural Network Processing Unit (NPU), Graphics Processing Unit (GPU), Accelerator Control Unit (ACU), Vector Processing Unit (VPU), Scalar Processing Unit (SPU), Digital Signal Processor (DSP), and others.
[0017] The task scheduling device 11 can obtain the earliest expected start time of the task scheduling queue. The earliest expected start time is determined based on the expected start time of the tasks in the task scheduling queue. In response to the relationship between the current time and the earliest expected start time satisfying the task timeout condition, the first task corresponding to the earliest expected start time is deleted from the task scheduling queue, and timeout exception information of the first task is generated. Alternatively, in response to the relationship between the current time and the earliest expected start time satisfying the task triggering condition, the first task is executed.
[0018] This disclosure enables timely scheduling of computing elements to execute the first task when the relationship between the current time and the earliest expected start time meets the task triggering condition, ensuring the real-time performance of the first task. Furthermore, when the relationship between the current time and the earliest expected start time meets the task timeout condition, it can promptly remove the first task, which cannot be executed at the expected time, from the task scheduling queue, avoiding impact on the execution of other tasks in the queue. It can also promptly generate timeout exception information for the first task, allowing the on-chip system 10, where the task scheduling device resides, to promptly detect and resolve anomalies, further ensuring the real-time performance of the expected task and thereby improving the overall security and stability of the on-chip system.
[0019] Exemplary device Figure 2This is a schematic diagram of the structure of a task scheduling device provided in an exemplary embodiment of this disclosure. The task scheduling device provided in this embodiment is, for example, but not limited to, an electronic device, a system-on-a-chip (SoC), or hardware applied to an electronic device or SoC. The electronic device includes, for example, but not limited to, an in-vehicle computing platform (or in-vehicle terminal), an embodied intelligent agent, a mobile phone, a tablet, a wearable device, etc. The SoC includes, for example, but not limited to, an intelligent driving SoC, an intelligent cockpit SoC, a cockpit-driver integrated SoC, etc., such as... Figure 2 As shown, the task scheduling device 20 of this embodiment may include a processor 21. The processor 21 is configured to: Obtain the earliest expected start time corresponding to the task scheduling queue; the earliest expected start time is determined based on the expected start time of the tasks in the task scheduling queue; in response to the relationship between the current time and the earliest expected start time satisfying the task timeout condition, delete the first task corresponding to the earliest expected start time from the task scheduling queue and generate timeout exception information for the first task; or, in response to the relationship between the current time and the earliest expected start time satisfying the task triggering condition, execute the first task.
[0020] The processor 21 includes, for example, but not limited to, one or more of a central processing unit and other processors.
[0021] A task scheduling queue is a buffer used to manage tasks to be scheduled sequentially. Optionally, the task scheduling queue can be a component in processor 21. The earliest expected start time corresponding to the task scheduling queue refers to the expected start time of the task with the earliest expected start time in the task scheduling queue. That is, the earliest expected start time corresponding to the task scheduling queue is dynamically determined based on the expected start times of the tasks in the task scheduling queue. The earliest expected start time can be determined based on the expected start times of each task in the task scheduling queue, and this earliest expected start time can be used as the earliest expected start time corresponding to the task scheduling queue.
[0022] Optionally, the earliest expected start time of the task scheduling queue can be dynamically updated in real time based on the dynamic changes of tasks in the queue. For example, when the task with the earliest expected start time in the queue is executed or deleted, the earliest expected start time is updated to the earliest expected start time of the remaining tasks in the queue. When a new task is added to the queue, if its expected start time is earlier than the earliest expected start time, the earliest expected start time can be updated based on the new task's expected start time. The expected start time of a task can be determined based on its deadline (or expected deadline) and expected execution duration.
[0023] The current time can be the current system time obtained in real time or periodically by the task scheduler. Optionally, the current time can be determined by a clock system or a system timestamp maintained by the operating system. The current time can be obtained in real time or periodically, and it can be determined whether the relationship between the current time and the earliest expected start time satisfies the task triggering condition or the task timeout condition.
[0024] Task triggering conditions refer to the conditions that determine whether the task needs to be executed at the current time. Task triggering conditions include, but are not limited to, the current time reaching the earliest expected start time, or the current time about to reach the earliest expected start time, for example, the duration of the current time being earlier than the earliest expected start time being less than a preset duration threshold.
[0025] A task timeout condition refers to the condition used to determine whether a task corresponding to the earliest expected start time has timed out and not been executed. Task timeout conditions include, but are not limited to, situations where the current time is later than the earliest expected start time.
[0026] Optionally, if the relationship between the current time and the earliest expected start time satisfies the task triggering condition, then the task corresponding to the earliest expected start time (referred to as the first task) is executed. For example, the first task can be read from the task scheduling queue, transferred to the computing element corresponding to the first task, and executed by the computing element. Optionally, the operation of reading the first task from the task scheduling queue represents the operation of dequeuing the first task. After the first task is dequeued, the task scheduling queue no longer contains the first task, and the earliest expected start time corresponding to the task scheduling queue needs to be updated to the earliest expected start time of the remaining tasks in the task scheduling queue.
[0027] Optionally, if the relationship between the current time and the earliest expected start time satisfies the task timeout condition, indicating that the first task has timed out, to prevent the first task from affecting the real-time performance of other tasks in the task scheduling queue, the first task is removed from the task scheduling queue, and a timeout exception message for the first task is generated. The timeout exception message indicates that the first task has timed out. The timeout exception message may include, but is not limited to, the task identifier of the first task and information indicating that it has timed out.
[0028] In some optional embodiments, tasks in the task scheduling queue can be arranged in chronological order of their expected start times, so that the task with the earliest expected start time is always at the head of the queue. This makes it easy to quickly retrieve the first task from the task scheduling queue when it is triggered to execute, and to quickly delete the first task from the task scheduling queue when it needs to be deleted.
[0029] The task scheduling device provided in this embodiment can obtain the earliest expected start time of the task scheduling queue. When the relationship between the current time and the earliest expected start time meets the task triggering condition, it can execute the first task in a timely manner, ensuring the real-time performance of the first task. Furthermore, when the relationship between the current time and the earliest expected start time meets the task timeout condition, it can promptly remove the first task, which cannot be executed at the expected time, from the task scheduling queue, avoiding impacting the execution of other tasks in the queue. It can also promptly generate timeout exception information for the first task, enabling the on-chip system or electronic device where the task scheduling device resides to detect and resolve the exception promptly, further ensuring the real-time performance of the expected tasks and effectively improving the stability and security of the on-chip system or electronic device.
[0030] Figure 3 This is a schematic diagram of the structure of a task scheduling apparatus provided in another exemplary embodiment of the present disclosure.
[0031] In some alternative embodiments, based on any of the above embodiments, such as Figure 3 As shown, the apparatus 20 in this embodiment may further include: a first storage unit 22, coupled to the processor 21, configured to store the earliest expected start time of the task scheduling queue.
[0032] The processor 21 is specifically configured as follows: Obtain the earliest expected start time of the task scheduling queue from the first storage unit 22.
[0033] The first storage unit 22 is, for example, but not limited to, a memory or a register. The first storage unit 22 stores the earliest expected start time corresponding to the task scheduling queue. The processor 21 can maintain the earliest expected start time stored in the first storage unit 22 in real time. During task scheduling, the processor 21 obtains the earliest expected start time corresponding to the task scheduling queue from the first storage unit 22, and then, based on the relationship between the current time and the earliest expected start time, determines whether the current time meets the task triggering condition or the task timeout condition.
[0034] In the embodiments of this disclosure, the earliest expected start time corresponding to the task scheduling queue is stored in the first storage unit, which facilitates the processor to maintain and obtain the earliest expected start time in real time, and provides the processor with an effective earliest expected start time for task scheduling.
[0035] In some optional embodiments, based on any of the above embodiments, the task scheduling queue includes multiple task scheduling sub-queues with corresponding priorities.
[0036] Obtaining the earliest expected start time corresponding to the task scheduling queue includes: for any first task scheduling sub-queue among multiple task scheduling sub-queues, obtaining the earliest expected start time corresponding to the first task scheduling sub-queue from the first storage unit 22 that stores the earliest expected start time.
[0037] In response to the relationship between the current time and the earliest expected start time satisfying the task timeout condition, the first task corresponding to the earliest expected start time is removed from the task scheduling queue, and timeout exception information for the first task is generated. This includes: for the first task scheduling sub-queue in multiple task scheduling sub-queues, in response to the relationship between the current time and the earliest expected start time corresponding to the first task scheduling sub-queue satisfying the task timeout condition, the first task corresponding to the earliest expected start time in the first task scheduling sub-queue is removed from the first task scheduling sub-queue, and timeout exception information for the first task is generated.
[0038] Priority refers to the ranking of tasks based on their importance and urgency. The number of priority levels can be set according to actual needs; for example, but not limited to, two, three, or four priorities. Each priority level corresponds to a task scheduling sub-queue. For example, multiple priorities may include priority 1, priority 2, and priority 3, where priority 1 is higher than priority 2, and priority 2 is higher than priority 3. The task scheduling queues include task scheduling sub-queue A corresponding to priority 1, task scheduling sub-queue B corresponding to priority 2, and task scheduling sub-queue C corresponding to priority 3. For each task scheduling sub-queue, the earliest expected start time can be maintained. Optionally, the earliest expected start time corresponding to each task scheduling sub-queue can be stored in the first storage unit 22.
[0039] Optionally, during task scheduling, the processor 21 can use any one of the multiple task scheduling sub-queues as the first task scheduling sub-queue and retrieve the earliest expected start time corresponding to the first task scheduling sub-queue from the first storage unit 22. If the relationship between the current time and the earliest expected start time corresponding to the first task scheduling sub-queue satisfies the task timeout condition, the first task corresponding to the earliest expected start time in the first task scheduling sub-queue is deleted from the first task scheduling sub-queue, and timeout exception information for the first task is generated to avoid the first task affecting the execution of other tasks in the first task scheduling sub-queue and ensure the real-time performance of the tasks.
[0040] Optionally, the processor 21 can use each of the multiple task scheduling sub-queues as the first task scheduling sub-queue, and retrieve the earliest expected start time corresponding to the first task scheduling sub-queue from the first storage unit 22. If the relationship between the current time and the earliest expected start time corresponding to the first task scheduling sub-queue satisfies the task timeout condition, the first task corresponding to the earliest expected start time in the first task scheduling sub-queue is deleted from the first task scheduling sub-queue, and timeout exception information for the first task is generated.
[0041] In some optional embodiments, the processor 21 may also be configured to: in response to the relationship between the current time and the earliest expected start time corresponding to the first task scheduling sub-queue satisfying the task triggering condition, execute the first task in the first task scheduling sub-queue corresponding to the earliest expected start time. Alternatively, determine whether to execute the first task in the first task scheduling sub-queue corresponding to the earliest expected start time based on the priority of the first task scheduling sub-queue and the priorities of multiple second task scheduling sub-queues other than the first task scheduling sub-queue. If there is at least one second task scheduling sub-queue with a higher priority than the first task scheduling sub-queue, and there are tasks in the second task scheduling sub-queue that satisfy the task triggering condition, then the tasks in the second task scheduling sub-queue that satisfy the task triggering condition should be executed first, and the first task in the first task scheduling sub-queue will not be executed temporarily. If the high-priority tasks in the second task scheduling sub-queue have been completed before the first task has timed out, then the first task will be executed. If the first task times out during the execution of the high-priority tasks in the second task scheduling sub-queue, then the first task will be deleted from the first task scheduling sub-queue, and timeout exception information for the first task will be generated.
[0042] In the embodiments of this disclosure, for multiple task scheduling sub-queues corresponding to different priorities, the system can monitor whether tasks in each task scheduling sub-queue have timed out based on the relationship between the current time and the earliest expected start time of each task scheduling sub-queue. Tasks that have timed out and not yet executed are promptly removed from the task scheduling sub-queues to avoid affecting the execution of other tasks in the task scheduling sub-queues. This ensures that other tasks can execute their relevant tasks according to their expected start time, thereby improving the real-time performance of the overall tasks in the on-chip system or electronic device. Furthermore, it can promptly generate timeout exception information for the first task to facilitate timely resolution of exceptions and improve the security and stability of the on-chip system or electronic device.
[0043] In some optional embodiments, based on any of the above embodiments, after obtaining the earliest expected start time corresponding to the task scheduling queue, the processor 21 is further configured to: The current time is compared with the earliest expected start time to obtain a comparison result; in response to the comparison result indicating that the current time is later than the earliest expected start time, it is determined that the relationship between the current time and the earliest expected start time satisfies the task timeout condition; or, in response to the comparison result indicating that the current time is not later than the earliest expected start time and the interval between the current time and the earliest expected start time is less than a preset duration threshold, it is determined that the relationship between the current time and the earliest expected start time satisfies the task triggering condition.
[0044] The comparison result can include one of the following: the current time is earlier than the earliest expected start time, the current time is equal to the earliest expected start time, or the current time is later than the earliest expected start time. If the current time is later than the earliest expected start time, it means that the first task corresponding to the earliest expected start time has timed out and has not been executed, thus determining that the relationship between the current time and the earliest expected start time satisfies the task timeout condition. Optionally, the current time can be compared with the earliest expected start time in real time to obtain the comparison result, thereby achieving the purpose of real-time monitoring of tasks in the task scheduling queue, timely execution of tasks, or deletion of tasks.
[0045] In some optional embodiments, if the current time is the same as (or identical to) the earliest expected start time, it can be determined that the relationship between the current time and the earliest expected start time satisfies the task triggering condition; if the current time is earlier than the earliest expected start time, the interval between the current time and the earliest expected start time can be determined; if the interval is less than a preset duration threshold, it indicates that the current time has reached or is close to the earliest expected start time, and it is determined that the relationship between the current time and the earliest expected start time satisfies the task triggering condition. The preset duration threshold can be set according to actual needs.
[0046] In the embodiments of this disclosure, by comparing the current time with the earliest expected start time, and determining whether the relationship between the current time and the earliest expected start time satisfies the task triggering condition or the task timeout condition based on the comparison result, an effective reference can be provided for timely triggering of task execution or deletion of timeout tasks.
[0047] In some optional embodiments, based on any of the above embodiments, in response to the relationship between the current time and the earliest expected start time satisfying the task triggering condition, a first task is executed, including: In response to the relationship between the current time and the earliest expected start time satisfying the task triggering conditions, a task scheduling reminder message is generated; the task triggering conditions include that the current time is not later than the earliest expected start time, and the interval between the current time and the earliest expected start time is less than a preset duration threshold; in response to the task scheduling reminder message, the first task is read from the task scheduling queue; the computing element corresponding to the first task is scheduled to execute the first task.
[0048] The task scheduling reminder information is information indicating that a task in the task scheduling queue has reached its scheduled execution time. Optionally, the task scheduling reminder information may include indication information for task scheduling. Alternatively, the task scheduling information may include the task identifier of the first task corresponding to the earliest expected start time and the indication information for task scheduling. The processor 21 generates the task scheduling reminder information in response to the relationship between the current time and the earliest expected start time satisfying the task triggering condition.
[0049] In response to the task scheduling reminder information, the processor 21 can read the first task corresponding to the earliest expected start time from the task scheduling queue and schedule the computing element corresponding to the first task to execute the first task.
[0050] In some optional embodiments, when the task scheduling queue arranges tasks according to their expected start times, the processor 21 may read a task from the head of the task scheduling queue in response to a task scheduling reminder message. This task is the first task corresponding to the earliest expected start time.
[0051] In some optional embodiments, if the task scheduling reminder information includes a task identifier, the processor 21 can read the first task from the task scheduling queue based on the task identifier.
[0052] In some optional embodiments, the computing element corresponding to the first task can be determined based on the first task. For example, the first task may include a component identifier of the computing element to be executed. Based on the component identifier in the first task, the computing element corresponding to the first task is determined, and then the computing element corresponding to the first task is scheduled to execute the first task. For example, the first task is sent to the computing element corresponding to the first task, and the computing element is controlled to execute the first task. For example, if the first task is an addition calculation task, the computing element corresponding to the first task can be scheduled to execute the addition calculation task to obtain the execution result of the first task. Optionally, the computing element is, for example, but not limited to, a CPU, GPU, NPU, ACU, SPU, DSP, etc. Optionally, the processor 21 can also determine the computing element corresponding to the first task based on a pre-configured correspondence between tasks and computing elements. The specific method of determining the computing element corresponding to the first task is not limited.
[0053] In the embodiments of this disclosure, the processor generates task scheduling reminder information in response to the relationship between the current time and the earliest expected start time satisfying the task triggering condition. The task scheduling reminder information promptly triggers the reading of the first task from the task scheduling queue, and then schedules the computing element corresponding to the first task to execute the first task, thereby ensuring the real-time performance of the first task.
[0054] In some optional embodiments, the task scheduling queue includes multiple task scheduling sub-queues with corresponding priorities. The multiple task scheduling sub-queues with corresponding priorities can be referred to in the foregoing embodiments, and will not be repeated here.
[0055] In response to the task scheduling notification, read the first task from the task scheduling queue, including: In response to task scheduling reminders, based on the priorities of multiple task scheduling sub-queues, the highest priority target task scheduling sub-queue is determined from the task scheduling sub-queues with pending tasks. The task with the earliest expected start time is read from the target task scheduling sub-queue and taken as the first task.
[0056] When a task scheduling reminder is received, it indicates that there are tasks to be executed in the task scheduling queue. Based on the priorities of the multiple task scheduling sub-queues, the task scheduling sub-queue with the highest priority is determined from the task scheduling sub-queues with pending tasks. This determined task scheduling sub-queue with the highest priority is taken as the target task scheduling sub-queue. The task with the earliest expected start time is read from the target task scheduling sub-queue and taken as the first task.
[0057] Optionally, task scheduling subqueues can be checked from highest to lowest priority. If a task scheduling subqueue with pending tasks is detected, it is designated as the target task scheduling subqueue. For example, multiple priorities include priority 1, priority 2, and priority 3. The task scheduling queues include task scheduling subqueue A corresponding to priority 1, task scheduling subqueue B corresponding to priority 2, and task scheduling subqueue C corresponding to priority 3. Priority 1 is higher than priority 2, and priority 2 is higher than priority 3. Therefore, task scheduling subqueue A is checked first. If there are pending tasks in task scheduling subqueue A, it is designated as the target task scheduling subqueue. If there are no pending tasks in task scheduling subqueue A, task scheduling subqueue B is checked next. If there are pending tasks in task scheduling subqueue B, it is designated as the target task scheduling subqueue, and so on, until the target task scheduling subqueue is determined from multiple task scheduling subqueues.
[0058] In the embodiments of this disclosure, for multiple task scheduling sub-queues corresponding to different priorities, when the processor receives task scheduling reminder information, it determines the target task scheduling sub-queue with the highest priority from the task scheduling sub-queues with pending tasks, based on the priorities corresponding to the multiple task scheduling sub-queues, reads the task with the earliest expected start time from the target task scheduling sub-queue, and takes the read task with the earliest expected start time as the first task, and schedules the computing element corresponding to the first task to execute the first task, ensuring that high-priority tasks can be executed first, and further improving the security and stability of the on-chip system or electronic device.
[0059] In some optional embodiments, based on any of the above embodiments, scheduling the computing element corresponding to the first task to execute the first task includes: Determine the working state of the computing element corresponding to the first task; in response to the computing element being in an idle state, transfer the first task to the computing element; control the computing element to execute the first task.
[0060] The operating state of the computing element indicates whether it is idle. Operating states include, but are not limited to, idle and non-idle states (i.e., running states). If the computing element is in an idle state, it means the computing element can be used to execute the first task, and the first task can be transmitted to the computing element to control its execution. Optionally, the computing element can be controlled to execute the first task according to a pre-configured control method; the specific control method is not limited in this disclosure. If the computing element is in a non-idle state, it means the computing element is currently executing other tasks and cannot execute the first task.
[0061] In the embodiments of this disclosure, by determining the working state of the computing element corresponding to the first task, when the working state of the computing element is idle, the first task is transmitted to the computing element, and the computing element is controlled to execute the first task, so as to ensure that the first task can be executed smoothly and avoid the first task timeout caused by the computing element being in a non-idle state and thus being unable to execute the first task.
[0062] In some alternative embodiments, processor 21 is also configured to: In response to the computing element being in a non-idle state, the first task is removed from the task scheduling queue, and a timeout exception message corresponding to the first task is generated.
[0063] If the computing element corresponding to the first task is in a non-idle state, it means that the computing element is executing other tasks and cannot execute the first task temporarily. The first task can be deleted from the task scheduling queue in a timely manner, and timeout exception information corresponding to the first task can be generated.
[0064] In the embodiments of this disclosure, when the computing element corresponding to the first task is in a non-idle state, the first task is promptly removed from the task scheduling queue to avoid the delay of the first task affecting the execution of other tasks in the task scheduling queue, ensuring that other tasks can be executed at the expected start time, and generating timeout exception information corresponding to the first task to resolve the timeout exception problem in a timely manner, thereby further improving the security and stability of the on-chip system or electronic device.
[0065] In some optional embodiments, based on any of the above embodiments, the task scheduling queue includes multiple task scheduling sub-queues with corresponding priorities.
[0066] In response to the relationship between the current time and the earliest expected start time satisfying the task triggering condition, the first task is executed, including: For any first task scheduling subqueue among multiple task scheduling subqueues, in response to the relationship between the current time and the earliest expected start time corresponding to the first task scheduling subqueue satisfying the task triggering condition, a task scheduling reminder message is generated; in response to the task scheduling reminder message, a target task scheduling subqueue is determined based on the earliest expected start time and priority corresponding to the multiple task scheduling subqueues respectively; the task corresponding to the earliest expected start time in the target task scheduling subqueue is determined as the first task; the computing element corresponding to the first task is scheduled to execute the first task.
[0067] Specifically, for any first task scheduling sub-queue among multiple task scheduling sub-queues, if the relationship between the current time and the earliest expected start time corresponding to the first task scheduling sub-queue satisfies the task triggering condition, the processor 21 can generate task scheduling reminder information. Optionally, the task scheduling reminder information may include indication information indicating task scheduling. In response to the task scheduling reminder information, the processor 21 can determine the task scheduling sub-queue corresponding to the task scheduling reminder information based on the earliest expected start time and the current time corresponding to each of the multiple task scheduling sub-queues. The task scheduling sub-queue corresponding to the task scheduling reminder information can be called a candidate task scheduling sub-queue. Combining the priority of each task scheduling sub-queue, it is determined whether the candidate task scheduling sub-queue can be used as the target task scheduling sub-queue. For example, if there is a second task scheduling sub-queue with a higher priority than the candidate task scheduling sub-queue, and the second task scheduling sub-queue contains tasks to be processed or tasks that meet the task triggering condition, then the second task scheduling sub-queue is determined to be the target task scheduling sub-queue. If each task scheduling sub-queue with a higher priority than the candidate task scheduling sub-queue does not contain tasks to be processed or tasks that meet the task triggering condition, then the candidate task scheduling sub-queue is determined to be the target task scheduling sub-queue. Therefore, the target task scheduling sub-queue can be determined based on the earliest expected start time and priority of each of the multiple task scheduling sub-queues. Then, the task with the earliest expected start time in the target task scheduling sub-queue can be designated as the first task; the computing element corresponding to the first task is then scheduled to execute the first task.
[0068] Optionally, each of the multiple task scheduling sub-queues can serve as the first task scheduling sub-queue. In response to the relationship between the current time and the earliest expected start time corresponding to the first task scheduling sub-queue satisfying the task triggering condition, a task scheduling reminder is generated. In response to the task scheduling reminder, a target task scheduling sub-queue is determined based on the earliest expected start time and priority corresponding to the multiple task scheduling sub-queues. The task corresponding to the earliest expected start time in the target task scheduling sub-queue is determined as the first task. The computing element corresponding to the first task is scheduled to execute the first task.
[0069] In the embodiments of this disclosure, when the task scheduling queue includes multiple task scheduling sub-queues with corresponding priorities, for each task scheduling sub-queue, the task scheduling sub-queue is designated as the first task scheduling sub-queue. In response to the relationship between the current time and the earliest expected start time corresponding to the first task scheduling sub-queue satisfying the task triggering condition, a task scheduling reminder is generated. In response to the task scheduling reminder, a target task scheduling sub-queue is determined based on the earliest expected start time and priority corresponding to the multiple task scheduling sub-queues. The task corresponding to the earliest expected start time in the target task scheduling sub-queue is determined as the first task, and then the computing element corresponding to the first task is scheduled to execute the first task. Thus, by combining the earliest expected start time and priority of the multiple task scheduling sub-queues to determine the target task scheduling sub-queue, the priority execution of high-priority tasks can be ensured, further improving the security and stability of the on-chip system or electronic device.
[0070] In some optional embodiments, when the task scheduling queue includes multiple task scheduling sub-queues with corresponding priorities, the task scheduling reminder information may include the priority or sub-queue identifier of the task scheduling sub-queue corresponding to the earliest expected start time that meets the task triggering conditions. The processor 21 may also be configured to: in response to the task scheduling reminder information, determine a target task scheduling sub-queue from the multiple task scheduling sub-queues based on the priority or sub-queue identifier included in the task scheduling reminder information, the priorities corresponding to the multiple task scheduling sub-queues, and the earliest expected execution time corresponding to each task scheduling sub-queue. For example, the priority or sub-queue identifier included in the task scheduling reminder information corresponds to task scheduling sub-queue C. Task scheduling sub-queue C has a lower priority than task scheduling sub-queue B, and task scheduling sub-queue B has a lower priority than task scheduling sub-queue A. Task scheduling sub-queue B contains pending tasks, while task scheduling sub-queue A does not. The task with the earliest expected start time in task scheduling sub-queue B is task b, and the task with the earliest expected start time in task scheduling sub-queue C is task c. Based on the earliest expected start time of task scheduling sub-queue B and task scheduling sub-queue C, it is determined whether the execution of task c in task scheduling sub-queue C will affect the execution of task b in task scheduling sub-queue B. If the execution of task c does not affect the execution of task b, then task scheduling sub-queue C can be designated as the target task scheduling sub-queue, and task c can be designated as the first task. If the execution of task c will affect the execution of task b, then task scheduling sub-queue B can be designated as the target task scheduling sub-queue, and task b can be designated as the first task. Specifically, the determination of whether the execution of task c will affect the execution of task b can be based on the expected start time and expected execution duration of task c, and the expected start time of task b. Alternatively, based on the deadline of task c and the expected start time of task b, determine whether the execution of task c will affect the execution of task b. If, based on the expected start time and duration of task c and the expected start time of task b, it is determined that task c can be completed before the expected start time of task b, then the execution of task c will not affect the execution of task b.
[0071] In this embodiment of the disclosure, the priority or sub-queue identifier included in the task scheduling reminder information, as well as the priority and the earliest expected execution time of each of the multiple task scheduling sub-queues, are combined to determine the target task scheduling sub-queue from the multiple task scheduling sub-queues. Without affecting the execution of tasks in the high-priority task scheduling sub-queues, tasks in the lower-priority task scheduling sub-queues are executed in a timely manner, reducing the timeout of lower-priority tasks and further improving the overall task real-time performance of the system-on-chip or electronic device.
[0072] In some alternative embodiments, based on any of the above embodiments, the processor 21 is further configured to: In response to obtaining the second task information, the expected start time of the second task corresponding to the second task information is determined based on the second task information; based on the expected start time of the second task, the second task is inserted into the task scheduling queue.
[0073] The second task information can be obtained from the processor or main controller used to generate the task, or it can be obtained from a preset application. The processor or main controller used to generate the task is, for example, but not limited to, a central processing unit (CPU). The preset application is, for example, but not limited to, an application that includes a neural network model. The second task information includes, for example, but not limited to, the input information, operation type, output information, expected deadline, and expected execution duration of the second task. The input information includes, for example, but not limited to, the input tensor of the second task or its storage address, size, and data type. The operation type is the type of computation task that the second task needs to complete. The operation type includes, for example, but not limited to, addition, matrix multiplication, and convolution. The output information includes, for example, but not limited to, the output tensor of the second task or its storage address, size, and data type. The expected deadline is the expected completion time of the second task. The expected execution duration is the time required to execute the second task. In response to obtaining the second task information, the processor 21 can determine the expected start time of the second task based on the second task information, and then insert the second task into the task scheduling queue based on the expected start time of the second task.
[0074] Optionally, a third and / or fourth task adjacent to the expected start time of the second task can be determined based on the expected start time of the second task and the expected start time of each task in the task scheduling queue. The expected start time of the third task is earlier than that of the second task, and the expected start time of the fourth task is later than that of the second task. If both the third and fourth tasks exist in the task scheduling queue, the second task is inserted between them. If the third task exists in the task scheduling queue but the fourth task does not, the second task is inserted after the third task. If the third task does not exist in the task scheduling queue, but the fourth task does, it indicates that the fourth task has the earliest expected start time in the task scheduling queue, and the second task is inserted before the fourth task, i.e., inserted at the head of the task scheduling queue.
[0075] Optionally, if there is no task in the task scheduling queue, the second task is written into the task scheduling queue, and the second task is the first task in the task scheduling queue with the earliest expected start time.
[0076] In the embodiments of this disclosure, when the processor 21 obtains the second task information (i.e., the new task information), it can determine the expected start time of the second task based on the second task information, and then insert the second task into the task scheduling queue based on the expected start time, so that the tasks in the task scheduling queue are arranged according to the expected start time, which facilitates the tasks in the task scheduling queue to be dequeued and executed in order, thereby improving task management efficiency.
[0077] In some optional embodiments, determining the expected start time of the second task corresponding to the second task information based on the second task information includes: Based on the information of the second task, determine the task deadline and expected execution duration of the second task; based on the task deadline and expected execution duration, determine the expected start time of the second task.
[0078] The task deadline (or expected deadline) is the expected completion time of the task. The expected execution duration is the expected length of time the task will be executed. Both the task deadline and the expected execution duration can be obtained from the second task information.
[0079] Optionally, the expected start time of the second task can be calculated based on the task deadline and expected execution duration, according to pre-configured calculation rules.
[0080] Optionally, the expected start time can be a time earlier than the task deadline and the expected execution duration. For example, if the task deadline is T2, the expected execution duration is ΔT, the expected start time is T1, T1 is earlier than T2, and the time interval between T1 and T2 is ΔT.
[0081] Optionally, the expected start time of the second task can be determined based on the task deadline, the expected execution duration, and a first duration threshold. For example, based on the expected execution duration and the first duration threshold, a target execution duration is determined, and the time earlier than the target execution duration before the task deadline is taken as the expected start time. The first duration threshold is a set time margin for triggering the execution of the second task, ensuring that the second task can be completed before the task deadline. For example, if the task deadline is T2, the expected execution duration is ΔT, the first duration threshold is Δt, and the expected start time is T1, where T1 is earlier than T2, and the time interval between T1 and T2 is ΔT + Δt, then the expected start time T1 can be expressed as T1 = T2 - (ΔT + Δt).
[0082] In the embodiments of this disclosure, the expected start time of the second task is determined based on the task deadline and expected execution duration of the second task, ensuring the validity of the expected start time. This ensures that if the second task starts execution at the expected start time, it can be completed before the task deadline, further improving the real-time performance of the task.
[0083] In some alternative embodiments, processor 21 is also configured to: In response to the second task information not including the task deadline, the expected start time of the second task is set to a preset value; the second task is inserted at the tail of the task scheduling queue.
[0084] If the second task information does not include a deadline for the second task, it means that the second task is not a critical task and has no expected deadline. In this case, the expected start time of the second task can be set to a preset value, which can represent no expected deadline. The preset value is, for example, but not limited to, 0. The second task is then inserted at the end of the task scheduling queue, so that the second task is scheduled later.
[0085] In this embodiment of the disclosure, for a second task without an expected deadline, the expected start time of the second task is set to a preset value, and the second task is inserted at the end of the task scheduling queue, so that the second task can be scheduled later, and other critical tasks can be scheduled first, thereby further improving the security and stability of the on-chip system or electronic device.
[0086] In some alternative embodiments, processor 21 is also configured to: In response to the second task's expected start time being earlier than the earliest expected start time corresponding to the task scheduling queue, the earliest expected start time is updated based on the second task's expected start time.
[0087] If the expected start time of the second task is earlier than the earliest expected start time in the task scheduling queue, it means that the second task has the earliest expected start time in the task scheduling queue and should be scheduled first. Since the second task is newly added, the earliest expected start time in the task scheduling queue stored in the first storage unit is the earliest expected start time before the second task was added. Therefore, the earliest expected start time in the task scheduling queue needs to be updated based on the expected start time of the second task. The expected start time of the second task can be written into the first storage unit to ensure the accuracy and validity of the earliest expected start time in the task scheduling queue.
[0088] In the embodiments of this disclosure, if the expected start time of the second task newly added to the task scheduling queue is earlier than the earliest expected start time corresponding to the task scheduling queue, the earliest expected start time corresponding to the task scheduling queue is updated in real time based on the expected start time of the second task, so as to ensure the accuracy and effectiveness of the earliest expected start time corresponding to the task scheduling queue, and to provide an accurate and effective earliest expected start time for task triggering or timeout reminders.
[0089] In some optional embodiments, the task scheduling queue includes multiple task scheduling sub-queues with corresponding priorities. The processor 21 is also configured to determine the target priority of the second task based on the second task information.
[0090] Based on the expected start time of the second task, the second task is inserted into the task scheduling queue, including: Based on the expected start time of the second task, the second task is inserted into the task scheduling sub-queue corresponding to the target priority.
[0091] In cases where the task scheduling queue includes multiple task scheduling sub-queues corresponding to different priorities, the second task information may also include the priority of the second task. After obtaining the second task information, the processor 21 can determine the target priority of the second task based on the priority of the second task included in the second task information. Then, based on the target priority, the task scheduling sub-queue corresponding to the target priority among the multiple task scheduling sub-queues can be determined as the task scheduling sub-queue corresponding to the second task. Based on the expected start time of the second task, the second task is inserted into the task scheduling sub-queue corresponding to the target priority. The specific principle of inserting the second task into the task scheduling sub-queue can be referred to in the previous embodiments, and will not be repeated here.
[0092] In the embodiments of this disclosure, when the task scheduling queue includes multiple task scheduling sub-queues with corresponding priorities, for a newly acquired second task, based on the target priority of the second task and according to the expected start time of the second task, the second task is inserted into the task scheduling sub-queue corresponding to the target priority, so that each task scheduling sub-queue is arranged according to the expected start time, which facilitates the orderly scheduling of tasks in the task scheduling sub-queue and further improves the efficiency of task scheduling.
[0093] In some optional embodiments, based on any of the above embodiments, after the first task corresponding to the earliest expected start time is removed from the task scheduling queue, or after the first task is executed, the processor 21 is further configured to: The earliest expected start time is updated based on the expected start time of the next task after the first task in the task scheduling queue.
[0094] The process of removing or executing the first task from the task scheduling queue changes the tasks in the queue. The earliest expected start time for the task scheduling queue is determined based on the expected start times of the tasks in the queue. Changes in the tasks in the queue will cause changes to the earliest expected start time. Therefore, the earliest expected start time can be updated based on the expected start time of the next task after the first task in the queue to ensure its accuracy and validity. For example, the expected start time of the next task after the first task can be written to the first storage unit, thus using it as the earliest expected start time of the task scheduling queue. The next task after the first task refers to a task whose expected start time is later than the first task's expected start time but earlier than the expected start times of other tasks in the queue. For example, if the task scheduling queue is arranged from earliest to latest according to expected start time, the first task at the head of the queue after the first task is dequeued is the next task after the first task. Dequeuing the first task includes removing or executing the first task from the queue.
[0095] In the embodiments of this disclosure, after the first task is dequeued, the processor can update the earliest expected start time corresponding to the task scheduling queue in real time based on the expected start time of the next task of the first task, thereby improving the accuracy and effectiveness of the earliest expected start time.
[0096] In some optional embodiments, when the task scheduling queue includes multiple task scheduling sub-queues with corresponding priorities, the processor 21 is further configured to: for any first task scheduling sub-queue among the multiple task scheduling sub-queues, in response to the deletion or execution of the first task in the first task scheduling sub-queue, update the earliest expected start time corresponding to the first task scheduling sub-queue based on the expected start time of the next task of the first task in the first task scheduling sub-queue, so as to ensure the accuracy and effectiveness of the earliest expected start time corresponding to each task scheduling sub-queue.
[0097] In some alternative embodiments, Figure 4 This is a schematic diagram of the structure of a processor provided in an exemplary embodiment of this disclosure. Figure 4 As shown, the processor 21 may include a task receiving unit 211, a sorting and scheduling unit 212, and an alerting unit 213. The sorting and scheduling unit 212 is coupled to the task receiving unit 211, and is also coupled to each computing element 12. The alerting unit 213 is coupled to both the task receiving unit 211 and the sorting and scheduling unit 212. The sorting and scheduling unit 212 and the alerting unit 213 are also coupled to the first storage unit 22.
[0098] The task receiving unit 211 is used to obtain second task information from the application, determine the expected start time of the second task corresponding to the second task information based on the second task information, and transmit the second task information and the expected start time to the sorting and scheduling unit 212.
[0099] The sorting and scheduling unit 212 is used to obtain the second task information and expected start time transmitted by the task receiving unit 211, determine the target priority of the second task based on the second task information, and insert the second task into the task scheduling sub-queue corresponding to the target priority based on the expected start time and target priority of the second task.
[0100] The sorting and scheduling unit 212 is also used to update the earliest expected start time of the task scheduling sub-queue in the first storage unit 22 based on the expected start time of the second task, in response to the expected start time of the second task being earlier than the earliest expected start time of the task scheduling sub-queue.
[0101] The reminder unit 213 is used to obtain the earliest expected start time corresponding to each task scheduling sub-queue from the first storage unit 22, compare the current time with the earliest expected start time to obtain a comparison result, generate task scheduling reminder information in response to the comparison result indicating that the relationship between the current time and the earliest expected start time meets the task triggering condition, and transmit the task scheduling reminder information to the sorting and scheduling unit 212.
[0102] The sorting and scheduling unit 212 is also used to, in response to task scheduling reminder information, determine the target task scheduling sub-queue based on the priority of each task scheduling sub-queue and the earliest expected start time of each task scheduling sub-queue; read the first task corresponding to the earliest expected start time from the target task scheduling sub-queue, and schedule the computing element 12 corresponding to the first task to execute the first task. The computing element 12 can return the task execution result to the task receiving unit 211. The task receiving unit 211 is also used to return the task execution result to the corresponding application. Optionally, after reading the first task, the sorting and scheduling unit 212 can also be used to determine the working status of the computing element 12 corresponding to the first task. In response to the working status being idle, the computing element 12 is scheduled to execute the first task. In response to the working status being non-idle, the first task is deleted from the target task scheduling sub-queue, and a timeout exception information is generated. The timeout exception information is transmitted to the task receiving unit 211, which then returns the timeout exception information to the application that issued the task.
[0103] The reminder unit 213 is also configured to transmit task timeout reminder information to the sorting and scheduling unit 212 in response to a comparison result indicating that the relationship between the current time and the earliest expected start time meets the task timeout condition. The task timeout reminder information may include the task identifier of the first task that timed out.
[0104] The sorting and scheduling unit 212 is also used to, in response to the task timeout reminder information, delete the first task from the task scheduling sub-queue based on the task identifier of the first task included in the task timeout reminder information.
[0105] The reminder unit 213 is also used to generate timeout exception information corresponding to the first task, and return the timeout exception information to the task receiving unit 211, which then returns the timeout exception information to the application that issued the task.
[0106] The sorting and scheduling unit 212 is also used to: after deleting the first task from the task scheduling sub-queue, or after the scheduling computing element executes the first task, update the earliest expected start time of the task scheduling sub-queue in the first storage unit 22 based on the expected start time of the next task of the first task in the task scheduling sub-queue.
[0107] In this embodiment, the task receiving unit, sorting and scheduling unit, and reminder unit work together to manage the task scheduling queue in an orderly manner and to schedule the tasks in the task scheduling queue in an orderly manner. The reminder unit effectively monitors the task execution status, reminds the task to start execution in a timely manner according to the expected start time, and deletes expired tasks in a timely manner, effectively balancing the execution efficiency and real-time performance of the tasks. Furthermore, by maintaining tasks of different priorities through multiple task scheduling sub-queues corresponding to different priorities, it is ensured that high-priority tasks can be executed first, effectively improving the security and stability of the on-chip system or electronic device.
[0108] The embodiments described above can be implemented individually or in any combination without conflict. The specific implementation can be set according to actual needs, and this disclosure does not limit them.
[0109] Exemplary methods Figure 5 This is a flowchart illustrating a task scheduling method provided in an exemplary embodiment of this disclosure. The task scheduling method provided in this embodiment can be implemented using any of the task scheduling devices provided in the above embodiments of this disclosure, such as... Figure 5 The method shown may include the following steps: Step 510: Obtain the earliest expected start time for the task scheduling queue.
[0110] The earliest expected start time is determined based on the expected start time of tasks in the task scheduling queue.
[0111] Step 520: In response to the fact that the current time and the earliest expected start time meet the task timeout condition, the first task corresponding to the earliest expected start time is deleted from the task scheduling queue, and timeout exception information for the first task is generated.
[0112] Step 530: In response to the fact that the current time and the earliest expected start time meet the task triggering conditions, execute the first task.
[0113] In some optional embodiments, based on any of the above embodiments, obtaining the earliest expected start time corresponding to the task scheduling queue in step 510 may include: obtaining the earliest expected start time corresponding to the task scheduling queue from the first storage unit.
[0114] In some optional embodiments, based on any of the above embodiments, the task scheduling queue includes multiple task scheduling sub-queues with corresponding priorities.
[0115] Step 510, obtaining the earliest expected start time for the task scheduling queue, may include: For any first task scheduling subqueue among multiple task scheduling subqueues, obtain the earliest expected start time corresponding to the first task scheduling subqueue from the first storage unit that stores the earliest expected start time.
[0116] In step 520, in response to the relationship between the current time and the earliest expected start time satisfying the task timeout condition, the first task corresponding to the earliest expected start time is deleted from the task scheduling queue, and timeout exception information for the first task is generated, which may include: For the first task scheduling subqueue among multiple task scheduling subqueues, if the relationship between the current time and the earliest expected start time corresponding to the first task scheduling subqueue meets the task timeout condition, the first task corresponding to the earliest expected start time in the first task scheduling subqueue is deleted from the first task scheduling subqueue, and timeout exception information for the first task is generated.
[0117] Figure 6 This is a flowchart illustrating a task scheduling method provided in another exemplary embodiment of this disclosure.
[0118] In some alternative embodiments, based on any of the above embodiments, such as Figure 6 As shown, after obtaining the earliest expected start time for the task scheduling queue, the process also includes: Step 610: Compare the current time with the earliest expected start time to obtain the comparison result.
[0119] Step 620: In response to the comparison result indicating that the current time is later than the earliest expected start time, determine that the relationship between the current time and the earliest expected start time satisfies the task timeout condition.
[0120] Step 630: In response to the comparison result indicating that the current time is not later than the earliest expected start time and the interval between the current time and the earliest expected start time is less than a preset duration threshold, determine that the relationship between the current time and the earliest expected start time satisfies the task triggering condition.
[0121] Figure 7 This is a flowchart illustrating a task scheduling method provided in yet another exemplary embodiment of this disclosure.
[0122] In some alternative embodiments, based on any of the above embodiments, such as Figure 7 As shown, step 530, in response to the relationship between the current time and the earliest expected start time satisfying the task triggering condition, executes the first task, which may include: Step 5310: In response to the relationship between the current time and the earliest expected start time satisfying the task triggering condition, generate a task scheduling reminder message.
[0123] The task triggering conditions include that the current time is not later than the earliest expected start time, and the interval between the current time and the earliest expected start time is less than a preset duration threshold.
[0124] Step 5320: In response to the task scheduling reminder message, read the first task from the task scheduling queue.
[0125] Step 5330: Schedule the computing element corresponding to the first task to execute the first task.
[0126] In some optional embodiments, the task scheduling queue includes multiple task scheduling sub-queues with corresponding priorities. Step 5320, in response to the task scheduling reminder information, reading the first task from the task scheduling queue, may include: In response to task scheduling reminders, based on the priorities of multiple task scheduling sub-queues, the highest priority target task scheduling sub-queue is determined from the task scheduling sub-queues with pending tasks. The task with the earliest expected start time is read from the target task scheduling sub-queue and taken as the first task.
[0127] In some optional embodiments, based on any of the above embodiments, step 5330, which involves scheduling the computing element corresponding to the first task to execute the first task, may include: Determine the working state of the computing element corresponding to the first task; in response to the computing element being in an idle state, transfer the first task to the computing element; control the computing element to execute the first task.
[0128] In some alternative embodiments, processor 21 is also configured to: In response to the computing element being in a non-idle state, the first task is removed from the task scheduling queue, and a timeout exception message corresponding to the first task is generated.
[0129] Figure 8 This is a flowchart illustrating a task scheduling method provided in yet another exemplary embodiment of this disclosure.
[0130] In some optional embodiments, based on any of the above embodiments, the task scheduling queue includes multiple task scheduling sub-queues with corresponding priorities.
[0131] like Figure 8 As shown, step 530, in response to the relationship between the current time and the earliest expected start time satisfying the task triggering condition, executes the first task, which may include: Step 53a0: For any first task scheduling subqueue among multiple task scheduling subqueues, in response to the relationship between the current time and the earliest expected start time corresponding to the first task scheduling subqueue satisfying the task triggering condition, generate task scheduling reminder information.
[0132] Step 53b0: In response to the task scheduling reminder information, determine the target task scheduling subqueue based on the earliest expected start time and priority of each of the multiple task scheduling subqueues.
[0133] Step 53c0: Determine the task with the earliest expected start time in the target task scheduling sub-queue as the first task.
[0134] Step 53d0: Schedule the computing element corresponding to the first task to execute the first task.
[0135] Figure 9 This is a flowchart illustrating a task scheduling method provided in yet another exemplary embodiment of this disclosure.
[0136] In some alternative embodiments, based on any of the above embodiments, such as Figure 9 As shown, the method in this embodiment of the disclosure may further include: Step 710: In response to obtaining the second task information, determine the expected start time of the second task corresponding to the second task information based on the second task information.
[0137] Step 720: Based on the expected start time of the second task, insert the second task into the task scheduling queue.
[0138] In some optional embodiments, step 720, based on the second task information, determines the expected start time of the second task, including: Based on the information of the second task, determine the task deadline and expected execution duration of the second task; based on the task deadline and expected execution duration, determine the expected start time of the second task.
[0139] In some optional embodiments, the method of this disclosure further includes: In response to the second task information not including the task deadline, the expected start time of the second task is set to a preset value; the second task is inserted at the tail of the task scheduling queue.
[0140] In some alternative embodiments, based on any of the above embodiments, such as Figure 9 As shown, the method in this embodiment of the disclosure may further include: Step 730: In response to the fact that the expected start time of the second task is earlier than the earliest expected start time corresponding to the task scheduling queue, update the earliest expected start time based on the expected start time of the second task.
[0141] In some optional embodiments, the task scheduling queue includes multiple task scheduling sub-queues with corresponding priorities. The method in this disclosure embodiment may further include: determining the target priority of the second task based on the second task information.
[0142] Step 720, based on the expected start time of the second task, inserts the second task into the task scheduling queue, which may include: Based on the expected start time of the second task, the second task is inserted into the task scheduling sub-queue corresponding to the target priority.
[0143] In some optional embodiments, based on any of the above embodiments, after deleting the first task corresponding to the earliest expected start time from the task scheduling queue, or after executing the first task, the method of this disclosure embodiment may further include: The earliest expected start time is updated based on the expected start time of the next task after the first task in the task scheduling queue.
[0144] The embodiments described above can be implemented individually or in any combination without conflict. The specific implementation can be set according to actual needs, and this disclosure does not limit them.
[0145] The beneficial technical effects corresponding to the exemplary embodiments of this method can be found in the corresponding beneficial technical effects of the exemplary device section above, and will not be repeated here.
[0146] Any task scheduling method provided in this disclosure can be executed by any suitable electronic device with data processing capabilities, including but not limited to: terminal devices and servers. Alternatively, any task scheduling method provided in this disclosure can be executed by a processor, such as by a processor executing any task scheduling method mentioned in this disclosure by calling corresponding instructions stored in memory. Further details will not be elaborated below.
[0147] Exemplary electronic devices Figure 10 This is a structural diagram of an electronic device provided in an embodiment of the present disclosure, including at least one processor 91 and a memory 92.
[0148] The processor 91 may be a central processing unit (CPU) or other form of processing unit with data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 90 to perform desired functions.
[0149] The memory 92 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 91 may execute one or more computer program instructions to implement the task scheduling methods and / or other desired functions of the various embodiments of this disclosure described above.
[0150] In one example, the electronic device 90 may also include an input device 93 and an output device 94, which are interconnected via a bus system and / or other forms of connection mechanism (not shown).
[0151] The input device 93 may also include, for example, a touch screen, a microphone, various sensors, etc.
[0152] The output device 94 can output various information to the outside, including, for example, a display, a speaker, a communication network and its connected remote output devices, etc.
[0153] Of course, for the sake of simplicity, Figure 10 Only some of the components of the electronic device 90 relevant to this disclosure are shown, omitting components such as buses, input / output interfaces, etc. In addition, the electronic device 90 may include any other suitable components depending on the specific application.
[0154] Exemplary computer program products and computer-readable storage media In addition to the methods and apparatus described above, embodiments of this disclosure may also provide a computer program product, including computer program instructions that, when executed by a processor, cause the processor to perform the steps of the task scheduling methods of the various embodiments of this disclosure described in the "Exemplary Methods" section above.
[0155] Computer program products can be written in any combination of one or more programming languages to perform the operations of embodiments of this disclosure. These programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on a user's computing device, partially on a user's computing device, as a standalone software package, partially on a user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0156] Furthermore, embodiments of this disclosure may also be computer-readable storage media storing computer program instructions thereon, which, when executed by a processor, cause the processor to perform the steps of the task scheduling methods of the various embodiments of this disclosure described in the "Exemplary Methods" section above.
[0157] Computer-readable storage media may take the form of any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may include, but is not limited to, systems, apparatuses, or devices that are electrical, magnetic, optical, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0158] The basic principles of this disclosure have been described above with reference to specific embodiments. However, the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations, and should not be considered as essential features of each embodiment of this disclosure. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the scope of this disclosure to the necessity of employing the aforementioned specific details for implementation.
[0159] Various modifications and variations can be made to this disclosure without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this disclosure and their equivalents, this disclosure is also intended to include such modifications and variations.
Claims
1. A task scheduling device, comprising a processor, the processor being configured to: Obtain the earliest expected start time corresponding to the task scheduling queue; the earliest expected start time is determined based on the expected start time of the tasks in the task scheduling queue; If the relationship between the current time and the earliest expected start time satisfies the task timeout condition, the first task corresponding to the earliest expected start time is deleted from the task scheduling queue, and timeout exception information for the first task is generated; or, In response to the relationship between the current time and the earliest expected start time satisfying the task triggering condition, the first task is executed.
2. The apparatus according to claim 1, wherein, The response that the relationship between the current time and the earliest expected start time satisfies the task triggering condition, and the execution of the first task, includes: In response to the relationship between the current time and the earliest expected start time satisfying the task triggering condition, a task scheduling reminder message is generated; the task triggering condition includes that the current time is not later than the earliest expected start time, and the interval between the current time and the earliest expected start time is less than a preset duration threshold. In response to the task scheduling reminder information, the first task is read from the task scheduling queue; The computing element corresponding to the first task is scheduled to execute the first task.
3. The apparatus according to claim 1, wherein, The processor is also configured to: In response to obtaining the second task information, the expected start time of the second task corresponding to the second task information is determined based on the second task information; Based on the expected start time of the second task, the second task is inserted into the task scheduling queue.
4. The apparatus according to claim 3, wherein, The processor is also configured to: In response to the fact that the expected start time of the second task is earlier than the earliest expected start time corresponding to the task scheduling queue, the earliest expected start time is updated based on the expected start time of the second task.
5. The apparatus according to claim 3, wherein, The task scheduling queue includes multiple task scheduling sub-queues with corresponding priorities; the processor is further configured to: Based on the second task information, determine the target priority of the second task; The step of inserting the second task into the task scheduling queue based on the expected start time of the second task includes: Based on the expected start time of the second task, the second task is inserted into the task scheduling sub-queue corresponding to the target priority.
6. The apparatus according to claim 3, wherein, The step of determining the expected start time of the second task corresponding to the second task information based on the second task information includes: Based on the second task information, determine the task deadline and expected execution time of the second task; Based on the task deadline and the expected execution duration, the expected start time of the second task is determined.
7. The apparatus according to claim 6, wherein, The processor is also configured to: In response to the fact that the second task information does not include the task deadline of the second task, the expected start time of the second task is set to a preset value; The second task is inserted at the tail of the task scheduling queue.
8. The apparatus according to claim 2, wherein, The task scheduling queue includes multiple task scheduling sub-queues with corresponding priorities; The step of reading the first task from the task scheduling queue in response to the task scheduling reminder information includes: In response to the task scheduling reminder information, based on the priorities corresponding to the multiple task scheduling sub-queues, the target task scheduling sub-queue with the highest priority is determined from the multiple task scheduling sub-queues with pending tasks. The task with the earliest expected start time is read from the target task scheduling sub-queue and taken as the first task.
9. The apparatus according to claim 2, wherein, The scheduling of the computing element corresponding to the first task to execute the first task includes: Determine the working status of the computing element corresponding to the first task; In response to the computing element being in an idle state, the first task is transmitted to the computing element; Control the computing element to perform the first task.
10. The apparatus according to claim 9, wherein, The processor is also configured to: In response to the computing element being in a non-idle state, the first task is deleted from the task scheduling queue, and timeout exception information corresponding to the first task is generated.
11. The apparatus according to any one of claims 1-10, wherein, Also includes: The first storage unit is configured to store the earliest expected start time of execution corresponding to the task scheduling queue; The processor is specifically configured as follows: Obtain the earliest expected start time of the task scheduling queue from the first storage unit.
12. The apparatus according to any one of claims 1-10, wherein, The task scheduling queue includes multiple task scheduling sub-queues with corresponding priorities; The process of obtaining the earliest expected start time corresponding to the task scheduling queue includes: For any first task scheduling subqueue among the plurality of task scheduling subqueues, the earliest expected start time corresponding to the first task scheduling subqueue is obtained from the first storage unit storing the earliest expected start time; If the relationship between the current time and the earliest expected start time satisfies the task timeout condition, the first task corresponding to the earliest expected start time is deleted from the task scheduling queue, and timeout exception information for the first task is generated, including: For the first task scheduling sub-queue among the multiple task scheduling sub-queues, in response to the relationship between the current time and the earliest expected start time corresponding to the first task scheduling sub-queue satisfying the task timeout condition, the first task corresponding to the earliest expected start time in the first task scheduling sub-queue is deleted from the first task scheduling sub-queue, and timeout exception information for the first task is generated.
13. The apparatus according to any one of claims 1-10, wherein, The task scheduling queue includes multiple task scheduling sub-queues with corresponding priorities; The response that the relationship between the current time and the earliest expected start time satisfies the task triggering condition, and the execution of the first task, includes: For any first task scheduling subqueue among the plurality of task scheduling subqueues, in response to the relationship between the current time and the earliest expected start time corresponding to the first task scheduling subqueue satisfying the task triggering condition, a task scheduling reminder message is generated. In response to the task scheduling reminder information, a target task scheduling sub-queue is determined based on the earliest expected start time and priority corresponding to the multiple task scheduling sub-queues respectively; The task with the earliest expected start time in the target task scheduling sub-queue is determined as the first task; The computing element corresponding to the first task is scheduled to execute the first task.
14. The apparatus according to any one of claims 1-10, wherein, After obtaining the earliest expected start time corresponding to the task scheduling queue, the processor is further configured to: Compare the current time with the earliest expected start time to obtain a comparison result; In response to the comparison result indicating that the current time is later than the earliest expected start time, determine that the relationship between the current time and the earliest expected start time satisfies the task timeout condition; or, In response to the comparison result indicating that the current time is not later than the earliest expected start time, and the interval between the current time and the earliest expected start time is less than a preset duration threshold, it is determined that the relationship between the current time and the earliest expected start time satisfies the task triggering condition.
15. The apparatus according to any one of claims 1-10, wherein, After removing the first task corresponding to the earliest expected start time from the task scheduling queue, or after executing the first task, the processor is further configured to: The earliest expected start time is updated based on the expected start time of the next task of the first task in the task scheduling queue.
16. A task scheduling method, comprising: Obtain the earliest expected start time corresponding to the task scheduling queue; the earliest expected start time is determined based on the expected start time of the tasks in the task scheduling queue; In response to the current time and the earliest expected start time meeting the task timeout condition, the first task corresponding to the earliest expected start time is deleted from the task scheduling queue, and timeout exception information for the first task is generated; or, In response to the current time and the earliest expected start time meeting the task triggering condition, the first task is executed.
17. A computer-readable storage medium storing a computer program that is executed by a processor to perform the task scheduling method of claim 16.
18. An electronic device, the electronic device comprising: processor; Memory used to store the processor's executable instructions; The processor is configured to read the executable instructions from the memory, and execute the executable instructions to implement the task scheduling method of claim 16.