WO2023122891A1 - Task scheduling method and multi-core processor system - Google Patents

Task scheduling method and multi-core processor system Download PDF

Info

Publication number
WO2023122891A1
WO2023122891A1 PCT/CN2021/141693 CN2021141693W WO2023122891A1 WO 2023122891 A1 WO2023122891 A1 WO 2023122891A1 CN 2021141693 W CN2021141693 W CN 2021141693W WO 2023122891 A1 WO2023122891 A1 WO 2023122891A1
Authority
WO
WIPO (PCT)
Prior art keywords
task
scheduling method
processed
tasks
pending
Prior art date
Application number
PCT/CN2021/141693
Other languages
French (fr)
Chinese (zh)
Inventor
段贵江
吴成鼎
Original Assignee
宁德时代新能源科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 宁德时代新能源科技股份有限公司 filed Critical 宁德时代新能源科技股份有限公司
Priority to PCT/CN2021/141693 priority Critical patent/WO2023122891A1/en
Priority to CN202180101376.XA priority patent/CN117751351A/en
Publication of WO2023122891A1 publication Critical patent/WO2023122891A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]

Definitions

  • the present application relates to the field of computer technology, in particular to a task scheduling method and a multi-core processor system.
  • SOA Service-Oriented Architecture
  • the on-board controller it is necessary to introduce functions developed by third parties to create a digital ecosystem to meet consumers' diverse driving/riding scene experience, but also to ensure driving safety. Because, reasonable scheduling is required for a large number of tasks that need to be handled by the on-board controller.
  • the present application proposes a task scheduling method, a multi-core processor system, and a computer-readable storage medium.
  • the first aspect of the present invention provides a kind of task scheduling method, and this task scheduling method comprises:
  • the execution of the first task is forcibly terminated or the task scheduling for the processing core executing the first task is stopped. .
  • tasks have different priorities.
  • low-level tasks can be forcibly terminated immediately
  • middle-level tasks can be forcibly terminated after receiving instructions or delays
  • high-level tasks cannot If it can be terminated forcibly, the task scheduling of the processing core executing the abnormal task is stopped.
  • the abnormal task is terminated after a delay, neither the abnormal program will be forcibly terminated, nor will the abnormal program be left alone, which avoids further damage caused by the abnormal program expanding the scope of the fault, and avoids Abnormalities such as system crashes, flashbacks, restarts, and logic conflicts provide technical support for the system to enter a safe state.
  • the abnormal state of the first task when the first task is in an execution abnormal state, the abnormal state of the first task is recorded. By recording abnormal tasks, it provides data assurance for problem analysis of third-party applications and whether new applications can be deployed.
  • the abnormal state of the first task is sent to the system application, and the system application judges whether to execute the second task based on the abnormal state.
  • a processing core of a task issues a termination command of the first task.
  • the system application includes a health management module.
  • the execution exception state includes one or more of the following states: task execution timeout state, memory used by the task exceeds the limit, and stack used by the task exceeds the limit.
  • the predetermined waiting time is determined based on the priority of the first task.
  • the task scheduling method includes: when the first task can be forcibly terminated, forcibly terminating the first task.
  • the task scheduling method includes: when the first task that is forcibly terminated is the last task in the processing core executing the first task, assigning a new task to the processing core executing the first task .
  • the task scheduling method includes: when the first task that is forcibly terminated is not the last task in the processing core executing the first task, ordering the processing core executing the first task to execute sequentially as The next task assigned.
  • the processing core executing the abnormal task is released, and the system crash is avoided.
  • the task scheduling method is applicable to a multi-core processor system, and the multi-core processor system includes multiple processing cores.
  • the task scheduling method is executed by a processing core in the plurality of processing cores, the task scheduling method includes:
  • the task scheduling method is temporarily fixed to be executed by one processing core, and then the task scheduling method is moved to another processing core for execution when the processing core fails, so as to avoid the processing core failure of the execution task scheduling method
  • the processing core executing the task scheduling method plays the role of monitoring task triggering, task waiting, task scheduling, and task execution, and can record abnormalities when tasks are abnormal.
  • the task scheduling method includes: allocating the pending tasks in the pending task queue to processing cores other than the processing core executing the task scheduling method among the plurality of processing cores.
  • the tasks to be processed in the task queue to be processed are allocated to available specified processing core.
  • the processing cores searched for indiscriminate scheduling according to the dynamic execution parameters of the tasks but also 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.
  • 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 scene, this application
  • the implementation scheme realizes the flexible adjustment of the priority.
  • the task scheduling method includes: adjusting the priority of the pending tasks based on the allocated waiting time of the pending tasks in the pending task queue.
  • the scheduling order of the tasks to be processed in the task queue to be processed is adjusted based on the first-in-first-out and priority criteria.
  • adjusting the priority of the above-mentioned tasks to be processed based on the assigned waiting time of the tasks to be processed in the task queue to be processed includes:
  • the priority of the task to be processed is set to the maximum allowable priority of the task to be processed.
  • the attribute parameters of the new task to be processed are obtained, and the above attribute parameters include one or more of the following items: the maximum allowable waiting time of the task, the scheduled time of the task The estimated execution time, the original priority of the task, the priority adjustment factor of the task, and whether the task is allowed to be forced to terminate.
  • the task scheduling method includes: assigning tasks in the pending task queue to different idle processing cores according to the estimated execution time of the tasks in the pending task queue, so that different processing cores execute tasks Completion times are staggered.
  • the difference between the sum of the estimated execution times of one or more tasks assigned to one idle processing core and the sum of the estimated execution times of one or more tasks successively assigned to another idle processing core greater than or equal to the preset time interval.
  • the preset time interval is 2ms.
  • neither tasks are allocated individually one by one, nor tasks are allocated to multiple idle processing cores in batches at the same time, but one or more tasks are allocated to each idle processing core sequentially according to the possible execution time of the task,
  • the waiting time of the idle processing core is reduced, the system efficiency is improved, and the coordination difficulty of tasks during the waiting time and the problem of being unable to control the processing core load are avoided at the same time.
  • allocating tasks based on estimated execution times of tasks in the queue of pending tasks includes:
  • the second pending task When the difference between the sum of the estimated execution time of the second pending task and the third pending task and the estimated execution time of the first pending task is greater than or equal to the preset time interval, the second pending task
  • the processing task and the third task to be processed are allocated to the second idle processing core;
  • the second pending task When the difference between the sum of the estimated execution time of the second pending task and the third pending task and the estimated execution time of the first pending task is less than a preset time interval, the second pending task The task, the third task to be processed and the fourth task to be processed are allocated to the second idle processing core.
  • first”, “second”, “third” and “Fourth” indicates the allocation order of tasks to be processed
  • “first” and “second” in the first idle processing core and the second idle processing core indicate the allocation order of idle processing cores that are equally allocated tasks.
  • one or more tasks are assigned to a certain processing core according to the possible execution time of the task, so that each processing core is not assigned a task at an approximate time, thereby ensuring that each processing core does not frequently Entering the idle time can effectively reduce the probability that multiple processing cores enter the idle time at the same time, and improve the processing efficiency of the system.
  • the assignment order of the tasks to be processed is arranged in order from high to low.
  • the allocation order of the above idle processing cores is arranged in descending order.
  • the second aspect of the present application provides a computer-readable storage medium, the computer-readable storage medium stores instructions, and when the above-mentioned instructions are executed by a processor, the above-mentioned instructions cause the processor to implement the method according to the above-mentioned first aspect. Task scheduling method.
  • a third aspect of the present application provides a multi-core processor system, the multi-core processor system includes a plurality of processing cores, one of the processing cores in the plurality of processing cores is configured as a management core for executing task scheduling;
  • the management core is configured to execute the task scheduling method according to the first aspect above.
  • the fourth aspect of the present application provides a task scheduling method, the task scheduling method includes: assigning tasks in the pending task queue to different idle processing cores according to the estimated execution time of the tasks in the pending task queue, The completion time of tasks performed by different processing cores is staggered.
  • the fifth aspect of the present application provides a task scheduling method, the task scheduling method is suitable for a multi-core processor system, the multi-core processor system includes a plurality of processing cores;
  • the task scheduling method is executed by one processing core in the plurality of processing cores, and the task scheduling method includes:
  • FIG. 1 illustrates a flowchart of a task scheduling method 100 according to an embodiment of the present application
  • Figure 1a illustrates a flowchart of a task scheduling method 100a according to another embodiment of the present application
  • FIG. 2 illustrates a block diagram of a multi-core processor system 200 according to one embodiment of the present application
  • FIG. 3 illustrates a flowchart of a task scheduling method 300 according to an embodiment of the present application
  • FIG. 4 illustrates a flowchart of a task scheduling method 400 according to an embodiment of the present application
  • FIG. 5 illustrates a flowchart of a task scheduling method 500 according to an embodiment of the present application
  • Figure 6 illustrates a flow chart of a task scheduling method 600 according to an embodiment of the present application.
  • Fig. 6a illustrates a flowchart of a task scheduling method 600a according to another embodiment of the present application.
  • first and second are only used to distinguish different objects, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features , in a particular order or in a primary or secondary relationship, unless otherwise indicated.
  • an embodiment means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the present application.
  • the occurrences of this phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is understood explicitly and implicitly by those skilled in the art that the embodiments described herein can be combined with other embodiments.
  • the term “and/or” is only an association relationship describing associated objects, which means that there may be three relationships, such as A and/or B, which may mean: there is A, and there is A at the same time and B, there are three cases of B.
  • the character "/" in this article generally indicates that the contextual objects are an "or” relationship.
  • the term “plurality” refers to two or more (including two), unless otherwise clearly and specifically defined.
  • conventional scheduling algorithms classify tasks at different levels into different scheduling classes using different algorithms, resulting in overly complex algorithms for task allocation and poor program maintainability.
  • conventional scheduling algorithms do not take into account the impact of scene changes on scheduling; conventional scheduling algorithms only use the dynamic execution parameters of tasks to find processing cores and perform undifferentiated scheduling. state, tasks may be assigned to invalid processing cores.
  • the inventor also found that when the scheduling algorithm is dynamically executed by multiple processing cores, it is often necessary to stack and push the data in different processing cores, resulting in a long execution time of the scheduling algorithm itself; while the scheduling algorithm is fixed by a When the main core is executing, if the main core fails, the scheduling algorithm cannot continue to be executed. In addition, when the task processing times out, the conventional scheduling algorithm often directly terminates the task, which can easily lead to system crashes, flashbacks, restarts, logic conflicts and other abnormalities.
  • the inventor also realized that the conventional scheduling algorithm either assigns individual tasks to idle processing cores one by one, which easily leads to too much waiting time for idle processing cores, or assigns multiple tasks to multiple idle processing cores in batches, which easily leads to task Coordination difficulties during waiting times and the inability to manage nuclear loads.
  • the inventors designed a task scheduling method and a multi-core processor system to adapt to the requirements of applications such as automatic driving for functional complexity, scene diversification, functional individualization, and system security. and real-time requirements.
  • Fig. 1 illustrates a flowchart of a task scheduling method 100 according to an embodiment of the present application.
  • step 102 it is judged whether the executed task is in an abnormal execution state; if yes, it is judged whether the task can be forcibly terminated, step 104 . If the task cannot be forcibly terminated, then report the execution exception status of the task to other tasks associated with the task, step 108 . Then, wait to receive processing instructions for the task from other tasks, and determine whether waiting to receive processing instructions for the task times out, step 110 .
  • Task scheduling step 114. If a processing instruction of the task is received within the predetermined waiting time, the task is processed according to the received processing instruction (step 112 ).
  • the execution exception state includes one or more of the following states: task execution timeout state, memory used by the task exceeds the limit, and stack used by the task exceeds the limit.
  • the predetermined waiting time is determined according to the priority of the task.
  • the abnormal state of the task when the task is in an abnormal execution state, the abnormal state of the task is recorded.
  • the abnormal state of the task By recording abnormal tasks, it provides data assurance for problem analysis of third-party applications and whether new applications can be deployed.
  • the operating system reports the failure of the program process, And provide a certain response time for other related processes. If the operating system instructs to close the program process after receiving the fault alarm, it directly closes the program process. If the operating system does not give or receive processing instructions for the process for a long time, the operating system closes the faulty process after a timeout.
  • the operating system during automatic parking, if the taillight program fails, the operating system will set the failure and wait for other application programs to process, such as slowing down, parking, exiting the automatic driving mode, etc.; If there is no indication feedback, the operating system forcibly shuts down the process in order to prevent the process from expanding the fault range and causing further harm.
  • Fig. 1a illustrates a flowchart of a task scheduling method 100a according to another embodiment of the present application.
  • Figure 1a is similar to Figure 1, so the same steps will not be repeated.
  • step 101 monitor the execution status of the task; then, judge whether the task is in an abnormal state according to the execution status of the task, step 102 . If the task is not in an abnormal state, it is judged whether the execution of the task is completed, step 103 . If the task is not completed, return to step 101 to continue monitoring the execution of the task.
  • the task is terminated directly (step 106 ).
  • the task to be forcibly terminated is the last task in the processing core executing the task, assign a new task to the processing core executing the task;
  • the processing core executing the task is ordered to execute the next task assigned to it in sequence.
  • FIG. 2 illustrates a block diagram of a multi-core processor system 200 according to one embodiment of the present application.
  • the multi-core processor system 200 includes a plurality of processing cores 202A, 202B, 202C, . . . , 202N.
  • processing core 0 202A is a management core
  • the remaining processing cores 1-n 202B, 202C, ..., 202N are processing cores for executing tasks to be processed.
  • the management core 202A plays a role of monitoring task triggering, task waiting, task scheduling, and task execution, and can record abnormalities when tasks are abnormal.
  • the attribute parameters of the new task are obtained, and the attribute parameters include one or more of the following items: the maximum allowable 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 allows forced termination, etc.
  • the new task is inserted into the task queue to be executed according to the priority of the new task.
  • FIG. 3 illustrates a flowchart of a task scheduling method 300 according to an embodiment of the present application.
  • step 302 the state information of the above-mentioned multiple processing cores 202A, 202B, 202C, . . . , 202N is obtained in real time.
  • step 304 it is determined whether the management core 202A is faulty. If the management core 202A is normal, the management core 202A continues to execute the task scheduling algorithm.
  • the management core 202A fails, another processing core other than the processing core 202A in the multiple processing cores 202A, 202B, 202C, ..., 202N is used as a new management core, that is, the new management core executes the task scheduling algorithm, Step 306.
  • the scheduling algorithm is shifted to be executed by the processing core 1 202B, and the tasks to be processed are assigned to the remaining processing cores 2-n 202C, ..., 202N for execution.
  • the task scheduling method is temporarily fixed to be executed by one processing core, and then the task scheduling method is moved to another processing core for execution when the processing core fails, so as to avoid the processing core failure of the execution task scheduling method
  • FIG. 4 illustrates a flowchart of a task scheduling method 400 according to an embodiment of the present application.
  • step 402 the state information of the above-mentioned multiple processing cores 202A, 202B, 202C, . . . , 202N is obtained in real time.
  • 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 consumption state. If there is a processing core failure or the system is in a low power consumption state, the pending tasks in the pending task queue are assigned to available designated processing cores, step 408 .
  • the processing cores searched for indiscriminate scheduling according to the dynamic execution parameters of the tasks are searched for indiscriminate scheduling according to the dynamic execution parameters of the tasks, but also 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.
  • FIG. 5 illustrates a flowchart of a task scheduling method 500 according to an embodiment of the present application.
  • step 502 whether the original priority of the pending task plus the priority adjustment value of the pending task is less than or equal to the maximum allowable priority of the pending task. If yes, then 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 will be set to Maximum allowed priority of pending tasks, step 506 .
  • the priority adjustment value of the task to be processed is equal to the rounded integer of the product of the assigned waiting time of the task to be processed and the adjustment coefficient.
  • the priorities of some tasks can be changed, but the priorities of tasks are limited within a certain range according to their own attributes.
  • the priority range of the air-conditioning switching task will not exceed the priority range of the braking task.
  • the priority of the pending tasks is adjusted based on the assigned waiting time of the pending tasks in the pending task queue. Considering that the relative priority of the tasks will change dynamically based on the scene, the priority of the tasks is realized. Flexible adjustment.
  • FIG. 6 illustrates a flowchart of a task scheduling method 600 according to an embodiment of the present application.
  • the estimated execution time of the task is acquired; then, in step 604, the tasks in the pending task queue are allocated to different idle tasks according to the estimated execution time of the tasks in the pending task queue
  • the processing cores enable different processing cores to stagger the completion time of tasks. In the embodiment of the present application, by staggering the completion time of different processing cores to execute tasks, the waiting time of idle processing cores is reduced, and the overall efficiency of the system is improved.
  • the difference between the sum of the estimated execution times of one or more tasks assigned to one idle processing core and the sum of the estimated execution times of one or more tasks successively assigned to another idle processing core greater than or equal to the preset time interval.
  • the preset time interval is 2ms. In the embodiment of the present application, neither tasks are allocated individually one by one, nor tasks are allocated to multiple idle processing cores in batches at the same time, but one or more tasks are allocated to each idle processing core sequentially according to the possible execution time of the task, The waiting time of the idle processing core is reduced, the system efficiency is improved, and the coordination difficulty of tasks during the waiting time and the problem of being unable to control the processing core load are avoided at the same time.
  • Fig. 6a illustrates a flowchart of a task scheduling method 600a according to another embodiment of the present application.
  • the first task to be processed is assigned to the first idle processing core; then, in step 606, it is judged that the estimated execution time of the second task to be processed is different from the estimated execution time of the first task to be processed Whether the absolute value of the execution time difference is greater than or equal to the preset time interval.
  • step 607 assigns the second task to be processed to the second idle processing core, step 607; if not, judge the sum of the estimated execution time of the second task to be processed and the third task to be processed and the first task to be processed Whether the absolute value of the difference of the estimated execution time is greater than or equal to the preset time interval, step 608 . If yes, assign the second task to be processed and the third task to be processed to the second idle processing core, step 609; if not, assign the second task to be processed, the third task to be processed and the fourth task to be processed To the second idle processing core, step 610.
  • the "first”, “second”, “third” and “second” in the first pending task, the second pending task, the third pending task and the fourth pending task Four" indicates the allocation order of tasks to be processed
  • "first" and "second” in the first idle processing core and the second idle processing core indicate the allocation order of idle processing cores that are equally allocated tasks.
  • one or more tasks are assigned to a certain processing core according to the possible execution time of the task, so that each processing core is not assigned a task at an approximate time, thereby ensuring that each processing core does not frequently Entering the idle time can effectively reduce the probability that multiple processing cores enter the idle time at the same time, and improve the processing efficiency of the system.
  • the second task to be processed, the third task to be processed and the fourth task to be processed are allocated to the second idle processing core.
  • 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 first idle processing core. Two idle processing cores, so that a maximum of three tasks to be processed are allocated to the second idle processing core.
  • the estimated execution time of one or more tasks pre-allocated 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. Compare the estimated execution times of one or more tasks of a core.
  • the assignment order of the tasks to be processed is arranged in order from high to low.
  • the allocation order of the above idle processing cores is arranged in descending order.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)
  • Hardware Redundancy (AREA)
  • Retry When Errors Occur (AREA)

