Task scheduling methods and multi-core processor systems

By dynamically adjusting the task scheduling method in the vehicle controller and allocating core resources according to task priority and status, the problem of unreasonable task scheduling in the vehicle controller is solved, and the system's security and real-time performance are improved.

CN117751351BActive Publication Date: 2026-07-31CONTEMPORARY AMPEREX TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CONTEMPORARY AMPEREX TECHNOLOGY CO LTD
Filing Date
2021-12-27
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively schedule complex and diverse tasks in vehicle controllers, resulting in insufficient system security and real-time performance. Conventional scheduling algorithms are prone to system crashes, freezes, restarts, and other anomalies, and the allocation of processing core resources is often unreasonable.

Method used

A task scheduling method is adopted to dynamically adjust the task scheduling of the processing core according to the task priority and status. Abnormal tasks are terminated by force or delay, abnormal status is recorded, and the management core is used to monitor and allocate tasks to ensure system security and real-time performance.

Benefits of technology

It improves system security and real-time performance, avoids system crashes and anomalies, optimizes the allocation of processing kernel resources, and enhances the overall efficiency of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117751351B_ABST
    Figure CN117751351B_ABST
Patent Text Reader

Abstract

A task scheduling method, a multi-core processor system, and a computer-readable storage medium are disclosed. The task scheduling method includes: when a first task is in an execution abnormal state, determining whether the first task can be forcibly terminated; when the first task cannot be forcibly terminated, reporting to a second task associated with the first task that the first task is in an execution abnormal state; and when the duration of the first task being in an execution abnormal state reaches a predetermined waiting time and no termination instruction is received from the first task, forcibly terminating the execution of the first task or stopping task scheduling for the processing core executing the first task.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a task scheduling method and a multi-core processor system. Background Technology

[0002] In the emerging field of automotive controllers, especially domain controllers designed to meet the demands of autonomous driving, the adoption of Service-Oriented Architecture (SOA) has gradually become the mainstream approach. As automotive intelligence continues to advance, the functions that automotive controllers need to handle are becoming increasingly complex, and the scenarios are becoming increasingly diverse. However, it is often difficult for a single developer to independently complete all application development. Furthermore, unlike mobile phone software, the control of automotive systems is more complex, and while loading various personalized application functions, security and real-time performance are becoming increasingly important.

[0003] For vehicle controllers, it's essential to integrate third-party developed functionalities to create a digital ecosystem that meets diverse driving / riding scenarios, while simultaneously ensuring driving safety. This is because the numerous tasks that the vehicle controller needs to handle require efficient scheduling. Summary of the Invention

[0004] In view of the above problems, this application proposes a task scheduling method, a multi-core processor system, and a computer-readable storage medium.

[0005] Therefore, a first aspect of the present invention provides a task scheduling method, the task scheduling method comprising:

[0006] When the first task is in an abnormal execution state, determine whether the first task can be forcibly terminated;

[0007] If the first task cannot be forcibly terminated, report the abnormal execution status of the first task to the second task associated with the first task; and

[0008] If the duration of the first task being in an abnormal execution state reaches the predetermined waiting time and no termination instruction for the first task is received, the execution of the first task will be forcibly terminated or task scheduling for the processing core executing the first task will be stopped.

[0009] In the implementation scheme of this application, tasks have different priorities. When an abnormal task occurs, low-priority tasks can be forcibly terminated immediately, medium-priority tasks can be forcibly terminated after receiving an instruction or after a delay, and high-priority tasks cannot be forcibly terminated, so the task scheduling of the processing kernel for that abnormal task is stopped. In the implementation scheme of this application, based on the characteristics of the task itself, the abnormal task is terminated with a delay. This avoids forcibly terminating the abnormal program, nor does it leave the abnormal program unattended, thus preventing the abnormal program from expanding the scope of the fault and causing further harm. It also avoids anomalies such as system crashes, freezes, restarts, and logical conflicts, providing technical support for the system to enter a safe state.

[0010] In some embodiments of this application, when the first task is in an abnormal execution state, the abnormal state of the first task is recorded. By recording abnormal tasks, data assurance is provided for problem analysis of third-party applications and whether new applications can be deployed.

[0011] In some embodiments of this application, when the first task cannot be forcibly terminated, an abnormal status of the first task is sent to the system application, and the system application determines whether to issue a termination command for the first task to the processing core executing the first task based on the abnormal status. In some embodiments, the system application includes a health management module.

