Disclosure of Invention
The purpose of the invention is as follows: the scheduling system and the scheduling method based on the adaptive automobile open system architecture standard are provided to solve the problems.
The technical scheme is as follows: a dispatching system based on adaptive automobile open system architecture standard comprises a task layer unit, a user layer unit and a core layer unit;
the task layer unit comprises a user task and core group configuration, wherein the user task is a user operation requirement, and the core group configuration distributes the user task for management;
the user layer unit comprises a thread pool, and the idle thread pool is allocated to a user task to run;
and the core layer unit comprises a CPU, is bound with the thread pool and runs the distributed user tasks.
According to one aspect of the invention, the task layer unit allocates user tasks in task lists to an idle thread pool, the user tasks start to run, when the tasks are listed as a global queue, all tasks on the user can be placed on the global queue, the task lists are two-dimensional arrays, the priority is used as an index, one task list is used as a group of members of the index to realize the function that the priority tasks run first, and the function of a core group is also realized.
According to one aspect of the present invention, the user layer unit uses the thread pool as a virtual CPU of the user layer, and performs resource management based on the thread pool, that is, the core group configures user tasks to be bound to the thread pool, since the thread pool corresponds to the physical CPU one by one, the user tasks are bound to the set physical CPU, the task columns correspond to the core group one by one, and uses the thread pool as a virtual CPU of the user layer, and performs resource management based on the thread pool, that is, since the core group configures user tasks to be bound to the thread pool, since the thread pool corresponds to the physical CPU one by one, the user tasks are bound to the set physical CPU, and the task columns correspond to the core group one by one.
A scheduling method based on adaptive automobile open system architecture standard manages user tasks according to priority and resource allocation, and comprises the following specific steps:
step 1, a member function of a scheduling system creates a work pool, and a configuration file scheduler program of a user is read, wherein the configuration file contains configuration information such as a core group, CPU setting, CPU binding, priority and the like;
step 2, instantiating a thread pool, calling a member function binding context of a classic thread pool, and acquiring a task context, namely a working context by the function;
step 3, in the context binding function, a ring thread is created in a standard traversing mode, and ring thread attributes including CPU setting, CPU binding, RR scheduling policy, FIFO scheduling policy, priority and the like are set according to the read scheduling program file configuration information;
step 4, the thread is a circular thread, if in the idle state, the thread is in the waiting state; if finding out the task, the scheduler will wake up the corresponding thread, or put the task into the corresponding task queue according to the priority to wait for execution.
According to one aspect of the invention, in order to implement real-time functionality, priority is first required, with different policies: preempting, RR and FIFO modes, using the FIFO mode, monitoring the FIFO scheduling strategy, and performing exception handling to avoid that when a certain task is abnormal, the CPU is always occupied, so that other tasks have no chance to obtain.
According to one aspect of the invention, to ensure real-time performance, not only priority level, but also resource configuration is required, and the real-time performance of the whole system is ensured by setting a core group of a certain process, binding a CPU, binding an interrupt and setting the affinity of the CPU.
Has the advantages that: the invention can design a scheduler on the user layer, is convenient for managing the automatic driving application program, ensures the stability and low delay of the automatic driving application program, has smaller resource consumption when the user task is switched compared with the kernel thread, monitors the FIFO scheduling strategy, performs exception handling, avoids that when a certain task is abnormal, the CPU is always occupied, other tasks have no chance to obtain, and ensures the real-time performance of the whole system by setting the core group of a certain process, binding the CPU, the interrupt and the affinity setting of the CPU.
Detailed Description
Example 1
A scheduling system is designed at a user layer, because the scheduling system designed at the user layer can statically configure strategies and resources and conveniently manage user tasks.
In this embodiment, as shown in fig. 1, a scheduling system based on the adaptive automobile open system architecture standard includes a task layer unit, a user layer unit and a core layer unit;
the task layer unit comprises a user task and core group configuration, wherein the user task is a user operation requirement, and the core group configuration distributes the user task for management;
the user layer unit comprises a thread pool, and the idle thread pool is allocated to a user task to run;
and the core layer unit comprises a CPU, is bound with the thread pool and runs the distributed user tasks.
In a further embodiment, as shown in fig. 2, 1. in the Linux platform, a running program is embodied in a process manner on a user layer, but only a thread concept is seen from a core layer unit, and a minimum unit of scheduling of the core layer unit is a thread, so that a thread pool can be created on the user layer and bound on a certain physical CPU, including 4 CPUs physically, so that 4 thread pools are created and bound on fixed CPUs respectively, and then a scheduling system can allocate a user task in a task column to an idle thread pool, and the user task starts running immediately; the user task column is a global queue, all tasks on the user are placed on the global queue, and then the scheduling system takes the tasks from the global queue task column to an idle thread pool.
Example 2
A scheduling system is designed at a user layer, because the scheduling system designed at the user layer can statically configure strategies and resources and conveniently manage user tasks.
In this embodiment, as shown in fig. 1, a scheduling system based on the adaptive automobile open system architecture standard includes a task layer unit, a user layer unit and a core layer unit;
the task layer unit comprises a user task and core group configuration, wherein the user task is a user operation requirement, and the core group configuration distributes the user task for management;
the user layer unit comprises a thread pool, and the idle thread pool is allocated to a user task to run;
and the core layer unit comprises a CPU, is bound with the thread pool and runs the distributed user tasks.
In a further embodiment, as shown in FIG. 3, the physical CPU sees only the thread pool from the core layer unit, and for application tasks, only the thread pool. Therefore, from the perspective of user tasks, the thread pool can be regarded as a virtual CPU of a user layer, and resource management can be performed based on the thread pool, that is, core group configuration, including that the core group configures user tasks to be bound on some thread pools. At this time, the global queue task columns are not suitable and need to correspond to the core groups, that is, how many core groups there are task columns, and each task column corresponds to one core group. The task list is a two-dimensional array, the priority is used as an index, and one task list is used as a group of members of the index, so that the function of firstly running the tasks of the priority user can be realized, and the function of a core group is also realized.
Example 3
A scheduling system is designed at a user layer, because the scheduling system designed at the user layer can statically configure strategies and resources and conveniently manage user tasks.
In this embodiment, as shown in fig. 1, a scheduling system based on the adaptive automobile open system architecture standard includes a task layer unit, a user layer unit and a core layer unit;
the task layer unit comprises a user task and core group configuration, wherein the user task is a user operation requirement, and the core group configuration distributes the user task for management;
the user layer unit comprises a thread pool, and the idle thread pool is allocated to a user task to run;
and the core layer unit comprises a CPU, is bound with the thread pool and runs the distributed user tasks.
As shown in fig. 4, a scheduling method based on adaptive automobile open system architecture standard manages user tasks according to priorities and resource allocation, and specifically includes the following steps:
step 1, a member function of a scheduling system creates a work pool, and a configuration file scheduler program of a user is read, wherein the configuration file contains configuration information such as a core group, CPU setting, CPU binding, priority and the like;
step 2, instantiating a thread pool, calling a member function binding context of a classic thread pool, and acquiring a task context, namely a working context by the function;
step 3, in the context binding function, a ring thread is created in a standard traversing mode, and ring thread attributes including CPU setting, CPU binding, RR scheduling policy, FIFO scheduling policy, priority and the like are set according to the read scheduling program file configuration information;
step 4, the thread is a circular thread, if in the idle state, the thread is in the waiting state; if finding out the task, the scheduler will wake up the corresponding thread, or put the task into the corresponding task queue according to the priority to wait for execution.
In a further embodiment, in order to implement the real-time functionality, priority is first required, which has different policies: preempting, RR and FIFO modes, using the FIFO mode, monitoring the FIFO scheduling strategy, and performing exception handling to avoid that when a certain task is abnormal, the CPU is always occupied, so that other tasks have no chance to obtain.
In a further embodiment, to ensure real-time performance, not only priority level, but also resource configuration is required, and the real-time performance of the whole system is ensured by setting a core group of a certain process, binding a CPU, binding interrupts, and setting affinity of the CPU.
In summary, the present invention has the following advantages:
1. by designing a scheduler on a user layer, the automatic driving application program is convenient to manage, the stability and low delay of the automatic driving application program are ensured, and the resource consumption is smaller when a user task is switched compared with that when a kernel thread is switched;
2. by monitoring the FIFO scheduling strategy and performing exception handling, the situation that when a certain task is abnormal, a CPU is always occupied and other tasks have no chance to obtain is avoided;
3. the real-time performance of the whole system is ensured by setting a core group of a certain process and binding affinity settings of a CPU, an interrupt and the CPU.
It is to be noted that the respective technical features described in the above embodiments are combined in any appropriate manner without contradiction. The invention is not described in detail in order to avoid unnecessary repetition.