Abstract

A task scheduling method, a multi-core processor system, and a computer-readable storage medium. The task scheduling method comprises: 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 the execution abnormal state; and when the duration in which the first task is in the execution abnormal state reaches a predetermined waiting time and a termination instruction for the first task has not been received, forcibly terminating the execution of the first task or stopping task scheduling performed on a processing core that executes the first task.

Description

任务调度方法及多核处理器系统Task scheduling method and multi-core processor system 技术领域technical field
本申请涉及计算机技术领域,特别涉及一种任务调度方法和一种多核处理器系统。The present application relates to the field of computer technology, in particular to a task scheduling method and a multi-core processor system.
背景技术Background technique
在新兴的车载控制器领域,特别是应对自动驾驶需求的域控制器采用面向服务的架构(Service-Oriented Architechture,SOA)已经渐渐成为主流认识。随着汽车智能化的不断推进,车载控制器需要处理的功能越来越复杂,场景越来越多样化,但是单一开发商往往很难独立完成所有的应用开发。此外,与手机软件不同,车载系统的控制更为复杂,在加载各种个性化应用功能的同时,安全性与实时性日渐重要。In the emerging field of vehicle controllers, especially domain controllers that meet the needs of autonomous driving, the use of Service-Oriented Architecture (SOA) has gradually become the mainstream understanding. With the continuous advancement of automobile intelligence, the functions that the on-board controller needs to handle are becoming more and more complex, and the scenarios are becoming more and more diverse. However, it is often difficult for a single developer to complete all application development independently. In addition, unlike mobile phone software, the control of vehicle-mounted systems is more complex. While loading various personalized application functions, security and real-time performance are becoming increasingly important.
对于车载控制器,既要引入第三方开发的功能,打造数字化生态,满足消费者多样化的驾驶/乘坐场景体验,但也要确保行车安全。因为,需要合理的调度需要车载控制器处理的大量任务。For the on-board controller, it is necessary to introduce functions developed by third parties to create a digital ecosystem to meet consumers' diverse driving/riding scene experience, but also to ensure driving safety. Because, reasonable scheduling is required for a large number of tasks that need to be handled by the on-board controller.
发明内容Contents of the invention
鉴于上述问题,本申请提出了一种任务调度方法、多核处理器系统及计算机可读存储介质。In view of the above problems, the present application proposes a task scheduling method, a multi-core processor system, and a computer-readable storage medium.
为此,本发明的第一方面提供了一种任务调度方法,该任务调度方法包括:For this reason, the first aspect of the present invention provides a kind of task scheduling method, and this task scheduling method comprises:
当第一任务处于执行异常状态时,判断该第一任务是否能够被强制终止;When the first task is in an abnormal execution state, judging whether the first task can be forcibly terminated;
在该第一任务不能够被强制终止时,向与该第一任务相关联的第二任务报告该第一任务的执行异常状态;以及When the first task cannot be forcibly terminated, report the execution exception status of the first task to a second task associated with the first task; and
当该第一任务处于执行异常状态的持续时间达到预定等待时间且未接收到该第一任务的终止指令时,强制终止执行该第一任务或停止对执行该第一任务的处理核进行任务调度。When the duration of the first task in the execution abnormal state reaches the predetermined waiting time and the termination instruction of the first task is not received, the execution of the first task is forcibly terminated or the task scheduling for the processing core executing the first task is stopped. .
在本申请的实施方案中,任务具有不同的优先级,在出现异常任务时,低等级的任务可以立即强制终止,中等级的任务待收到指令或延迟后可以强制终止, 高等级的任务不可以强制终止,则停止执行该异常任务的处理核的任务调度。在本申请的实施方案中,根据任务自身特性,选择延时终止异常任务,既不会强行终止异常程序,也不会放任异常程序不管,避免了异常程序扩大故障范围而导致进一步危害,避免了系统崩溃、闪退、重启、逻辑冲突等异常,为系统进入安全状态提供了技术支持。In the embodiment of this application, tasks have different priorities. When abnormal tasks occur, low-level tasks can be forcibly terminated immediately, middle-level tasks can be forcibly terminated after receiving instructions or delays, and high-level tasks cannot If it can be terminated forcibly, the task scheduling of the processing core executing the abnormal task is stopped. In the implementation plan of this application, according to the characteristics of the task itself, the abnormal task is terminated after a delay, neither the abnormal program will be forcibly terminated, nor will the abnormal program be left alone, which avoids further damage caused by the abnormal program expanding the scope of the fault, and avoids Abnormalities such as system crashes, flashbacks, restarts, and logic conflicts provide technical support for the system to enter a safe state.
在本申请的一些实施方案中,当该第一任务处于执行异常状态时,记录该第一任务的异常状态。通过记录异常任务,对于第三方应用程序的问题分析以及是否能够部署新的应用程序等提供了数据保证。In some embodiments of the present application, when the first task is in an execution abnormal state, the abnormal state of the first task is recorded. By recording abnormal tasks, it provides data assurance for problem analysis of third-party applications and whether new applications can be deployed.
在本申请的一些实施方案中,在该第一任务不能够被强制终止时,向系统应用程序发送该第一任务的异常状态,并且由该系统应用程序基于该异常状态判断是否向执行该第一任务的处理核下达该第一任务的终止指令。在一些实施方案中,该系统应用程序包括健康管理模块。In some embodiments of the present application, when the first task cannot be forcibly terminated, the abnormal state of the first task is sent to the system application, and the system application judges whether to execute the second task based on the abnormal state. A processing core of a task issues a termination command of the first task. In some embodiments, the system application includes a health management module.
在一些实施方案中,执行异常状态包括如下状态中的一个或多个:任务执行超时状态,任务使用的内存超限,任务使用的堆栈超限。In some embodiments, the execution exception state includes one or more of the following states: task execution timeout state, memory used by the task exceeds the limit, and stack used by the task exceeds the limit.
在一些实施方案中,根据该第一任务的优先级确定预定等待时间。In some embodiments, the predetermined waiting time is determined based on the priority of the first task.
在一些实施方案中,该任务调度方法包括:在该第一任务能够被强制终止时,强制终止该第一任务。In some embodiments, the task scheduling method includes: when the first task can be forcibly terminated, forcibly terminating the first task.
在本申请的实施方案中,在出现异常任务时,根据任务自身特性,在终止任务和延时终止之间进行选择,满足了自动驾驶等高安全场景的需求。In the embodiment of this application, when an abnormal task occurs, a choice is made between terminating the task and delaying the termination according to the characteristics of the task itself, which meets the requirements of high-safety scenarios such as automatic driving.
在一些实施方案中,该任务调度方法包括:当被强制终止的该第一任务是执行该第一任务的处理核中的最后一个任务时,为执行该第一任务的处理核分配新的任务。In some embodiments, the task scheduling method includes: when the first task that is forcibly terminated is the last task in the processing core executing the first task, assigning a new task to the processing core executing the first task .
在一些实施方案中,该任务调度方法包括:当被强制终止的该第一任务不是执行该第一任务的处理核中的最后一个任务时,命令执行该第一任务的处理核顺序执行为其分配的下一个任务。In some embodiments, the task scheduling method includes: when the first task that is forcibly terminated is not the last task in the processing core executing the first task, ordering the processing core executing the first task to execute sequentially as The next task assigned.
在本申请的实施方案中,通过终止或延迟终止的异常任务,释放了执行异常任务的处理核,避免了系统崩溃。In the embodiment of the present application, by terminating or delaying the termination of the abnormal task, the processing core executing the abnormal task is released, and the system crash is avoided.
在一些实施方案中,该任务调度方法适用于多核处理器系统,上述多核处理器系统包含多个处理核。In some embodiments, the task scheduling method is applicable to a multi-core processor system, and the multi-core processor system includes multiple processing cores.
在一些实施方案中,该任务调度方法由该多个处理核中的一个处理核执行,该任务调度方法包括:In some embodiments, the task scheduling method is executed by a processing core in the plurality of processing cores, the task scheduling method includes:
实时获取上述多个处理核的状态信息;以及Obtaining status information of the plurality of processing cores in real time; and
当执行该任务调度方法的处理核出现故障时,通过上述多个处理核中的另一 个处理核执行该任务调度方法。When the processing core executing the task scheduling method fails, another processing core among the plurality of processing cores executes the task scheduling method.
在本申请的实施方案中,将任务调度方法暂时固定由一个处理核执行,然后在该处理核故障时将任务调度方法移至另一个处理核进行执行,避免了执行任务调度方法的处理核故障时无法继续调度任务的问题;同时,在存在多个处理核的情况下,调度算法本身不是由多个处理核动态执行的,省去了在不同的处理核中执行的堆栈和压栈等需求,节省了执行时间,提高了系统整体效率。In the embodiment of the present application, the task scheduling method is temporarily fixed to be executed by one processing core, and then the task scheduling method is moved to another processing core for execution when the processing core fails, so as to avoid the processing core failure of the execution task scheduling method The problem that tasks cannot be scheduled continuously; at the same time, in the case of multiple processing cores, the scheduling algorithm itself is not dynamically executed by multiple processing cores, eliminating the need for stacking and stacking in different processing cores. , which saves execution time and improves the overall efficiency of the system.
在本申请的实施方案中,执行任务调度方法的处理核起到实施监控任务触发、任务等待、任务调度、任务执行的作用,并且可以在任务异常时记录异常。In the embodiment of the present application, the processing core executing the task scheduling method plays the role of monitoring task triggering, task waiting, task scheduling, and task execution, and can record abnormalities when tasks are abnormal.
在一些实施方案中,该任务调度方法包括:将待处理任务队列中的待处理任务分配到上述多个处理核中执行该任务调度方法的处理核以外的处理核。In some implementations, the task scheduling method includes: allocating the pending tasks in the pending task queue to processing cores other than the processing core executing the task scheduling method among the plurality of processing cores.
在一些实施方案中,当上述多个处理核中的一个或多个处理核故障或上述多核处理系统处于低功耗工作状态时,将待处理任务队列中的待处理任务分配到可使用的指定的处理核。在本申请的实施方案中,不仅仅根据任务的动态执行参数,寻找处理核进行无差别调度,而且根据处理核和处理系统本身的状态,动态调整处理核的任务调度,任务调度更为合理。In some embodiments, when one or more processing cores in the above-mentioned plurality of processing cores fail or the above-mentioned multi-core processing system is in a low power consumption working state, the tasks to be processed in the task queue to be processed are allocated to available specified processing core. In the embodiment of the present application, not only are the processing cores searched for indiscriminate scheduling according to the dynamic execution parameters of the tasks, but also 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.
在本申请的实施方案中,在待处理任务队列中,有些任务的优先级不能够改变,而有些任务的优先级能够改变;考虑到任务的相对优先级会基于场景动态变化的情况,本申请的实施方案实现了优先级的灵活调整。In the embodiment of this application, in the pending task queue, 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 scene, this application The implementation scheme realizes the flexible adjustment of the priority.
在一些实施方案中,该任务调度方法包括:基于待处理任务队列中的待处理任务的分配等待时间调整上述待处理任务的优先级。In some implementations, the task scheduling method includes: adjusting the priority of the pending tasks based on the allocated waiting time of the pending tasks in the pending task queue.
在本申请的一些实施方案中,基于先进先出和优先级的准则,调整待处理任务队列中的待处理任务的调度顺序。In some implementations of the present application, the scheduling order of the tasks to be processed in the task queue to be processed is adjusted based on the first-in-first-out and priority criteria.
在本申请的具体实施方案中,基于待处理任务队列中的待处理任务的分配等待时间调整上述待处理任务的优先级包括:In a specific embodiment of the present application, adjusting the priority of the above-mentioned tasks to be processed based on the assigned waiting time of the tasks to be processed in the task queue to be processed includes:
当上述待处理任务的原始优先级加上上述待处理任务的优先级调整值小于或等于上述待处理任务的最大允许优先级时,将上述待处理任务的优先级设置为上述待处理任务的原始优先级加上该优先级调整值,其中通过对上述待处理任务的分配等待时间与调整系数的乘积取整来获得该优先级调整值;以及When the original priority of the above-mentioned pending task plus the priority adjustment value of the above-mentioned pending task is less than or equal to the maximum allowed priority of the above-mentioned pending task, set the priority of the above-mentioned pending task to the original priority of the above-mentioned pending task The priority is added to the priority adjustment value, wherein the priority adjustment value is obtained by rounding the product of the allocation waiting time of the pending task 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 allowable priority of the task to be processed, the priority of the task to be processed is set to the maximum allowable priority of the task to be processed.
在一些实施方案中,在接收新的待处理任务时,获得该新的待处理任务的属性参数,上述属性参数包括以下项目中的一项或多项:任务的最大允许等待时间,任务的预估执行时间,任务的原始优先级,任务的优先级调整系数以及任务是否 允许强制终止。In some embodiments, when a new task to be processed is received, the attribute parameters of the new task to be processed are obtained, and the above attribute parameters include one or more of the following items: the maximum allowable waiting time of the task, the scheduled time of the task The estimated execution time, the original priority of the task, the priority adjustment factor of the task, and whether the task is allowed to be forced to terminate.
在一些实施方案中,该任务调度方法包括:根据待处理任务队列中的任务的预估执行时间,将待处理任务队列中的任务分配给不同的空闲处理核,使得不同的处理核执行任务的完成时间错开。In some embodiments, the task scheduling method includes: assigning tasks in the pending task queue to different idle processing cores according to the estimated execution time of the tasks in the pending task queue, so that different processing cores execute tasks Completion times are staggered.
在本申请的实施方案中,通过将不同处理核执行任务的完成时间错开,减少了空闲处理核的等待时间,提供了系统整体效率。In the embodiment of the present application, by staggering the completion time of different processing cores to execute tasks, the waiting time of idle processing cores is reduced, and the overall efficiency of the system is improved.
在一些实施方案中,分配给一个空闲处理核的一个或多个任务的预估执行时间的总和与相继分配给另一个空闲处理核的一个或多个任务的预估执行时间的总和的差值大于或等于预设的时间间隔。在本申请的一个示例性实施例中,该预设的时间间隔是2ms。In some embodiments, the difference between the sum of the estimated execution times of one or more tasks assigned to one idle processing core and the sum of the estimated execution times of one or more tasks successively assigned to another idle processing core greater than or equal to the preset time interval. In an exemplary embodiment of the present application, the preset time interval is 2ms.
在本申请的实施方案中,既不是将任务单个逐一分配,也不是同时向多个空闲处理核批量分配任务,而是根据任务可能的执行时间依次为各个空闲处理核分配一个或多个任务,减少了空闲处理核的等待时间,提升了系统效率,同时避免了任务在等待时间内的协调困难以及无法把控处理核负荷的问题。In the embodiment of the present application, neither tasks are allocated individually one by one, nor tasks are allocated to multiple idle processing cores in batches at the same time, but one or more tasks are allocated to each idle processing core sequentially according to the possible execution time of the task, The waiting time of the idle processing core is reduced, the system efficiency is improved, and the coordination difficulty of tasks during the waiting time and the problem of being unable to control the processing core load are avoided at the same time.
在一些实施方案中,根据待处理任务队列中的任务的预估执行时间分配任务包括:In some embodiments, allocating tasks based on estimated execution times of tasks in the queue of pending tasks includes:
将第一待处理任务分配给第一空闲处理核;assigning the first task to be processed to the first idle processing core;
当第二待处理任务的预估执行时间与该第一待处理任务的预估执行时间的差值大于或等于预设的时间间隔时,将该第二待处理任务分配给第二空闲处理核;When the difference between the estimated execution time of the second to-be-processed task and the estimated execution time of the first to-be-processed task is greater than or equal to a preset time interval, assign the second to-be-processed task to a second idle processing core ;
当该第二待处理任务的预估执行时间与该第一待处理任务的预估执行时间的差值小于预设的时间间隔时,判断该第二待处理任务和第三待处理任务的预估执行时间的总和与该第一待处理任务的预估执行时间的差值是否大于或等于预设的时间间隔;When the difference between the estimated execution time of the second to-be-processed task and the estimated execution time of the first to-be-processed task is less than a preset time interval, determine the estimated execution time of the second to-be-processed task and the third to-be-processed task Whether the difference between the sum of the estimated execution time and the estimated execution time of the first task to be processed is greater than or equal to a preset time interval;
当该第二待处理任务和第三待处理任务的预估执行时间的总和与该第一待处理任务的预估执行时间的差值大于或等于预设的时间间隔时,将该第二待处理任务和该第三待处理任务分配给该第二空闲处理核;以及When the difference between the sum of the estimated execution time of the second pending task and the third pending task and the estimated execution time of the first pending task is greater than or equal to the preset time interval, the second pending task The processing task and the third task to be processed are allocated to the second idle processing core; and
当该第二待处理任务和该第三待处理任务的预估执行时间的总和与该第一待处理任务的预估执行时间的差值小于预设的时间间隔时,将该第二待处理任务、该第三待处理任务和第四待处理任务分配给第二空闲处理核。When the difference between the sum of the estimated execution time of the second pending task and the third pending task and the estimated execution time of the first pending task is less than a preset time interval, the second pending task The task, the third task to be processed and the fourth task to be processed are allocated to the second idle processing core.
在本申请的上述实施方案中,第一待处理任务、第二待处理任务、第三待处理任务和第四待处理任务中的“第一”、“第二”、“第三”和“第四”表示待处理任务的分配顺序,第一空闲处理核和第二空闲处理核中的“第一”和“第二”表示等分配任务的空闲处理核的分配顺序。在本申请的实施方案中,通过根据任务可能的执行时间,把一个或多个任务一起分配给某个处理核,使得各个处理核 不以近似时间被分配任务,从而确保各个处理核不至于频繁进入空闲时间,可以有效减少多个处理核同时进入空闲的几率,提高系统的处理效率。In the above embodiments of the present application, "first", "second", "third" and " "Fourth" indicates the allocation order of tasks to be processed, and "first" and "second" in the first idle processing core and the second idle processing core indicate the allocation order of idle processing cores that are equally allocated tasks. In the embodiment of the present application, one or more tasks are assigned to a certain processing core according to the possible execution time of the task, so that each processing core is not assigned a task at an approximate time, thereby ensuring that each processing core does not frequently Entering the idle time can effectively reduce the probability that multiple processing cores enter the idle time at the same time, and improve the processing efficiency of the system.
在本申请的实施方案中,当该第二待处理任务、该第三待处理任务和该第四待处理任务的预估执行时间的总和与该第一待处理任务的预估执行时间的差值小于预设的时间间隔时,将该第二待处理任务、该第三待处理任务和该第四待处理任务分配给第二空闲处理核。在该实施方案中,虽然分配给第二空闲处理核的任务的预估执行时间的总和小于分配给第一空闲处理核的任务的预估执行时间,但是仍将三个待处理任务分配给第二空闲处理核,以使得给第二空闲处理核最多分配三个待处理任务。这样的做原因在于,避免给一个处理核分配过多的任务,分配到一个处理核的任务越多越容易出错,如果第二待处理任务的执行出现异常,则会影响分配到该第二空闲处理核的其他任务的执行。In the embodiment of the present application, when the sum of the estimated execution time of the second pending task, the third pending task, and the fourth pending task is equal to the difference between the estimated execution time of the first pending task When the value is less than the preset time interval, assign the second task to be processed, the third task to be processed and the fourth task to be processed 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 first idle processing core. Two idle processing cores, so that a maximum of three tasks to be processed are allocated to the second idle processing core. The reason for this is to avoid assigning too many tasks to a processing core. The more tasks assigned to a processing core, the more error-prone it is. If the execution of the second pending task is abnormal, it will affect the allocation to the second idle task. Handles the execution of other tasks for the core.
在一些实施方案中,根据待处理任务队列中的待处理任务的优先级由高到低依次排列上述待处理任务的分配顺序。In some implementations, according to the priorities of the tasks to be processed in the task queue to be processed, the assignment order of the tasks to be processed is arranged in order from high to low.
在一些实施方案中,根据空闲处理核的空闲时间由长到短依次排列上述空闲处理核的分配顺序。In some embodiments, according to the idle time of the idle processing cores, the allocation order of the above idle processing cores is arranged in descending order.
本申请的第二方面提供了一种计算机可读存储介质,该计算机可读存储介质存储有指令,当由处理器执行上述指令时,上述指令使该处理器实施根据上述第一方面所述的任务调度方法。The second aspect of the present application provides a computer-readable storage medium, the computer-readable storage medium stores instructions, and when the above-mentioned instructions are executed by a processor, the above-mentioned instructions cause the processor to implement the method according to the above-mentioned first aspect. Task scheduling method.
本申请的第三方面提供了一种多核处理器系统,该多核处理器系统包括多个处理核,上述多个处理核中的一个处理核被配置成用于执行任务调度的管理核;A third aspect of the present application provides a multi-core processor system, the multi-core processor system includes a plurality of processing cores, one of the processing cores in the plurality of processing cores is configured as a management core for executing task scheduling;
该管理核被配置成执行根据上述第一方面所述的任务调度方法。The management core is configured to execute the task scheduling method according to the first aspect above.
本申请的第四方面提供了一种任务调度方法,该任务调度方法包括:根据待处理任务队列中的任务的预估执行时间,将待处理任务队列中的任务分配给不同的空闲处理核,使得不同的处理核执行任务的完成时间错开。The fourth aspect of the present application provides a task scheduling method, the task scheduling method includes: assigning tasks in the pending task queue to different idle processing cores according to the estimated execution time of the tasks in the pending task queue, The completion time of tasks performed by different processing cores is staggered.
本申请的第五方面提供了一种任务调度方法,该任务调度方法适用于多核处理器系统,该多核处理器系统包含多个处理核;并且The fifth aspect of the present application provides a task scheduling method, the task scheduling method is suitable for a multi-core processor system, the multi-core processor system includes a plurality of processing cores; and
该任务调度方法由上述多个处理核中的一个处理核执行,该任务调度方法包括:The task scheduling method is executed by one processing core in the plurality of processing cores, and the task scheduling method includes:
实时获取上述多个处理核的状态信息;以及Obtaining status information of the plurality of processing cores in real time; and
当执行该任务调度方法的处理核出现故障时,通过上述多个处理核中的另一个处理核执行该任务调度方法。When the processing core executing the task scheduling method fails, another processing core among the plurality of processing cores executes the task scheduling method.
附图说明Description of drawings
为了更清楚地说明本申请的技术方案,下面将对本申请实施例中所需要使用的附图作简单地介绍,显而易见地,下面所描述的附图仅仅是本申请的一些实施方案,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据附图获得其他的附图。在附图中:In order to illustrate the technical solution of the present application more clearly, the accompanying drawings that need to be used in the embodiments of the present application will be briefly introduced below. Obviously, the accompanying drawings described below are only some implementations of the present application. Ordinary technicians can also obtain other drawings based on the drawings without creative labor. In the attached picture:
图1例示了根据本申请的一个实施方案的任务调度方法100的流程图;FIG. 1 illustrates a flowchart of a task scheduling method 100 according to an embodiment of the present application;
图1a例示了根据本申请的另一个实施方案的任务调度方法100a的流程图;Figure 1a illustrates a flowchart of a task scheduling method 100a according to another embodiment of the present application;
图2例示了根据本申请的一个实施方案的多核处理器系统200的框图;FIG. 2 illustrates a block diagram of a multi-core processor system 200 according to one embodiment of the present application;
图3例示了根据本申请的一个实施方案的任务调度方法300的流程图;FIG. 3 illustrates a flowchart of a task scheduling method 300 according to an embodiment of the present application;
图4例示了根据本申请的一个实施方案的任务调度方法400的流程图;FIG. 4 illustrates a flowchart of a task scheduling method 400 according to an embodiment of the present application;
图5例示了根据本申请的一个实施方案的任务调度方法500的流程图;FIG. 5 illustrates a flowchart of a task scheduling method 500 according to an embodiment of the present application;
图6例示了根据本申请的一个实施方案的任务调度方法600的流程图;以及Figure 6 illustrates a flow chart of a task scheduling method 600 according to an embodiment of the present application; and
图6a例示了根据本申请的另一个实施方案的任务调度方法600a的流程图。Fig. 6a illustrates a flowchart of a task scheduling method 600a according to another embodiment of the present application.
具体实施方式Detailed ways
下面将结合附图对本申请的实施方案进行详细的描述。以下实施方案仅用于更加清楚地说明本申请的技术方案,因此只作为示例,而不能以此来限制本申请的保护范围。Embodiments of the present application will be described in detail below with reference to the accompanying drawings. The following embodiments are only used to illustrate the technical solution of the present application more clearly, and therefore are only examples, and should not be used to limit the protection scope of the present application.
除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同;本文中所使用的术语只是为了描述具体的实施方案的目的,不是旨在于限制本申请;本申请的说明书和权利要求书及上述附图说明中的术语“包括”和“具有”以及它们的任何变形,意图在于覆盖不排他的包含。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field of the application; the terms used herein are only for the purpose of describing specific embodiments, and are not intended to be To limit this application; the terms "comprising" and "having" and any variations thereof in the specification and claims of this application and the description of the above drawings are intended to cover a non-exclusive inclusion.
在本申请的实施方案的描述中,技术术语“第一”和“第二”等仅用于区别不同对象,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量、特定顺序或主次关系,除非另有指明。In the description of the embodiments of the present application, the technical terms "first" and "second" are only used to distinguish different objects, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features , in a particular order or in a primary or secondary relationship, unless otherwise indicated.
在本文中提及“实施方案”意味着,结合实施方案描述的特定特征、结构或特性可以包含在本申请的至少一个实施方案中。在说明书中的各个位置出现该短语并不一定均是指相同的实施方案,也不是与其它实施方案互斥的独立的或备选的实施方案。本领域技术人员显式地和隐式地理解的是,本文所描述的实施方案可以与其它实施方案相结合。Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the present application. The occurrences of this phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is understood explicitly and implicitly by those skilled in the art that the embodiments described herein can be combined with other embodiments.
在本申请的实施方案的描述中,术语“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如A和/或B,可以表示:存在A,同时 存在A和B,存在B这三种情况。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系。在本申请的实施方案的描述中,术语“多个”指的是两个以上(包括两个),除非另有明确具体的限定。In the description of the embodiments of the present application, the term "and/or" is only an association relationship describing associated objects, which means that there may be three relationships, such as A and/or B, which may mean: there is A, and there is A at the same time and B, there are three cases of B. In addition, the character "/" in this article generally indicates that the contextual objects are an "or" relationship. In the description of the embodiments of the present application, the term "plurality" refers to two or more (including two), unless otherwise clearly and specifically defined.
如果在本说明书或权利要求中按顺序陈述步骤,这未必意味着实施方案或方面限于所陈述的顺序。相反,可以想象还以不同的顺序或者彼此并行地执行所述步骤,除非一个步骤建立在另一步骤上,这绝对需要建立的步骤随后执行(然而这将在个体情况下会变得清晰起来)。因此,所陈述的顺序可以是优选的实施方案。If steps are recited in order in the specification or claims, this does not necessarily mean that the embodiments or aspects are limited to the recited order. Rather, it is conceivable that the steps are also carried out in a different order or in parallel to each other, unless one step builds on another, which absolutely requires that the built-in steps be carried out subsequently (however this will become clear in individual cases) . Therefore, the stated order may be a preferred embodiment.
发明人发现,常规调度算法将不同层次的任务归类到采用不同算法的不同调度类,导致分配任务的算法过于复杂,程序维护性较差。此外,常规调度算法没有考虑到场景变化对调度带来的影响;常规调度算法仅通过任务的动态执行参数来寻找处理核且执行无差别调度,在某个处理核故障或者系统处于低功耗工作状态时,可能会将任务分配到无效的处理核。The inventors found that conventional scheduling algorithms classify tasks at different levels into different scheduling classes using different algorithms, resulting in overly complex algorithms for task allocation and poor program maintainability. In addition, conventional scheduling algorithms do not take into account the impact of scene changes on scheduling; conventional scheduling algorithms only use the dynamic execution parameters of tasks to find processing cores and perform undifferentiated scheduling. state, tasks may be assigned to invalid processing cores.
发明人还发现,在由多个处理核动态执行调度算法时,往往需要在不同的处理核中对数据进行堆栈和压栈,导致调度算法本身的执行时间较长;而在调度算法固定由一个主核执行时,如果主核故障,则无法继续执行调度算法。此外,在任务处理超时的情况下,常规调度算法往往直接终止任务,容易导致系统的崩溃、闪退、重启、逻辑冲突等异常。The inventor also found that when the scheduling algorithm is dynamically executed by multiple processing cores, it is often necessary to stack and push the data in different processing cores, resulting in a long execution time of the scheduling algorithm itself; while the scheduling algorithm is fixed by a When the main core is executing, if the main core fails, the scheduling algorithm cannot continue to be executed. In addition, when the task processing times out, the conventional scheduling algorithm often directly terminates the task, which can easily lead to system crashes, flashbacks, restarts, logic conflicts and other abnormalities.
此外,发明人还意识到,常规调度算法要么将单个任务逐一分配到空闲处理核,易导致空闲处理核的等待时间过多,要么将多个任务批量分配到多个空闲处理核,易导致任务在等待时间内的协调困难以及无法把控处理核负荷的问题。In addition, the inventor also realized that the conventional scheduling algorithm either assigns individual tasks to idle processing cores one by one, which easily leads to too much waiting time for idle processing cores, or assigns multiple tasks to multiple idle processing cores in batches, which easily leads to task Coordination difficulties during waiting times and the inability to manage nuclear loads.
基于以上发现,为了克服常规调度算法存在的问题,本发明人设计了一种任务调度方法和多核处理器系统,以适应自动驾驶等应用对功能复杂性、场景多样化、功能个性化、系统安全性和实时性的需求。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 adapt to the requirements of applications such as automatic driving for functional complexity, scene diversification, functional individualization, and system security. and real-time requirements.
图1例示了根据本申请的一个实施方案的任务调度方法100的流程图。如图1所示,在步骤102,判断执行的任务是否处于执行异常状态;如果是,则判断该任务是否能够被强制终止,步骤104。如果该任务不能够被强制终止,则向与该任务相关联的其他任务报告该任务的执行异常状态,步骤108。然后,等待接收来自其他任务的对该任务的处理指令,并且判断等待接收该任务的处理指令是否超时,步骤110。如果该任务处于执行异常状态的持续时间达到预定等待时间且未接收到该任务的终止指令,即等待接收该任务的处理指令超时,则强制终止执行该任务或停止对执行该任务的处理核进行任务调度,步骤114。如果在预定等待时间内接收到该任务的处理指令,则按照接收到的处理指令对该任务进行处理,步骤112。Fig. 1 illustrates a flowchart of a task scheduling method 100 according to an embodiment of the present application. As shown in FIG. 1 , in step 102 , it is judged whether the executed task is in an abnormal execution state; if yes, it is judged whether the task can be forcibly terminated, step 104 . If the task cannot be forcibly terminated, then report the execution exception status of the task to other tasks associated with the task, step 108 . Then, wait to receive processing instructions for the task from other tasks, and determine whether waiting to receive processing instructions for the task times out, step 110 . If the duration of the task being in the execution abnormal state reaches the predetermined waiting time and the termination instruction of the task is not received, that is, waiting for the processing instruction of the task to be received is timed out, the execution of the task is forcibly terminated or the processing core for executing the task is stopped. Task scheduling, step 114. If a processing instruction of the task is received within the predetermined waiting time, the task is processed according to the received processing instruction (step 112 ).
在本申请的一些实施方案中,执行异常状态包括如下状态中的一个或多个: 任务执行超时状态,任务使用的内存超限,任务使用的堆栈超限。在本申请的一些实施方案中,根据任务的优先级确定预定等待时间。In some embodiments of the present application, the execution exception state includes one or more of the following states: task execution timeout state, memory used by the task exceeds the limit, and stack used by the task exceeds the limit. In some embodiments of the present application, the predetermined waiting time is determined according to the priority of the task.
此外,在本申请的一些实施方案中,当该任务处于执行异常状态时,记录该任务的异常状态。通过记录异常任务,对于第三方应用程序的问题分析以及是否能够部署新的应用程序等提供了数据保证。In addition, in some embodiments of the present application, when the task is in an abnormal execution state, the abnormal state of the task is recorded. By recording abnormal tasks, it provides data assurance for problem analysis of third-party applications and whether new applications can be deployed.
在本申请的一些实施方案中,尤其是在车载控制器的场景中,在程序进程出现故障(例如,内存超限)时,不是简单强制终止程序进程,而是操作系统上报程序进程的故障,并且给其他相关进程提供一定的响应时间。如果操作系统收到故障报警后指示关闭该程序进程,则直接关闭该程序进程。如果操作系统迟迟不给出或接收到对该进程的处理指令,则操作系统在超时后关闭该故障进程。在本申请的一个实施例中,在自动泊车期间,如果尾灯程序故障,则操作系统会置位该故障并等待其他应用程序处理,诸如,降速、停车、退出自动驾驶模式等;如果超时没有指示反馈,则为了避免该进程扩大故障范围,导致进一步危害,操作系统强制关闭该进程。In some embodiments of the present application, especially in the scenario of the on-board controller, when the program process fails (for example, the memory exceeds the limit), instead of simply forcibly terminating the program process, the operating system reports the failure of the program process, And provide a certain response time for other related processes. If the operating system instructs to close the program process after receiving the fault alarm, it directly closes the program process. If the operating system does not give or receive processing instructions for the process for a long time, the operating system closes the faulty process after a timeout. In one embodiment of the present application, during automatic parking, if the taillight program fails, the operating system will set the failure and wait for other application programs to process, such as slowing down, parking, exiting the automatic driving mode, etc.; If there is no indication feedback, the operating system forcibly shuts down the process in order to prevent the process from expanding the fault range and causing further harm.
图1a例示了根据本申请的另一个实施方案的任务调度方法100a的流程图。图1a与图1相似,因此同样的步骤不再累述。如图1a所示,在步骤101,监控任务的执行情况;然后,根据任务的执行情况判断任务是否处于执行异常状态,步骤102。如果任务不处于异常状态,则判断任务是否执行完成,步骤103。如果任务未执行完成,则返回步骤101继续监控任务的执行情况。Fig. 1a illustrates a flowchart of a task scheduling method 100a according to another embodiment of the present application. Figure 1a is similar to Figure 1, so the same steps will not be repeated. As shown in FIG. 1 a , in step 101 , monitor the execution status of the task; then, judge whether the task is in an abnormal state according to the execution status of the task, step 102 . If the task is not in an abnormal state, it is judged whether the execution of the task is completed, step 103 . If the task is not completed, return to step 101 to continue monitoring the execution of the task.
此外,如果该任务能够被强制终止,则直接结束该任务,步骤106。在本申请的一些实施方案中,当被强制终止的任务是执行该任务的处理核中的最后一个任务时,为执行该任务的处理核分配新的任务;当被强制终止的任务不是执行该任务的处理核中的最后一个任务时,命令执行该任务的处理核顺序执行为其分配的下一个任务。In addition, if the task can be forcibly terminated, the task is terminated directly (step 106 ). In some embodiments of the present application, when the task to be forcibly terminated is the last task in the processing core executing the task, assign a new task to the processing core executing the task; When the last task in the processing core of the task is executed, the processing core executing the task is ordered to execute the next task assigned to it in sequence.
在本申请的实施方案中,在出现异常任务时,根据任务自身特性,在终止任务和延时终止之间进行选择,既不会强行终止异常程序,也不会放任异常程序不管,避免了异常程序扩大故障范围而导致进一步危害,避免了系统崩溃、闪退、重启、逻辑冲突等异常,为系统进入安全状态提供了技术支持,满足了自动驾驶等高安全场景的需求。In the embodiment of this application, when an abnormal task occurs, a choice is made between terminating the task and delaying the termination according to the characteristics of the task itself, neither forcibly terminating the abnormal program nor letting the abnormal program go, avoiding the abnormal The program expands the fault range and causes further harm, avoids system crashes, flashbacks, restarts, logic conflicts and other abnormalities, provides technical support for the system to enter a safe state, and meets the needs of high-security scenarios such as automatic driving.
图2例示了根据本申请的一个实施方案的多核处理器系统200的框图。图2所示,多核处理器系统200包含多个处理核202A、202B、202C、……、202N。在多个处理核中,处理核0 202A是管理核,其余处理核1-n 202B、202C、……、202N是执行待处理任务的处理核。FIG. 2 illustrates a block diagram of a multi-core processor system 200 according to one embodiment of the present application. As shown in FIG. 2 , the multi-core processor system 200 includes a plurality of processing cores 202A, 202B, 202C, . . . , 202N. Among the multiple processing cores, processing core 0 202A is a management core, and the remaining processing cores 1- n 202B, 202C, ..., 202N are processing cores for executing tasks to be processed.
在本申请的一些实施方案中,管理核202A起到实施监控任务触发、任务等待、任务调度、任务执行的作用,并且可以在任务异常时记录异常。In some embodiments of the present application, the management core 202A plays a role of monitoring task triggering, task waiting, task scheduling, and task execution, and can record abnormalities when tasks are abnormal.
在本申请的一些实施方案中,在接收新任务时,获取新任务的属性参数,上述属性参数包括以下项目中的一项或多项:任务的最大允许等待时间,任务的预估执行时间,任务的原始优先级,任务的优先级调整系数以及任务是否允许强制终止等。此外,在本申请的一些实施方案中,在接收新任务时,根据新任务的优先级将新任务插入到待执行的任务队列。In some embodiments of the present application, when a new task is received, the attribute parameters of the new task are obtained, and the attribute parameters include one or more of the following items: the maximum allowable 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 allows forced termination, etc. In addition, in some embodiments of the present application, when a new task is received, the new task is inserted into the task queue to be executed according to the priority of the new task.
图3例示了根据本申请的一个实施方案的任务调度方法300的流程图。如图3所示,在步骤302,实时获取上述多个处理核202A、202B、202C、……、202N的状态信息。然后,在步骤304,判断管理核202A是否故障。如果管理核202A正常,则继续由管理核202A执行任务调度算法。如果管理核202A故障,则将多个处理核202A、202B、202C、……、202N中处理核202A以外的另一个处理核作为新的管理核,即由该新的管理核执行任务调度算法,步骤306。在本申请的一些实施方案中,在处理核0 202A出现故障时,将调度算法顺移至由处理核1 202B执行,待处理任务分配至其余处理核2-n 202C、……、202N执行。FIG. 3 illustrates a flowchart of a task scheduling method 300 according to an embodiment of the present application. As shown in FIG. 3 , in step 302 , the state information of the above-mentioned multiple processing cores 202A, 202B, 202C, . . . , 202N is obtained 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 management core 202A continues to execute the task scheduling algorithm. If the management core 202A fails, another processing core other than the processing core 202A in the multiple processing cores 202A, 202B, 202C, ..., 202N is used as a new management core, that is, the new management core executes the task scheduling algorithm, Step 306. In some embodiments of the present application, when the processing core 0 202A fails, the scheduling algorithm is shifted to be executed by the processing core 1 202B, and the tasks to be processed are assigned to the remaining processing cores 2-n 202C, ..., 202N for execution.
在本申请的实施方案中,将任务调度方法暂时固定由一个处理核执行,然后在该处理核故障时将任务调度方法移至另一个处理核进行执行,避免了执行任务调度方法的处理核故障时无法继续调度任务的问题;同时,在存在多个处理核的情况下,调度算法本身不是由多个处理核动态执行的,省去了在不同的处理核中执行的堆栈和压栈等需求,节省了执行时间,提高了系统整体效率。In the embodiment of the present application, the task scheduling method is temporarily fixed to be executed by one processing core, and then the task scheduling method is moved to another processing core for execution when the processing core fails, so as to avoid the processing core failure of the execution task scheduling method The problem that tasks cannot be scheduled continuously; at the same time, in the case of multiple processing cores, the scheduling algorithm itself is not dynamically executed by multiple processing cores, eliminating the need for stacking and stacking in different processing cores. , which saves execution time and improves the overall efficiency of the system.
图4例示了根据本申请的一个实施方案的任务调度方法400的流程图。如图4所示,在步骤402,实时获取上述多个处理核202A、202B、202C、……、202N的状态信息。然后,在步骤404,判断是否有处理核故障,并且在步骤406,判断系统是否处于低功耗状态。如果有处理核故障或者系统处于低功耗状态,则将待处理任务队列中的待处理任务分配到可使用的指定的处理核,步骤408。在本申请的实施方案中,不仅仅根据任务的动态执行参数,寻找处理核进行无差别调度,而且根据处理核和处理系统本身的状态,动态调整处理核的任务调度,任务调度更为合理。FIG. 4 illustrates a flowchart of a task scheduling method 400 according to an embodiment of the present application. As shown in FIG. 4 , in step 402 , the state information of the above-mentioned multiple processing cores 202A, 202B, 202C, . . . , 202N is obtained 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 consumption state. If there is a processing core failure or the system is in a low power consumption state, the pending tasks in the pending task queue are assigned to available designated processing cores, step 408 . In the embodiment of the present application, not only are the processing cores searched for indiscriminate scheduling according to the dynamic execution parameters of the tasks, but also 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.
图5例示了根据本申请的一个实施方案的任务调度方法500的流程图。如图5所示,在步骤502,待处理任务的原始优先级加上待处理任务的优先级调整值是否小于或等于待处理任务的最大允许优先级。如果是,则将待处理任务的新优先级设置为待处理任务的原始优先级加上待处理任务的优先级调整值,步骤504;如果否,则将将待处理任务的新优先级设置为待处理任务的最大允许优先级,步骤506。在本申请的一些实施方案中,待处理任务的优先级调整值等于对待处理任务的分配等待时间与调整系数的乘积取整。FIG. 5 illustrates a flowchart of a task scheduling method 500 according to an embodiment of the present application. As shown in FIG. 5 , in step 502 , whether the original priority of the pending task plus the priority adjustment value of the pending task is less than or equal to the maximum allowable priority of the pending task. If yes, then 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 will be set to Maximum allowed priority of pending tasks, step 506 . In some implementations of the present application, the priority adjustment value of the task to be processed is equal to the rounded integer of the product of the assigned waiting time of the task to be processed and the adjustment coefficient.
在本申请的一些实施方案中,有些任务的优先级是可以改变的,但是任务根据自身的属性,其优先级限定在某一范围内。在本申请的一个实施例中,尤其是在车载控制器的场景中,空调开关任务的优先级所在的范围不会超过制动任务的 优先级所在的范围。In some embodiments of the present application, the priorities of some tasks can be changed, but the priorities of tasks are limited within a certain range according to their own attributes. In an embodiment of the present application, especially in the scenario of the on-board controller, the priority range of the air-conditioning switching task will not exceed the priority range of the braking task.
在本申请的实施方案中,基于待处理任务队列中的待处理任务的分配等待时间调整待处理任务的优先级,考虑到任务的相对优先级会基于场景动态变化的情况,实现了优先级的灵活调整。In the implementation of the present application, the priority of the pending tasks is adjusted based on the assigned waiting time of the pending tasks in the pending task queue. Considering that the relative priority of the tasks will change dynamically based on the scene, the priority of the tasks is realized. Flexible adjustment.
图6例示了根据本申请的一个实施方案的任务调度方法600的流程图。如图6所示,在步骤602,获取任务的预估执行时间;然后,在步骤604,根据待处理任务队列中的任务的预估执行时间将待处理任务队列中的任务分配给不同的空闲处理核,使得不同的处理核执行任务的完成时间错开。在本申请的实施方案中,通过将不同处理核执行任务的完成时间错开,减少了空闲处理核的等待时间,提供了系统整体效率。FIG. 6 illustrates a flowchart of a task scheduling method 600 according to an embodiment of the present application. As shown in Figure 6, in step 602, the estimated execution time of the task is acquired; then, in step 604, the tasks in the pending task queue are allocated to different idle tasks according to the estimated execution time of the tasks in the pending task queue The processing cores enable different processing cores to stagger the completion time of tasks. In the embodiment of the present application, by staggering the completion time of different processing cores to execute tasks, the waiting time of idle processing cores is reduced, and the overall efficiency of the system is improved.
在一些实施方案中,分配给一个空闲处理核的一个或多个任务的预估执行时间的总和与相继分配给另一个空闲处理核的一个或多个任务的预估执行时间的总和的差值大于或等于预设的时间间隔。在本申请的一个示例性实施例中,该预设的时间间隔是2ms。在本申请的实施方案中,既不是将任务单个逐一分配,也不是同时向多个空闲处理核批量分配任务,而是根据任务可能的执行时间依次为各个空闲处理核分配一个或多个任务,减少了空闲处理核的等待时间,提升了系统效率,同时避免了任务在等待时间内的协调困难以及无法把控处理核负荷的问题。In some embodiments, the difference between the sum of the estimated execution times of one or more tasks assigned to one idle processing core and the sum of the estimated execution times of one or more tasks successively assigned to another idle processing core greater than or equal to the preset time interval. In an exemplary embodiment of the present application, the preset time interval is 2ms. In the embodiment of the present application, neither tasks are allocated individually one by one, nor tasks are allocated to multiple idle processing cores in batches at the same time, but one or more tasks are allocated to each idle processing core sequentially according to the possible execution time of the task, The waiting time of the idle processing core is reduced, the system efficiency is improved, and the coordination difficulty of tasks during the waiting time and the problem of being unable to control the processing core load are avoided at the same time.
图6a例示了根据本申请的另一个实施方案的任务调度方法600a的流程图。如图6a所示,在步骤605,将第一待处理任务分配给第一空闲处理核;然后,在步骤606,判断第二待处理任务的预估执行时间与第一待处理任务的预估执行时间的差值的绝对值是否大于或等于预设的时间间隔。如果是,则将第二待处理任务分配给第二空闲处理核,步骤607;如果否,则判断第二待处理任务和第三待处理任务的预估执行时间的总和与第一待处理任务的预估执行时间的差值的绝对值是否大于或等于预设的时间间隔,步骤608。如果是,则将第二待处理任务和第三待处理任务分配给第二空闲处理核,步骤609;如果否,则将第二待处理任务、第三待处理任务和第四待处理任务分配给第二空闲处理核,步骤610。Fig. 6a illustrates a flowchart of a task scheduling method 600a according to another embodiment of the present application. As shown in Figure 6a, in step 605, the first task to be processed is assigned to the first idle processing core; then, in step 606, it is judged that the estimated execution time of the second task to be processed is different from the estimated execution time of the first task to be processed Whether the absolute value of the execution time difference is greater than or equal to the preset time interval. If yes, then assign the second task to be processed to the second idle processing core, step 607; if not, judge the sum of the estimated execution time of the second task to be processed and the third task to be processed and the first task to be processed Whether the absolute value of the difference of the estimated execution time is greater than or equal to the preset time interval, step 608 . If yes, assign the second task to be processed and the third task to be processed to the second idle processing core, step 609; if not, assign the second task to be processed, the third task to be processed and the fourth task to be processed To the second idle processing core, step 610.
在图6a的实施方案中,第一待处理任务、第二待处理任务、第三待处理任务和第四待处理任务中的“第一”、“第二”、“第三”和“第四”表示待处理任务的分配顺序,第一空闲处理核和第二空闲处理核中的“第一”和“第二”表示等分配任务的空闲处理核的分配顺序。在本申请的实施方案中,通过根据任务可能的执行时间,把一个或多个任务一起分配给某个处理核,使得各个处理核不以近似时间被分配任务,从而确保各个处理核不至于频繁进入空闲时间,可以有效减少多个处理核同时进入空闲的几率,提高系统的处理效率。In the embodiment of Fig. 6a, the "first", "second", "third" and "second" in the first pending task, the second pending task, the third pending task and the fourth pending task Four" indicates the allocation order of tasks to be processed, and "first" and "second" in the first idle processing core and the second idle processing core indicate the allocation order of idle processing cores that are equally allocated tasks. In the embodiment of the present application, one or more tasks are assigned to a certain processing core according to the possible execution time of the task, so that each processing core is not assigned a task at an approximate time, thereby ensuring that each processing core does not frequently Entering the idle time can effectively reduce the probability that multiple processing cores enter the idle time at the same time, and improve the processing efficiency of the system.
在本申请的一些实施方案中,当第二待处理任务、第三待处理任务和第四待处理任务的预估执行时间的总和与第一待处理任务的预估执行时间的差值小于 预设的时间间隔时,将第二待处理任务、第三待处理任务和第四待处理任务分配给第二空闲处理核。在该实施方案中,虽然分配给第二空闲处理核的任务的预估执行时间的总和小于分配给第一空闲处理核的任务的预估执行时间,但是仍将三个待处理任务分配给第二空闲处理核,以使得给第二空闲处理核最多分配三个待处理任务。此外,在本申请的一些实施方案中,在给第三空闲处理核分配任务时,也将预分配给第三空闲处理核的一个或多个任务的预估执行时间与分配给第二空闲处理核的一个或多个任务的预估执行时间进行比较。In some embodiments of the present application, when the difference between the sum of the estimated execution time of the second pending task, the third pending task, and the fourth pending task and the estimated execution time of the first pending task is less than the estimated When the time interval is set, the second task to be processed, the third task to be processed and the fourth task to be processed are allocated 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 first idle processing core. Two idle processing cores, so that a maximum of three tasks to be processed are allocated to the second idle processing core. In addition, in some embodiments of the present application, when assigning tasks to the third idle processing core, the estimated execution time of one or more tasks pre-allocated 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. Compare the estimated execution times of one or more tasks of a core.
在一些实施方案中,根据待处理任务队列中的待处理任务的优先级由高到低依次排列上述待处理任务的分配顺序。此外,在一些实施方案中,根据空闲处理核的空闲时间由长到短依次排列上述空闲处理核的分配顺序。In some implementations, according to the priorities of the tasks to be processed in the task queue to be processed, the assignment order of the tasks to be processed is arranged in order from high to low. In addition, in some implementations, according to the idle time of the idle processing cores, the allocation order of the above idle processing cores is arranged in descending order.
虽然已经参考优选实施例对本发明进行了描述,但在不脱离本发明的范围的情况下,可以对其进行各种改进并且可以用等效物替换其中的部件。尤其是,只要不存在结构冲突,各个实施例中所提到的各项技术特征均可以任意方式组合起来。本发明并不局限于文中公开的特定实施例,而是包括落入权利要求的范围内的所有技术方案。While the invention has been described with reference to a preferred embodiment, various modifications may be made and equivalents may be substituted for parts thereof without departing from the scope of the invention. In particular, as long as there is no structural conflict, the technical features mentioned in the various embodiments can be combined in any manner. The present invention is not limited to the specific embodiments disclosed herein, but includes all technical solutions falling within the scope of the claims.