[0012] In some implementations, the execution exception state includes one or more of the following states: task execution timeout, task memory usage exceeding limits, and task stack usage exceeding limits.

[0013] In some implementations, the predetermined waiting time is determined based on the priority of the first task.

[0014] In some implementations, the task scheduling method includes: forcibly terminating the first task when it can be forcibly terminated.

[0015] In the implementation scheme of this application, when an abnormal task occurs, a choice is made between terminating the task and delaying termination based on the characteristics of the task itself, which meets the needs of high-safety scenarios such as autonomous driving.

[0016] In some implementations, the task scheduling method includes: when the first task that is forcibly terminated is the last task in the processing core that executes the first task, allocating a new task to the processing core that executes the first task.

[0017] In some implementations, the task scheduling method includes: when the first task that is forcibly terminated is not the last task in the processing core that executes the first task, instructing the processing core that executes the first task to sequentially execute the next task assigned to it.

[0018] In the implementation of this application, by terminating or delaying the termination of abnormal tasks, the processing kernel executing the abnormal tasks is released, thus avoiding system crashes.

[0019] In some implementations, this task scheduling method is applicable to multi-core processor systems that contain multiple processing cores.

[0020] In some implementations, the task scheduling method is executed by one of the plurality of processing cores, and the task scheduling method includes:

[0021] Real-time acquisition of status information of the aforementioned multiple processing cores; and

[0022] When the processing core executing the task scheduling method fails, the task scheduling method is executed through another processing core among the aforementioned multiple processing cores.

[0023] In the implementation scheme of this application, the task scheduling method is temporarily fixed to be executed by one processing core. Then, when the processing core fails, the task scheduling method is moved to another processing core for execution. This avoids the problem that the task scheduling method cannot continue to be scheduled when the processing core is faulty. At the same time, when there are multiple processing cores, the scheduling algorithm itself is not dynamically executed by multiple processing cores. This eliminates the need for stack and push operations in different processing cores, saves execution time, and improves the overall efficiency of the system.

[0024] In the implementation scheme of this application, the processing kernel of the task scheduling method plays the role of monitoring task triggering, task waiting, task scheduling and task execution, and can record exceptions when tasks are abnormal.

[0025] In some implementations, the task scheduling method includes: allocating tasks to be processed in the task queue to processing cores other than the processing cores executing the task scheduling method among the plurality of processing cores.

[0026] In some implementations, when one or more of the aforementioned processing cores fail or the multi-core processor system is in a low-power operating state, the tasks in the task queue are assigned to available designated processing cores. In the implementations of this application, processing cores are not only searched for and indiscriminately scheduled based on the dynamic execution parameters of the tasks, but the task scheduling of the processing cores is also dynamically adjusted based on the state of the processing cores and the processing system itself, resulting in more rational task scheduling.

[0027] In the implementation scheme of this application, in the queue of tasks to be processed, the priority of some tasks cannot be changed, while the priority of some tasks can be changed; considering that the relative priority of tasks will change dynamically based on the scenario, the implementation scheme of this application realizes flexible adjustment of priority.

[0028] In some implementations, the task scheduling method includes adjusting the priority of the pending tasks based on the allocation waiting time of the pending tasks in the pending task queue.

[0029] In some embodiments of this application, the scheduling order of tasks in the task queue is adjusted based on the principles of first-in-first-out and priority.

[0030] In a specific implementation of this application, adjusting the priority of the pending tasks based on their allocation waiting time in the pending task queue includes:

[0031] When the sum of the original priority of the task to be processed and the priority adjustment value of the task to be processed is less than or equal to the maximum allowed priority of the task to be processed, the priority of the task to be processed is set to the original priority of the task to be processed plus the priority adjustment value, wherein the priority adjustment value is obtained by rounding down the product of the allocated waiting time and the adjustment coefficient of the task to be processed; and

[0032] When the original priority of the above-mentioned pending task plus the priority adjustment value is greater than the maximum allowed priority of the above-mentioned pending task, the priority of the above-mentioned pending task is set to the maximum allowed priority of the above-mentioned pending task.

[0033] In some implementations, when a new task is received, the attribute parameters of the new task are obtained. These attribute parameters include one or more of the following: the maximum allowed waiting time of the task, the estimated execution time of the task, the original priority of the task, the priority adjustment factor of the task, and whether the task is allowed to be forcibly terminated.

[0034] In some implementations, the task scheduling method includes: allocating tasks in the task queue to different idle processing cores based on the estimated execution time of the tasks in the task queue, so that the completion times of the tasks executed by different processing cores are staggered.

[0035] In the implementation scheme of this application, by staggering the completion times of tasks executed by different processing cores, the waiting time of idle processing cores is reduced, thereby improving the overall system efficiency.

[0036] In some implementations, the difference between the estimated execution time of the sum of one or more tasks assigned to an idle processing core and the estimated execution time of the sum of one or more tasks subsequently assigned to another idle processing core is greater than or equal to a preset time interval. In an exemplary embodiment of this application, the preset time interval is 2ms.

[0037] In the implementation scheme of this application, tasks are neither assigned one by one nor assigned in batches to multiple idle processing cores at the same time. Instead, one or more tasks are assigned to each idle processing core sequentially according to the possible execution time of the tasks. This reduces the waiting time of the idle processing cores, improves system efficiency, and avoids the difficulties in coordinating tasks during the waiting time and the problem of not being able to control the load of the processing cores.

[0038] In some implementations, task allocation based on the estimated execution time of tasks in the pending task queue includes:

[0039] Assign the first pending task to the first idle processing core;

[0040] When the difference between the estimated execution time of the second task to be processed and the estimated execution time of the first task to be processed is greater than or equal to a preset time interval, the second task to be processed is assigned to the second idle processing core.

[0041] When the difference between the estimated execution time of the second task to be processed and the estimated execution time of the first task to be processed is less than a preset time interval, it is determined whether the difference between the sum of the estimated execution times of the second and third tasks to be processed and the estimated execution time of the first task to be processed is greater than or equal to the preset time interval.

[0042] When the difference between the estimated execution time of the second and third pending tasks and the estimated execution time of the first pending task is greater than or equal to a preset time interval, the second and third pending tasks are assigned to the second idle processing core; and

[0043] When the difference between the estimated execution time of the second and third pending tasks and the estimated execution time of the first pending task is less than a preset time interval, the second, third, and fourth pending tasks are assigned to the second idle processing core.

[0044] In the above embodiments of this application, "first," "second," "third," and "fourth" in the first pending task, second pending task, third pending task, and fourth pending task represent the allocation order of the pending tasks, and "first" and "second" in the first idle processing core and second idle processing core represent the allocation order of the idle processing cores with equally allocated tasks. In the embodiments of this application, by allocating one or more tasks together to a processing core based on the possible execution time of the tasks, the processing cores are not assigned tasks at approximately the same time, thereby ensuring that each processing core does not frequently enter idle time. This effectively reduces the probability of multiple processing cores entering idle time simultaneously and improves the system's processing efficiency.

[0045] In an embodiment of this application, when the difference between the estimated execution time of the second, third, and fourth pending tasks and the estimated execution time of the first pending task is less than a preset time interval, the second, third, and fourth pending tasks are allocated to a second idle processing core. In this embodiment, although the total estimated execution time of the tasks allocated to the second idle processing core is less than the estimated execution time of the tasks allocated to the first idle processing core, three pending tasks are still allocated to the second idle processing core, ensuring that a maximum of three pending tasks are assigned to it. This is done to avoid assigning too many tasks to a single processing core; the more tasks assigned to a single core, the more prone it is to errors. If the execution of the second pending task malfunctions, it will affect the execution of other tasks allocated to the second idle processing core.

[0046] In some implementations, the tasks to be processed are arranged in descending order of priority in the task queue.

[0047] In some implementations, the idle processing cores are arranged in descending order of their idle time.

[0048] A second aspect of this application provides a computer-readable storage medium storing instructions that, when executed by a processor, cause the processor to perform the task scheduling method according to the first aspect.

[0049] A third aspect of this application provides a multi-core processor system, which includes multiple processing cores, one of which is configured as a management core for performing task scheduling.

[0050] The management core is configured to execute the task scheduling method described in the first aspect above.

[0051] The fourth aspect of this application provides a task scheduling method, which includes: allocating tasks in the task queue to different idle processing cores according to the estimated execution time of the tasks in the task queue, so that the completion times of the tasks executed by different processing cores are staggered.