Claims (20)

  1. 一种任务调度方法,其特征在于,所述任务调度方法包括:A task scheduling method, characterized in that the task scheduling method comprises:
    当第一任务处于执行异常状态时,判断所述第一任务是否能够被强制终止;When the first task is in an abnormal execution state, judging whether the first task can be forcibly terminated;
    在所述第一任务不能够被强制终止时,向与所述第一任务相关联的第二任务报告所述第一任务的执行异常状态;以及when the first task cannot be forcibly terminated, reporting the execution exception status of the first task to a second task associated with the first task; and
    当所述第一任务处于执行异常状态的持续时间达到预定等待时间且未接收到所述第一任务的终止指令时,强制终止执行所述第一任务或停止对执行所述第一任务的处理核进行任务调度。When the duration of the first task being in the execution abnormal state reaches a predetermined waiting time and no termination instruction of the first task is received, forcibly terminate the execution of the first task or stop the processing of the execution of the first task The core performs task scheduling.
  2. 根据权利要求1所述的任务调度方法,其特征在于,所述执行异常状态包括如下状态中的一个或多个:任务执行超时状态,任务使用的内存超限,任务使用的堆栈超限。The task scheduling method according to claim 1, wherein the abnormal execution state includes one or more of the following states: task execution timeout state, memory used by the task exceeds the limit, and stack used by the task exceeds the limit.
  3. 根据权利要求1或2所述的任务调度方法,其特征在于,根据所述第一任务的优先级确定所述预定等待时间。The task scheduling method according to claim 1 or 2, wherein the predetermined waiting time is determined according to the priority of the first task.
  4. 根据权利要求1至3中任一项所述的任务调度方法,其特征在于,所述任务调度方法包括:The task scheduling method according to any one of claims 1 to 3, wherein the task scheduling method comprises:
    在所述第一任务能够被强制终止时,强制终止所述第一任务。When the first task can be forcibly terminated, the first task is forcibly terminated.
  5. 根据权利要求1至4中任一项所述的任务调度方法,其特征在于,所述任务调度方法包括:The task scheduling method according to any one of claims 1 to 4, wherein the task scheduling method comprises:
    当被强制终止的所述第一任务是执行所述第一任务的处理核中的最后一个任务时,为执行所述第一任务的处理核分配新的任务。When the first task to be forcibly terminated is the last task in the processing core executing the first task, assign a new task to the processing core executing the first task.
  6. 根据权利要求1至5中任一项所述的任务调度方法,其特征在于,所述任务调度方法包括:The task scheduling method according to any one of claims 1 to 5, wherein the task scheduling method comprises:
    当被强制终止的所述第一任务不是执行所述第一任务的处理核中的最后一个任务时,命令执行所述第一任务的处理核顺序执行为其分配的下一个任务。When the first task to be forcibly terminated is not the last task in the processing core executing the first task, instructing the processing core executing the first task to sequentially execute the next assigned task.
  7. 根据权利要求1至6中任一项所述的任务调度方法,其特征在于,所述任务调度方法适用于多核处理器系统,所述多核处理器系统包含多个处理核。The task scheduling method according to any one of claims 1 to 6, wherein the task scheduling method is applicable to a multi-core processor system, and the multi-core processor system includes a plurality of processing cores.
  8. 根据权利要求7所述的任务调度方法,其特征在于,所述任务调度方法由所述多个处理核中的一个处理核执行,所述任务调度方法包括:The task scheduling method according to claim 7, wherein the task scheduling method is executed by a processing core in the plurality of processing cores, and the task scheduling method comprises:
    实时获取所述多个处理核的状态信息;以及acquiring state information of the plurality of processing cores in real time; and
    当执行所述任务调度方法的处理核出现故障时,通过所述多个处理核中的另一个处理核执行所述任务调度方法。When a processing core executing the task scheduling method fails, another processing core among the plurality of processing cores executes the task scheduling method.
  9. 根据权利要求7或8所述的任务调度方法,其特征在于,所述任务调度方法包括:The task scheduling method according to claim 7 or 8, wherein the task scheduling method comprises:
    将待处理任务队列中的待处理任务分配到所述多个处理核中执行所述任务调度方法的处理核以外的处理核。Allocating the pending tasks in the pending task queue to processing cores other than the processing core executing the task scheduling method among the plurality of processing cores.
  10. 根据权利要求7至9中任一项所述的任务调度方法,其特征在于,当所述多个处理核中的一个或多个处理核故障或所述多核处理系统处于低功耗工作状态时,将待处理任务队列中的待处理任务分配到可使用的指定的处理核。The task scheduling method according to any one of claims 7 to 9, wherein when one or more processing cores in the plurality of processing cores fail or the multi-core processing system is in a low power consumption working state , assign the pending tasks in the pending task queue to the available specified processing cores.
  11. 根据权利要求1至10中任一项所述的任务调度方法,其特征在于,所述任务调度方法包括:The task scheduling method according to any one of claims 1 to 10, wherein the task scheduling method comprises:
    基于待处理任务队列中的待处理任务的分配等待时间调整所述待处理任务的优先级。The priority of the pending tasks is adjusted based on the allocated waiting time of the pending tasks in the pending task queue.
  12. 根据权利要求11所述的任务调度方法,其特征在于,基于待处理任务队列中的待处理任务的分配等待时间调整所述待处理任务的优先级包括:The task scheduling method according to claim 11, wherein adjusting the priority of the task to be processed based on the assigned waiting time of the task to be processed in the task queue to be processed comprises:
    当所述待处理任务的原始优先级加上所述待处理任务的优先级调整值小于或等于所述待处理任务的最大允许优先级时,将所述待处理任务的优先级设置为所述待处理任务的原始优先级加上所述优先级调整值,其中通过对所述待处理任务的分配等待时间与调整系数的乘积取整来获得所述优先级调整值;以及When the original priority of the pending task plus the priority adjustment value of the pending task is less than or equal to the maximum allowed priority of the pending task, set the priority of the pending task to the the original priority of the task to be processed plus the priority adjustment value, wherein the priority adjustment value is obtained by rounding the product of the assigned waiting time of the task to be processed and an adjustment factor; and
    当所述待处理任务的原始优先级加上所述优先级调整值大于所述待处理任务的最大允许优先级时,将所述待处理任务的优先级设置为所述待处理任务的最大允许优先级。When the original priority of the pending task plus the priority adjustment value is greater than the maximum allowed priority of the pending task, set the priority of the pending task to the maximum allowed priority of the pending task priority.
  13. 根据权利要求1至12中任一项所述的任务调度方法,其特征在于,在接收新的待处理任务时,获得所述新的待处理任务的属性参数,所述属性参数包括以下项目中的一项或多项:任务的最大允许等待时间,任务的预估执行时间,任务的原始优先级,任务的优先级调整系数以及任务是否允许强制终止。The task scheduling method according to any one of claims 1 to 12, wherein when a new task to be processed is received, attribute parameters of the new task to be processed are obtained, and the attribute parameters include the following items One or more of: the maximum allowable 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 forced to terminate.
  14. 根据权利要求1至13中任一项所述的任务调度方法,其特征在于,所述任务调度方法包括:The task scheduling method according to any one of claims 1 to 13, wherein the task scheduling method comprises:
    根据待处理任务队列中的任务的预估执行时间,将待处理任务队列中的任务分配给不同的空闲处理核,使得不同的处理核执行任务的完成时间错开。According to the estimated execution time of the tasks in the task queue to be processed, the tasks in the task queue to be processed are allocated to different idle processing cores, so that the completion times of tasks executed by different processing cores are staggered.
  15. 根据权利要求14所述的任务调度方法,其特征在于,分配给一个空闲处理核的一个或多个任务的预估执行时间的总和与相继分配给另一个空闲处理核的一个或多个任务的预估执行时间的总和的差值大于或等于预设的时间间隔。The task scheduling method according to claim 14, wherein the sum of the estimated execution time of one or more tasks assigned to one idle processing core and the estimated execution time of one or more tasks successively assigned to another idle processing core The difference of the sum of estimated execution times is greater than or equal to a preset time interval.
  16. 根据权利要求14或15所述的任务调度方法,其特征在于,根据待处理任务队列中的任务的预估执行时间分配任务包括:The task scheduling method according to claim 14 or 15, wherein allocating tasks according to the estimated execution time of the tasks in the task queue to be processed comprises:
    将第一待处理任务分配给第一空闲处理核;assigning the first task to be processed to the first idle processing core;
    当第二待处理任务的预估执行时间与所述第一待处理任务的预估执行时间的差值大于或等于预设的时间间隔时,将所述第二待处理任务分配给第二空闲处理核;When the difference between the estimated execution time of the second to-be-processed task and the estimated execution time of the first to-be-processed task is greater than or equal to a preset time interval, assign the second to-be-processed task to the second idler processing core;
    当所述第二待处理任务的预估执行时间与所述第一待处理任务的预估执行时间的差值小于预设的时间间隔时,判断所述第二待处理任务和第三待处理任务的预估执行时间的总和与所述第一待处理任务的预估执行时间的差值是否大于或等于预设的时间间隔;When the difference between the estimated execution time of the second pending task and the estimated execution time of the first pending task is less than a preset time interval, judging the second pending task and the third pending task Whether the difference between the sum of the estimated execution time of tasks and the estimated execution time of the first task to be processed is greater than or equal to a preset time interval;
    当所述第二待处理任务和第三待处理任务的预估执行时间的总和与所述第一待处理任务的预估执行时间的差值大于或等于预设的时间间隔时,将所述第二待处理任务和所述第三待处理任务分配给所述第二空闲处理核;以及When the difference between the sum of the estimated execution time of the second to-be-processed task and the third to-be-processed task and the estimated execution time of the first to-be-processed task is greater than or equal to a preset time interval, the assigning the second pending task and the third pending task to the second idle processing core; and
    当所述第二待处理任务和所述第三待处理任务的预估执行时间的总和与所述第一待处理任务的预估执行时间的差值小于预设的时间间隔时,将所述第二待处理任务、所述第三待处理任务和第四待处理任务分配给第二空闲处理核。When the difference between the sum of the estimated execution time of the second to-be-processed task and the third to-be-processed task and the estimated execution time of the first to-be-processed task is less than a preset time interval, the The second task to be processed, the third task to be processed and the fourth task to be processed are allocated to the second idle processing core.
  17. 根据权利要求1至16中任一项所述的任务分配方法,其特征在于,根据待处理任务队列中的待处理任务的优先级由高到低依次排列所述待处理任务的分配顺序。The task allocation method according to any one of claims 1 to 16, characterized in that the allocation order of the tasks to be processed is arranged in sequence from high to low according to the priorities of the tasks to be processed in the task queue to be processed.
  18. 根据权利要求1至17中任一项所述的任务分配方法,其特征在于,根据空闲处理核的空闲时间由长到短依次排列所述空闲处理核的分配顺序。The method for allocating tasks according to any one of claims 1 to 17, characterized in that the allocation order of the idle processing cores is arranged in descending order according to the idle time of the idle processing cores.
  19. 一种计算机可读存储介质,所述计算机可读存储介质存储有指令,当由处理器执行所述指令时,所述指令使所述处理器实施根据权利要求1至18中任一项所述的任务调度方法。A computer-readable storage medium storing instructions which, when executed by a processor, cause the processor to implement the task scheduling method.
  20. 一种多核处理器系统,其特征在于,所述多核处理器系统包括多个处理核,所述多个处理核中的一个处理核被配置成用于执行任务调度的管理核;A multi-core processor system, characterized in that the multi-core processor system includes a plurality of processing cores, and one processing core in the plurality of processing cores is configured as a management core for performing task scheduling;
    所述管理核被配置成执行根据上述权利要求1至18中任一项所述的任务调度方法。The management core is configured to execute the task scheduling method according to any one of claims 1 to 18 above.