[0052] The fifth aspect of this application provides a task scheduling method applicable to a multi-core processor system, the multi-core processor system comprising multiple processing cores; and

[0053] This task scheduling method is executed by one of the aforementioned processing cores, and the task scheduling method includes:

[0054] Real-time acquisition of status information of the aforementioned multiple processing cores; and

[0055] When the processing core executing the task scheduling method fails, the task scheduling method is executed through another processing core among the aforementioned multiple processing cores. Attached Figure Description

[0056] To more clearly illustrate the technical solutions of this application, the accompanying drawings used in the embodiments of this application will be briefly described below. Obviously, the drawings described below are merely some embodiments of this application. For those skilled in the art, other drawings can be obtained based on the drawings without any creative effort. In the drawings:

[0057] Figure 1 A flowchart illustrating a task scheduling method 100 according to one embodiment of this application is shown;

[0058] Figure 1a A flowchart illustrating a task scheduling method 100a according to another embodiment of this application is shown;

[0059] Figure 2 A block diagram of a multi-core processor system 200 according to one embodiment of this application is illustrated;

[0060] Figure 3 A flowchart illustrating a task scheduling method 300 according to one embodiment of this application is shown;

[0061] Figure 4 A flowchart illustrating a task scheduling method 400 according to one embodiment of this application is shown;

[0062] Figure 5 A flowchart illustrating a task scheduling method 500 according to one embodiment of this application is shown;

[0063] Figure 6 A flowchart illustrating a task scheduling method 600 according to one embodiment of this application is shown; and

[0064] Figure 6a A flowchart illustrating a task scheduling method 600a according to another embodiment of this application is shown. Detailed Implementation

[0065] The embodiments of this application will now be described in detail with reference to the accompanying drawings. These embodiments are merely illustrative of the technical solution of this application and should not be construed as limiting the scope of protection of this application.

[0066] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this application; the terms “comprising” and “having”, and any variations thereof, in the specification, claims, and foregoing description of the drawings are intended to cover non-exclusive inclusion.

[0067] In the description of the embodiments of this application, the technical terms "first" and "second" are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly indicating the number, specific order or primary and secondary relationship of the indicated technical features, unless otherwise specified.

[0068] In this document, the term "implementation" means that a particular feature, structure, or characteristic described in connection with an implementation can be included in at least one implementation of this application. The appearance of this phrase in various places in the specification does not necessarily refer to the same implementation, nor is it a separate or alternative implementation mutually exclusive with other implementations. It will be explicitly and implicitly understood by those skilled in the art that the implementations described herein can be combined with other implementations.

[0069] In the description of the embodiments of this application, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists, A and B exist simultaneously, and B exists. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship. In the description of the embodiments of this application, the term "multiple" refers to two or more (including two), unless otherwise explicitly specified.

[0070] If the steps are stated sequentially in this specification or claims, this does not necessarily mean that the embodiments or aspects are limited to the stated order. Rather, it is conceivable that the steps may be performed in a different order or in parallel with each other, unless one step builds upon another, which absolutely requires the building step to be performed subsequently (however, this will become clear in individual cases). Therefore, the stated order may be a preferred embodiment.

[0071] The inventors discovered that conventional scheduling algorithms categorize tasks at different levels into different scheduling classes using different algorithms, resulting in overly complex task allocation algorithms and poor program maintainability. Furthermore, conventional scheduling algorithms do not consider the impact of changing scenarios on scheduling; they only use dynamic execution parameters of tasks to find processing cores and perform indiscriminate scheduling. When a processing core fails or the system is in a low-power operating state, tasks may be assigned to invalid processing cores.

[0072] The inventors also discovered that when multiple processing cores dynamically execute the scheduling algorithm, data often needs to be stacked and pushed onto different processing cores, resulting in a longer execution time for the scheduling algorithm itself. Furthermore, when the scheduling algorithm is consistently executed by a single master core, if the master core fails, the scheduling algorithm cannot continue execution. In addition, when a task times out, conventional scheduling algorithms often terminate the task directly, easily leading to system crashes, freezes, restarts, logical conflicts, and other anomalies.

[0073] In addition, the inventors realized that conventional scheduling algorithms either allocate individual tasks to idle processing cores one by one, which can lead to excessive waiting time for idle processing cores, or allocate multiple tasks to multiple idle processing cores in batches, which can lead to difficulties in coordinating tasks during the waiting time and the inability to control the load on processing cores.

[0074] Based on the above findings, in order to overcome the problems of conventional scheduling algorithms, the inventors designed a task scheduling method and a multi-core processor system to meet the needs of autonomous driving and other applications for functional complexity, scenario diversity, functional personalization, system security and real-time performance.

[0075] Figure 1 A flowchart illustrating a task scheduling method 100 according to one embodiment of this application is shown. Figure 1 As shown, in step 102, it is determined whether the task being executed is in an abnormal execution state; if so, it is determined whether the task can be forcibly terminated, step 104. If the task cannot be forcibly terminated, the abnormal execution state of the task is reported to other tasks associated with the task, step 108. Then, it waits to receive processing instructions for the task from other tasks, and determines whether the wait for receiving the processing instructions has timed out, step 110. If the duration of the task being in an abnormal execution state reaches a predetermined waiting time and no termination instruction for the task is received, i.e., the wait for receiving the processing instructions for the task has timed out, the execution of the task is forcibly terminated or task scheduling for the processing core executing the task is stopped, step 114. If the processing instructions for the task are received within the predetermined waiting time, the task is processed according to the received processing instructions, step 112.

[0076] In some embodiments of this application, the execution exception state includes one or more of the following states: task execution timeout, task memory usage exceeding limits, and task stack usage exceeding limits. In some embodiments of this application, the predetermined waiting time is determined based on the task's priority.

[0077] Furthermore, in some embodiments of this application, when the task is in an abnormal execution state, the abnormal state of the task is recorded. By recording abnormal tasks, data assurance is provided for problem analysis of third-party applications and whether new applications can be deployed.

[0078] In some embodiments of this application, particularly in the scenario of an in-vehicle controller, when a program process malfunctions (e.g., memory overrun), the process is not simply forcibly terminated. Instead, the operating system reports the malfunction and provides other related processes with a certain response time. If the operating system receives a malfunction alarm and instructs the program process to be closed, it closes the process directly. If the operating system fails to provide or receive a processing instruction for the process for a prolonged period, it closes the malfunctioning process after a timeout. In one embodiment of this application, during automatic parking, if the taillight program malfunctions, the operating system sets the malfunction and waits for other applications to process it, such as slowing down, stopping, or exiting the automatic driving mode. If no feedback is received after a timeout, the operating system forcibly closes the process to prevent it from expanding its malfunction scope and causing further harm.

[0079] Figure 1a A flowchart illustrating a task scheduling method 100a according to another embodiment of this application is shown. Figure 1a and Figure 1 The steps are similar, so the same steps will not be repeated. Figure 1a As shown, in step 101, the execution status of the task is monitored; then, based on the task's execution status, it is determined whether the task is in an abnormal execution state (step 102). If the task is not in an abnormal state, it is determined whether the task has been completed (step 103). If the task has not been completed, the process returns to step 101 to continue monitoring the task's execution status.

[0080] Furthermore, if the task can be forcibly terminated, the task is terminated directly, step 106. In some embodiments of this application, when the forcibly terminated task is the last task in the processing core executing the task, a new task is assigned to the processing core executing the task; when the forcibly terminated task is not the last task in the processing core executing the task, the processing core executing the task is instructed to sequentially execute the next task assigned to it.

[0081] In the implementation scheme of this application, when an abnormal task occurs, a choice is made between terminating the task and delaying termination based on the characteristics of the task itself. This avoids forcibly terminating the abnormal program or leaving it unattended, thus preventing the abnormal program from expanding the scope of the fault and causing further harm. It also avoids anomalies such as system crashes, freezes, restarts, and logical conflicts, providing technical support for the system to enter a safe state and meeting the needs of high-safety scenarios such as autonomous driving.

[0082] Figure 2 A block diagram of a multi-core processor system 200 according to one embodiment of the present application is illustrated. Figure 2 As shown, the multi-core processor system 200 includes multiple processing cores 202A, 202B, 202C, ..., 202N. Among the multiple processing cores, processing core 0202A is the management core, and the remaining processing cores 1-n 202B, 202C, ..., 202N are processing cores that execute tasks to be processed.

[0083] In some implementation schemes of this application, the management core 202A plays the role of monitoring task triggering, task waiting, task scheduling, and task execution, and can record exceptions when tasks are abnormal.