PCT/CN2021/141693 2021-12-27 2021-12-27 Task scheduling method and multi-core processor system WO2023122891A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2021/141693 WO2023122891A1 (en) 2021-12-27 2021-12-27 Task scheduling method and multi-core processor system
CN202180101376.XA CN117751351A (en) 2021-12-27 2021-12-27 Task scheduling method and multi-core processor system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/141693 WO2023122891A1 (en) 2021-12-27 2021-12-27 Task scheduling method and multi-core processor system

Publications (1)

Publication Number Publication Date
WO2023122891A1 true WO2023122891A1 (en) 2023-07-06

Family

ID=86996822

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/141693 WO2023122891A1 (en) 2021-12-27 2021-12-27 Task scheduling method and multi-core processor system

Country Status (2)

Country Link
CN (1) CN117751351A (en)
WO (1) WO2023122891A1 (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103454935A (en) * 2013-08-23 2013-12-18 广州中智融通金融科技有限公司 Method, device and system for delay shutdown of electronic equipment
CN104102572A (en) * 2013-04-01 2014-10-15 中兴通讯股份有限公司 Method and device for detecting and processing system faults
CN104407847A (en) * 2014-10-29 2015-03-11 中国建设银行股份有限公司 Batch processing method and device
US20170208186A1 (en) * 2016-01-19 2017-07-20 Canon Kabushiki Kaisha Information processing apparatus performing process based on execution data, control method therefor, storage medium storing control program therefor, process execution apparatus, control method therefor, and storage medium storing control program therefor
CN109491771A (en) * 2018-09-26 2019-03-19 平安医疗健康管理股份有限公司 Task processing method and relevant device based on system function optimization
CN112214319A (en) * 2020-09-29 2021-01-12 深圳大学 Task scheduling method for sensing computing resources
CN112817762A (en) * 2021-01-29 2021-05-18 中汽创智科技有限公司 Dispatching system based on adaptive automobile open system architecture standard and dispatching method thereof

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104102572A (en) * 2013-04-01 2014-10-15 中兴通讯股份有限公司 Method and device for detecting and processing system faults
CN103454935A (en) * 2013-08-23 2013-12-18 广州中智融通金融科技有限公司 Method, device and system for delay shutdown of electronic equipment
CN104407847A (en) * 2014-10-29 2015-03-11 中国建设银行股份有限公司 Batch processing method and device
US20170208186A1 (en) * 2016-01-19 2017-07-20 Canon Kabushiki Kaisha Information processing apparatus performing process based on execution data, control method therefor, storage medium storing control program therefor, process execution apparatus, control method therefor, and storage medium storing control program therefor
CN109491771A (en) * 2018-09-26 2019-03-19 平安医疗健康管理股份有限公司 Task processing method and relevant device based on system function optimization
CN112214319A (en) * 2020-09-29 2021-01-12 深圳大学 Task scheduling method for sensing computing resources
CN112817762A (en) * 2021-01-29 2021-05-18 中汽创智科技有限公司 Dispatching system based on adaptive automobile open system architecture standard and dispatching method thereof

Also Published As

Publication number Publication date
CN117751351A (en) 2024-03-22

Similar Documents

Publication Publication Date Title
US10606653B2 (en) Efficient priority-aware thread scheduling
US8793695B2 (en) Information processing device and information processing method
US6560628B1 (en) Apparatus, method, and recording medium for scheduling execution using time slot data
US6148322A (en) Processing unit with an improved ability to coordinate the execution of multiple tasks with varying priorities
CN109992403B (en) Optimization method and device for multi-tenant resource scheduling, terminal equipment and storage medium
US20090083746A1 (en) Method for job management of computer system
CN111897637B (en) Job scheduling method, device, host and storage medium
CN109710416B (en) Resource scheduling method and device
CN115454589A (en) Task scheduling method and device and Kubernetes scheduler
US9367349B2 (en) Multi-core system and scheduling method
CN114327894A (en) Resource allocation method, device, electronic equipment and storage medium
WO2023122891A1 (en) Task scheduling method and multi-core processor system
CN111143063B (en) Task resource reservation method and device
CN109656716B (en) Slurm job scheduling method and system
CN111143210A (en) Test task scheduling method and system
CN105955816A (en) Event scheduling method and device
CN109240815A (en) A kind of multitask running method, device and equipment of shared storehouse
JP2008225641A (en) Computer system, interrupt control method and program
JP2000259430A (en) Processing method for computer system
US20220188407A1 (en) Method carried out in electronic control unit of the multi-core structure, and apparatus implementing the same method
CN112000294A (en) IO queue depth adjusting method and device and related components
CN114212096B (en) Control delay processing method and device for automatic driving vehicle
JPH07114518A (en) Task scheduling system of multiprocessor system
KR102540724B1 (en) Method for managing execution of task in the multi-core system, and apparatus implementing the same method
JPS63300326A (en) Transaction execution schedule system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21969277

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 202180101376.X

Country of ref document: CN