[0084] In some embodiments of this application, when a new task is received, the attribute parameters of the new task are obtained. These attribute parameters include one or more of the following: the maximum allowed waiting time of the task, the estimated execution time of the task, the original priority of the task, the priority adjustment coefficient of the task, and whether the task is allowed to be forcibly terminated. Furthermore, in some embodiments of this application, when a new task is received, it is inserted into the task queue to be executed according to its priority.

[0085] Figure 3 A flowchart illustrating a task scheduling method 300 according to one embodiment of this application is shown. Figure 3 As shown, in step 302, the status information of the multiple processing cores 202A, 202B, 202C, ..., 202N is acquired in real time. Then, in step 304, it is determined whether the management core 202A is faulty. If the management core 202A is normal, the task scheduling algorithm continues to be executed by the management core 202A. If the management core 202A is faulty, another processing core other than processing core 202A among the multiple processing cores 202A, 202B, 202C, ..., 202N is designated as the new management core, that is, the task scheduling algorithm is executed by the new management core, step 306. In some embodiments of this application, when processing core 0 202A fails, the scheduling algorithm is shifted to be executed by processing core 1202B, and the tasks to be processed are assigned to the remaining processing cores 2-n 202C, ..., 202N for execution.

[0086] In the implementation scheme of this application, the task scheduling method is temporarily fixed to be executed by one processing core. Then, when the processing core fails, the task scheduling method is moved to another processing core for execution. This avoids the problem that the task scheduling method cannot continue to be scheduled when the processing core is faulty. At the same time, when there are multiple processing cores, the scheduling algorithm itself is not dynamically executed by multiple processing cores. This eliminates the need for stack and push operations in different processing cores, saves execution time, and improves the overall efficiency of the system.

[0087] Figure 4 A flowchart illustrating a task scheduling method 400 according to one embodiment of this application is shown. Figure 4 As shown, in step 402, the status information of the multiple processing cores 202A, 202B, 202C, ..., 202N is acquired in real time. Then, in step 404, it is determined whether there is a processing core failure, and in step 406, it is determined whether the system is in a low-power state. If there is a processing core failure or the system is in a low-power state, the tasks to be processed in the task queue are assigned to the designated available processing cores, step 408. In the implementation scheme of this application, processing cores are not only searched for and indiscriminately scheduled based on the dynamic execution parameters of the tasks, but the task scheduling of the processing cores is dynamically adjusted according to the status of the processing cores and the processing system itself, making the task scheduling more reasonable.

[0088] Figure 5 A flowchart illustrating a task scheduling method 500 according to one embodiment of this application is shown. For example... Figure 5 As shown, in step 502, it is determined whether the original priority of the task to be processed plus the priority adjustment value of the task to be processed is less than or equal to the maximum allowed priority of the task to be processed. If yes, the new priority of the task to be processed is set to the original priority of the task to be processed plus the priority adjustment value of the task to be processed, step 504; if no, the new priority of the task to be processed is set to the maximum allowed priority of the task to be processed, step 506. In some embodiments of this application, the priority adjustment value of the task to be processed is equal to the product of the allocation waiting time of the task to be processed and the adjustment coefficient, rounded down.

[0089] In some embodiments of this application, the priority of some tasks can be changed, but the priority of a task is limited to a certain range based on its own attributes. In one embodiment of this application, particularly in the scenario of an in-vehicle controller, the priority range of the air conditioning switch task will not exceed the priority range of the braking task.

[0090] In the implementation scheme of this application, the priority of the pending tasks is adjusted based on the allocation waiting time of the pending tasks in the pending task queue. Considering that the relative priority of tasks may change dynamically based on the scenario, the priority can be flexibly adjusted.

[0091] Figure 6 A flowchart illustrating a task scheduling method 600 according to one embodiment of this application is shown. Figure 6As shown, in step 602, the estimated execution time of the task is obtained; then, in step 604, the tasks in the task queue are allocated to different idle processing cores according to their estimated execution times, so that the completion times of the tasks executed by different processing cores are staggered. In the embodiment of this application, by staggering the completion times of the tasks executed by different processing cores, the waiting time of idle processing cores is reduced, and the overall system efficiency is improved.

[0092] In some implementations, the difference between the estimated execution time of one or more tasks assigned to an idle processing core and the estimated execution time of one or more tasks subsequently assigned to another idle processing core is greater than or equal to a preset time interval. In an exemplary embodiment of this application, the preset time interval is 2ms. In the implementations of this application, tasks are neither assigned individually nor simultaneously in batches to multiple idle processing cores. Instead, one or more tasks are sequentially assigned to each idle processing core based on their possible execution times. This reduces the waiting time of idle processing cores, improves system efficiency, and avoids coordination difficulties and the inability to control the load on processing cores during waiting times.

[0093] Figure 6a A flowchart illustrating a task scheduling method 600a according to another embodiment of this application is shown. Figure 6a As shown, in step 605, the first task to be processed is assigned to the first idle processing core; then, in step 606, it is determined whether the absolute value of the difference between the estimated execution time of the second task to be processed and the estimated execution time of the first task to be processed is greater than or equal to a preset time interval. If yes, the second task to be processed is assigned to the second idle processing core, step 607; if no, it is determined whether the absolute value of the difference between the sum of the estimated execution times of the second and third tasks to be processed and the estimated execution time of the first task to be processed is greater than or equal to a preset time interval, step 608. If yes, the second and third tasks to be processed are assigned to the second idle processing core, step 609; if no, the second, third, and fourth tasks to be processed are assigned to the second idle processing core, step 610.

[0094] exist Figure 6aIn the implementation scheme, "first," "second," "third," and "fourth" in the first, second, third, and fourth pending tasks indicate the allocation order of the pending tasks, and "first" and "second" in the first and second idle processing cores indicate the allocation order of the idle processing cores with equally allocated tasks. In the implementation scheme of this application, by allocating one or more tasks together to a processing core based on their possible execution time, the processing cores are not assigned tasks at approximately the same time, thus ensuring that each processing core does not frequently enter idle periods. This effectively reduces the probability of multiple processing cores entering idle periods simultaneously and improves the system's processing efficiency.

[0095] In some embodiments of this application, when the difference between the estimated execution time of the second, third, and fourth pending tasks and the estimated execution time of the first pending task is less than a preset time interval, the second, third, and fourth pending tasks are assigned to the second idle processing core. In this embodiment, although the sum of the estimated execution times of the tasks assigned to the second idle processing core is less than the estimated execution time of the tasks assigned to the first idle processing core, three pending tasks are still assigned to the second idle processing core, so that a maximum of three pending tasks are assigned to the second idle processing core. Furthermore, in some embodiments of this application, when assigning tasks to the third idle processing core, the estimated execution time of one or more tasks pre-assigned to the third idle processing core is also compared with the estimated execution time of one or more tasks assigned to the second idle processing core.

[0096] In some implementations, the tasks to be processed are arranged in descending order of priority in the task queue. Furthermore, in some implementations, the idle processing cores are arranged in descending order of their idle time.

[0097] Although the invention has been described with reference to preferred embodiments, various modifications can be made and components can be replaced with equivalents without departing from the scope of the invention. In particular, the technical features mentioned in the various embodiments can be combined in any manner as long as there is no structural conflict. The invention is not limited to the specific embodiments disclosed herein, but includes all technical solutions falling within the scope of the claims.

Claims

1. A task scheduling method, characterized by, The task scheduling method includes: When the first task is in an abnormal execution state, determine whether the first task can be forcibly terminated. If the first task cannot be forcibly terminated, report the abnormal execution status of the first task to the second task associated with the first task; and When the duration of the first task being in an abnormal execution state reaches the predetermined waiting time and no termination instruction for the first task is received, the execution of the first task is forcibly terminated or task scheduling for the processing core executing the first task is stopped. When the first task that is forcibly terminated is the last task in the processing core that executes the first task, a new task is assigned to the processing core that executes the first task. The task scheduling method is applicable to multi-core processor systems, which contain multiple processing cores.

2. The task scheduling method of claim 1, wherein, The execution exception status includes one or more of the following statuses: task execution timeout, task memory usage exceeding limits, and task stack usage exceeding limits.

3. The task scheduling method according to claim 1 or 2, characterized in that, The predetermined waiting time is determined based on the priority of the first task.

4. The task scheduling method of claim 1, wherein, The task scheduling method includes: If the first task can be forcibly terminated, then forcibly terminate the first task.

5. The task scheduling method according to claim 1, 2 or 4, characterized in that, The task scheduling method includes: When the first task that is forcibly terminated is not the last task in the processing core that executes the first task, the processing core that executes the first task is ordered to sequentially execute the next task assigned to it.

6. The task scheduling method of claim 1, wherein, The task scheduling method is executed by one of the plurality of processing cores, and the task scheduling method includes: Real-time acquisition of the status information of the multiple processing cores; and When the processing core executing the task scheduling method fails, the task scheduling method is executed by another processing core among the plurality of processing cores.

7. The task scheduling method of claim 6, wherein, The task scheduling method includes: The tasks to be processed in the queue are assigned to processing cores other than the processing cores that execute the task scheduling method.

8. The task scheduling method according to any one of claims 6-7, characterized in that, When one or more of the processing cores fail or the multi-core processing system is in a low-power operating state, the tasks to be processed in the task queue are assigned to the specified available processing cores.

9. The task scheduling method according to any one of claims 1, 2, 4, 6 and 7, characterized in that, The task scheduling method includes: The priority of the pending tasks is adjusted based on the allocation waiting time of the pending tasks in the pending task queue.

10. The task scheduling method of claim 9, wherein, Adjusting the priority of pending tasks based on their allocation waiting time in the pending task queue includes: When the original priority of the task to be processed plus the priority adjustment value of the task to be processed is less than or equal to the maximum allowed priority of the task to be processed, the priority of the task to be processed is set to the original priority of the task to be processed plus the priority adjustment value, wherein the priority adjustment value is obtained by rounding down the product of the allocated waiting time of the task to be processed and the adjustment coefficient; and When the original priority of the task to be processed plus the priority adjustment value is greater than the maximum allowed priority of the task to be processed, the priority of the task to be processed is set to the maximum allowed priority of the task to be processed.

11. The task scheduling method according to any one of claims 1, 2, 4, 6 and 7, characterized in that, When a new task is received, the attribute parameters of the new task are obtained. The attribute parameters include one or more of the following items: the maximum allowed waiting time of the task, the estimated execution time of the task, the original priority of the task, the priority adjustment coefficient of the task, and whether the task is allowed to be forcibly terminated.

12. The task scheduling method according to any one of claims 1, 2, 4, 6 and 7, characterized in that, The task scheduling method includes: Based on the estimated execution time of the tasks in the task queue, the tasks in the task queue are assigned to different idle processing cores, so that the completion time of the tasks on different processing cores is staggered.

13. The task scheduling method according to claim 12, characterized in that, The difference between the sum of the estimated execution times of one or more tasks assigned to an idle processing core and the sum of the estimated execution times of one or more tasks subsequently assigned to another idle processing core is greater than or equal to a preset time interval.

14. The task scheduling method of claim 12, wherein, Tasks are assigned based on the estimated execution time of tasks in the pending task queue, including: Assign the first pending task to the first idle processing core; When the difference between the estimated execution time of the second task to be processed and the estimated execution time of the first task to be processed is greater than or equal to a preset time interval, the second task to be processed is assigned to the second idle processing core. When the difference between the estimated execution time of the second task to be processed and the estimated execution time of the first task to be processed is less than a preset time interval, it is determined whether the difference between the sum of the estimated execution times of the second task to be processed and the third task to be processed and the estimated execution time of the first task to be processed is greater than or equal to the preset time interval. When the difference between the estimated execution time of the second and third pending tasks and the estimated execution time of the first pending task is greater than or equal to a preset time interval, the second and third pending tasks are assigned to the second idle processing core; and When the difference between the estimated execution time of the second and third pending tasks and the estimated execution time of the first pending task is less than a preset time interval, the second, third, and fourth pending tasks are assigned to the second idle processing core.

15. The task scheduling method according to any one of claims 1, 2, 4, 6 and 7, characterized in that, The tasks to be processed are arranged in descending order of priority according to the tasks in the task queue.

16. The task scheduling method according to any one of claims 1, 2, 4, 6 and 7, characterized in that, The idle processing cores are arranged in descending order of their idle time.

17. A computer-readable storage medium storing instructions that, when executed by a processor, cause the processor to perform the task scheduling method according to any one of claims 1 to 16.

18. A multi-core processor system, comprising: The multi-core processor system includes multiple processing cores, one of which is configured as a management core for performing task scheduling. The management core is configured to execute the task scheduling method according to any one of claims 1 to 16.