Vehicle event processing method and device, vehicle, equipment and medium

By introducing a directed acyclic graph scheduling process into the vehicle intelligent driving system, tasks are scheduled directly in the kernel space, which solves the problem of operating system scheduling latency and improves the event processing efficiency and real-time performance of the intelligent driving system.

CN121636133APending Publication Date: 2026-03-10SHANGHAI LIXIANG AUTOMOBILE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

In traditional end-to-end vehicle intelligent driving systems, operating system scheduling delays cause scheduling delays under high real-time requirements, affecting driving safety and system performance.

Method used

A directed acyclic graph (DAG) scheduling method is adopted to schedule processes. By scheduling tasks directly in kernel space, the operating system message queue wake-up latency is reduced. By utilizing communication between kernel space programs and user space programs, combined with kernel mapping tables and scheduling policies, efficient task scheduling is achieved.

Benefits of technology

It reduces the time spent scheduling and selecting runnable tasks, improves the event processing efficiency of the intelligent driving system, reduces operating system scheduling latency, and enhances the system's real-time performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121636133A_ABST
    Figure CN121636133A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a vehicle event processing method and device, a vehicle, equipment and a medium, and the method comprises the steps: obtaining a directed acyclic graph corresponding to an event when the event of an intelligent driving system is triggered; the directed acyclic graph defines tasks corresponding to the events and a dependency relationship between the tasks; calling the user space program to load the kernel space program to the kernel space; the kernel space program and the user space program communicate through a kernel mapping table, and a scheduling strategy for tasks is set in the kernel space program; sending the directed acyclic graph to a directed acyclic graph scheduling process; calling a directed acyclic graph scheduling process to load a kernel space program; and scheduling the task according to the directed acyclic graph and the scheduling strategy. According to the embodiment of the invention, the event processing efficiency of the intelligent driving system can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of vehicle control technology, and in particular to a vehicle event handling method, apparatus, vehicle, equipment, and medium. Background Technology

[0002] End-to-end refers to a system or model that can directly provide a solution from input data to output data, rather than the traditional modular processing method. The end-to-end structure makes the intelligent driving system simpler, reduces information loss between modules, and makes iteration more efficient.

[0003] Current vehicle intelligent driving systems generate tasks at every stage, from perception, fusion, prediction, planning to decision-making. These tasks are handled using a traditional end-to-end control approach. This approach typically involves chaining multiple stages together, with each stage depending on the output of the previous one. Each stage's task can only begin execution after the previous stage's task is completed. This necessitates an operating system (OS), such as Linux, to schedule and manage these tasks. However, there are delays in the OS's task scheduling, which accumulate in the traditional end-to-end approach. Especially in intelligent driving systems with high real-time requirements, even a small scheduling delay can affect the system, impacting driving safety and system performance. Therefore, using a traditional end-to-end approach to handle tasks at each stage introduces the problem of operating system scheduling delays. Summary of the Invention

[0004] In view of the above problems, a vehicle incident handling method, apparatus, vehicle, equipment, and medium are proposed to overcome or at least partially solve the above problems, including:

[0005] A vehicle event handling method is applied to a vehicle's intelligent driving system. The intelligent driving system includes a user space and a kernel space. The user space includes user space programs and kernel space programs. The kernel space includes a directed acyclic graph scheduling process. The method includes:

[0006] When an event is triggered in the intelligent driving system, a directed acyclic graph corresponding to the event is obtained; the directed acyclic graph defines the task corresponding to the event and the dependency relationship between the tasks;

[0007] The user-space program is invoked to load the kernel-space program into the kernel space; the kernel-space program and the user-space program communicate through a kernel mapping table, and the kernel-space program has a scheduling policy set for the task;

[0008] Send the directed acyclic graph to the directed acyclic graph scheduling process;

[0009] The directed acyclic graph scheduling process is invoked to load the kernel space program;

[0010] The task is scheduled according to the directed acyclic graph and the scheduling strategy.

[0011] Optionally, the step of calling the user-space program to load the kernel-space program into the kernel space includes:

[0012] The program code of the kernel space program is obtained by calling the user space program and then compiled into bytecode by the compiler;

[0013] Load the bytecode into the kernel space;

[0014] If the bytecode of the kernel space program is successfully verified by the verifier in the kernel space, the compiler in the kernel space will convert the bytecode of the kernel space program into a machine-specific instruction set so that the kernel space program can run in the kernel space.

[0015] Optionally, the step of calling the user-space program to load the kernel-space program into the kernel space further includes:

[0016] If the bytecode of the kernel space program fails to be verified by the verifier in the kernel space, a message refusing to load the kernel space program is returned to the user space program.

[0017] Optionally, scheduling the task according to the directed acyclic graph and the scheduling policy includes:

[0018] The directed acyclic graph scheduling process is invoked to parse the directed acyclic graph and generate task topology relationships. The task topology relationships include the task nodes corresponding to the tasks, the topological order between the task nodes, and the in-degree and out-degree of each task node. The in-degree is used to represent the number of times the task node is dependent on other task nodes, and the out-degree is used to represent the number of times the task node depends on other task nodes.

[0019] The tasks are scheduled according to the task topology and the scheduling policy.

[0020] Optionally, the task node includes a task process identifier, a task name, and the name of the task it depends on.

[0021] Optionally, scheduling the task according to the directed acyclic graph and the scheduling policy includes:

[0022] The task name of the task node is placed into the user queue of the kernel-mode program according to the topological order among the task nodes.

[0023] Use the task name corresponding to the task node with an out-degree of zero in the user queue as the target task name;

[0024] The target task name is added to the scheduling queue of the kernel program, and the task corresponding to the target task name in the scheduling queue is executed.

[0025] Optionally, adding the target task name to the scheduling queue of the kernel-mode program and executing the task corresponding to the target task name in the scheduling queue includes:

[0026] Obtain the computing resources released by the user-space program;

[0027] The computing resources are placed into a global call queue, so that the task corresponding to the target task name in the call queue can be executed based on the computing resources in the global call queue.

[0028] Optionally, obtaining the computing resources released by the user-space program includes:

[0029] After the task node completes its task, it enters the ready state to wait for the next scheduling.

[0030] Acquire the computing resources released by the task node that has entered the ready state to execute the task corresponding to the target task name in the scheduling queue, wherein the task corresponding to the target task name is the task corresponding to the task name with an out-degree of zero in the user queue.

[0031] Optionally, scheduling the task according to the directed acyclic graph and the scheduling policy includes:

[0032] When a message from a new task node is received, the directed acyclic graph is updated according to the new task node.

[0033] The task is scheduled according to the updated directed acyclic graph and the scheduling policy.

[0034] Optionally, scheduling the task according to the directed acyclic graph and the scheduling policy includes:

[0035] Upon receiving a message indicating that a task node has completed execution, the directed acyclic graph is updated based on the completed task node.

[0036] The task is scheduled according to the updated directed acyclic graph and the scheduling policy.

[0037] Optionally, scheduling the task according to the directed acyclic graph and the scheduling policy includes:

[0038] When a message to create a directed acyclic graph is received, a new directed acyclic graph is created.

[0039] The tasks are scheduled according to the created directed acyclic graph and the scheduling policy.

[0040] Optionally, the kernel space program is written based on the extended Berkeley packet filter.

[0041] A vehicle event handling device is applied to a vehicle's intelligent driving system. The intelligent driving system includes a user space and a kernel space. The user space includes user space programs and kernel space programs. The kernel space includes a directed acyclic graph scheduling process. The device includes:

[0042] The directed acyclic graph acquisition module is used to acquire the directed acyclic graph corresponding to the event when the event of the intelligent driving system is triggered; the directed acyclic graph defines the task corresponding to the event and the dependency relationship between the tasks;

[0043] A kernel space program loading module is used to call the user space program to load the kernel space program into the kernel space; the kernel space program and the user space program communicate through a kernel mapping table, and the kernel space program has a scheduling policy for tasks set.

[0044] A directed acyclic graph sending module is used to send the directed acyclic graph to the directed acyclic graph scheduling process;

[0045] The kernel space program invocation module is used to invoke the directed acyclic graph scheduling process to load the kernel space program;

[0046] The task execution module is used to schedule the task according to the directed acyclic graph and the scheduling strategy.

[0047] An electronic device includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the vehicle event handling method described above.

[0048] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the vehicle event handling method described above.

[0049] The embodiments of the present invention have the following advantages:

[0050] This invention can be applied to an intelligent driving system for vehicles. The intelligent driving system includes a user space and a kernel space. The user space includes user space programs and kernel space programs, while the kernel space includes a directed acyclic graph (DAG) scheduling process. When an event is triggered in the intelligent driving system, the corresponding DAG is obtained. The DAG defines the tasks corresponding to the event and the dependencies between tasks. The user space program is invoked to load the kernel space program into the kernel space. The kernel space program and the user space program can communicate through a kernel mapping table. The kernel space program has a scheduling policy for tasks. The DAG is sent to the DAG scheduling process, which then loads the kernel space program and schedules the tasks according to the DAG and the scheduling policy. This invention reduces the latency of waking up messages in user space via the operating system's message queue, as is done in existing technologies, by writing a kernel space program and loading it into the kernel space for execution. Furthermore, this embodiment of the invention uses a directed acyclic graph (DAG) to schedule processes, and performs task scheduling based on the dependencies and scheduling strategies between tasks in the DAG, thereby reducing the time spent selecting runnable tasks and improving the efficiency of event processing for the intelligent driving system. Attached Figure Description

[0051] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0052] Figure 1 This is a flowchart of the steps of a vehicle event handling method provided in an embodiment of the present invention;

[0053] Figure 2 This is a schematic diagram of a Linux architecture provided in an embodiment of the present invention;

[0054] Figure 3 This is a diagram illustrating an implementation architecture of eBPF according to an embodiment of the present invention;

[0055] Figure 4 This is a schematic diagram of a task dependency provided in an embodiment of the present invention;

[0056] Figure 5 This is a schematic diagram illustrating the connection of a service monitoring each task node according to an embodiment of the present invention;

[0057] Figure 6a This is a flowchart of task execution provided in an embodiment of the present invention;

[0058] Figure 6b This is a flowchart of task execution provided in an embodiment of the present invention;

[0059] Figure 7 This is a schematic diagram of the structure of a vehicle event processing device provided in an embodiment of the present invention. Detailed Implementation

[0060] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0061] First, some of the names or keywords involved in the embodiments of the present invention will be explained.

[0062] DAG: directed acyclic graph.

[0063] eBPF: Extended Berkeley Packet Filter, a kernel-based lightweight virtual machine.

[0064] sched_ext: an extensible scheduler class.

[0065] To address the end-to-end scheduling latency issue in the background technology, the following solution has been proposed: scheduling and tasks are moved from the kernel space (the core area of ​​the operating system) in kernel mode to the user space / task space (the area where applications run) in user mode. This allows for a closer integration of scheduling logic and algorithmic business logic. Specifically, messages about tasks from perception to decision-making are received and sent from various nodes of the intelligent driving system based on message queues, enabling the publication and subscription of messages between tasks. The above solution relies primarily on a two-layer scheduling framework (user-mode thread wake-up + kernel-mode thread scheduling). This scheduling framework is not end-to-end control, and latency is uncontrollable and lacks theoretical guarantees.

[0066] To address the uncertainties of two-layer scheduling in end-to-end latency: 1. Event-driven computation tasks, with event scheduling handled by the operating system scheduler, allowing business tasks to be directly scheduled by the operating system. 2. Ensuring the real-time performance of asynchronous event scheduling: After task A completes, a system call is used to trap into the kernel, allowing task B, which is ready to run, to continue.

[0067] The scheduler must meet the following user requirements:

[0068] 1. It manages complex task dependencies, ensuring the accuracy of task execution order.

[0069] 2. Users only want to write business logic, without caring about synchronous or asynchronous operations, or considering issues such as blocking and waiting.

[0070] 3. Provides encapsulated interfaces to simplify the process of building a directed acyclic graph (DAG) for users, eliminating the need to handle complex and cumbersome synchronization relationships.

[0071] A programmable kernel (kernel space) can be flexibly and dynamically adjusted. Dynamic loading involves not only modules but also, and more importantly, scheduling policies. Once a module is loaded, new scheduling policies can be dynamically provided to it. Borrowing the ideas of eBPF, the mechanism and framework are separated, with the framework built into the kernel. Therefore, the implemented functions and scheduling policies only need to be written and then injected into the kernel. This invention, through writing eBPF programs (kernel space programs) to customize the scheduling policy of the Linux kernel's intelligent driving system, can help developers experiment and explore new scheduling policies more quickly, making the kernel's scheduling policy closer to the needs of practical applications.

[0072] Reference Figure 1 This diagram illustrates a flowchart of a vehicle event handling method according to an embodiment of the present invention, applied to a vehicle's intelligent driving system. The intelligent driving system includes a user space and a kernel space. The user space includes user space programs and kernel space programs, and the kernel space includes a directed acyclic graph scheduling process. The method may specifically include the following steps:

[0073] Step S101: When an event is triggered by the intelligent driving system, obtain the directed acyclic graph corresponding to the event; the directed acyclic graph defines the task corresponding to the event and the dependency relationship between the tasks.

[0074] Reference Figure 2 This is a schematic diagram of a Linux architecture provided in an embodiment of the present invention. The intelligent driving system can be a Linux system, which can include user space (user mode) and kernel space (kernel mode). The user space includes user space programs (user mode applications) and kernel space programs (kernel mode applications, eBPF programs). The eBPF programs run in the kernel and react to events. The kernel space includes a directed acyclic graph scheduling process (DAG scheduling process / DAG scheduling master process).

[0075] In this embodiment of the invention, when an event is triggered in the intelligent driving system—that is, when the intelligent driving system generates events such as perception, fusion, prediction, planning, and decision-making—a task is generated. The directed acyclic graph (DAG) corresponding to the event is obtained. The DAG defines the tasks corresponding to the event and the dependencies between tasks. One event can correspond to one task, one event can correspond to multiple tasks, or multiple events can correspond to one task. Specifically, a task is the smallest unit entity scheduled for execution in the workflow's task scheduling system. The dependencies between tasks can be defined based on the DAG. Specifically, the DAG is a directed graph without loops. When executing a task, the task execution data corresponding to the task can be executed according to the dependencies between tasks in the DAG to complete the task processing.

[0076] Step S102: The user space program is invoked to load the kernel space program into the kernel space; the kernel space program and the user space program communicate through a kernel mapping table, and the kernel space program has a scheduling policy for tasks set.

[0077] In this embodiment of the invention, the user-space program can load the eBPF program into the kernel space. Subsequently, the user-space program can communicate with the eBPF program based on BPF MAPS (hash MAPS, arrays, ring / perf buffer). BPF MAPS allows data storage and information sharing between the user-space program and the eBPF program in the kernel.

[0078] In this implementation, the eBPF program contains the developer's scheduling policy for tasks. Therefore, after loading the eBPF program into kernel space, kernel space can schedule tasks based on this policy. Specifically, `sched_ext` is a scheduling class that runs parallel to existing scheduling classes in the Linux kernel, such as CFS and realtime. `sched_ext` allows scheduling behavior to be implemented by a single eBPF program. The added `sched_ext` is on par with existing kernel scheduling classes such as `stop_sched_class`, `dl_sched_class`, `rt_sched_class`, `fair_sched_class`, and `idle_sched_class`, with priority between `idle_sched_class` (SCHED_IDLE) and CFS (SCHED_NORMAL). Therefore, this embodiment of the invention can implement task scheduling through an eBPF program.

[0079] Step S103: Send the directed acyclic graph to the directed acyclic graph scheduling process.

[0080] In this embodiment of the invention, the user-space program can notify the DAG scheduling process of the directed acyclic graph through a message queue.

[0081] Step S104: Invoke the directed acyclic graph scheduling process to load the kernel space program.

[0082] In this embodiment of the invention, after the user space program loads the kernel space program into the kernel space, the DAG scheduling process can load the kernel space program, so that the kernel space DAG scheduling process can perform task scheduling based on the scheduling policy.

[0083] Step S105: Schedule the task according to the directed acyclic graph and the scheduling strategy.

[0084] In this embodiment of the invention, after loading the directed acyclic graph (DAG) and the task scheduling policy into the kernel space, the scheduling method of the task can be determined according to the DAG and the scheduling policy, and the task can be executed based on the scheduling method, thereby completing the processing of events of the intelligent driving system.

[0085] It should be noted that the execution of steps S101-S105 above is not necessarily in sequence. The above description of the steps is only for the purpose of explaining the specific implementation process of the embodiments of the present invention. For example, the execution order of S101 and S102 can be interchanged or combined, and the execution order of S103 and S104 can be interchanged or combined. This should not be construed as a limitation on the embodiments of the present invention.

[0086] This invention can be applied to intelligent driving systems for vehicles. The intelligent driving system includes a user space and a kernel space. The user space includes user space programs and kernel space programs, while the kernel space includes a directed acyclic graph (DAG) scheduling process. When an event is triggered in the intelligent driving system, the corresponding DAG is obtained. The DAG defines the tasks corresponding to the event and the dependencies between tasks. The user space program is invoked to load the kernel space program into the kernel space. The kernel space program and the user space program can communicate through a kernel mapping table. The kernel space program has a scheduling policy for tasks. The DAG is sent to the DAG scheduling process, which then loads the kernel space program and schedules tasks according to the DAG and the scheduling policy. This invention reduces the latency of waking up messages in user space via the operating system's message queue, as is done in existing technologies, by writing a kernel space program and loading it into the kernel space for execution. Furthermore, this embodiment of the invention uses a directed acyclic graph (DAG) to schedule processes, and performs task scheduling based on the dependencies and scheduling strategies between tasks in the DAG, thereby reducing the time spent selecting runnable tasks and improving the efficiency of event processing for the intelligent driving system.

[0087] In one embodiment of the present invention, step S102, loading the kernel space program into the kernel space by invoking the user space program, includes:

[0088] The program code of the kernel space program is obtained by calling the user space program and then compiled into bytecode by the compiler;

[0089] Load the bytecode into the kernel space;

[0090] If the bytecode of the kernel space program is successfully verified by the verifier in the kernel space, the compiler in the kernel space will convert the bytecode of the kernel space program into a machine-specific instruction set so that the kernel space program can run in the kernel space.

[0091] In this embodiment of the invention, reference is made to Figure 3 This is an implementation architecture diagram of eBPF provided by an embodiment of the present invention. The working principle of an eBPF program is mainly divided into three steps: loading, compiling, and execution. eBPF can be composed of three key parts: eBPF program, which runs in the kernel and reacts to events; user space program, which loads the eBPF program into the kernel and interacts with it; and BPF MAPS (hash MAPS, arrays, ring / perf buffer), which allows data storage and information sharing between the user space program and the eBPF program in the kernel.

[0092] Specifically, a complete eBPF application typically consists of two parts: user space and kernel space. The user-space program interacts with the kernel through a series of system calls (primarily the BPF system call), creates corresponding MapS (Mapping System) to store data in kernel space or communicate with user space, dynamically selects and loads different program segments based on configuration, dynamically modifies bytecode or configures eBPF program parameters, loads the corresponding bytecode information into the kernel, ensures security through a Verifier, and achieves bidirectional communication between the kernel and the MAPS, transferring data from kernel space to user space (or vice versa) through mechanisms such as ring buffers / perf buffers. The kernel space is primarily responsible for the specific computational logic and data collection. eBPF needs to run within the kernel. This is usually achieved by the user-space application, which loads the eBPF program through system calls. During loading, the kernel copies the eBPF program's code to kernel space. The eBPF program then needs to be compiled and executed. This process is typically handled by the Clang / LLVM compiler. After generating bytecode, the user-mode bytecode is loaded into the kernel. The verifier performs kernel security checks on the program to be injected into the kernel to ensure that the eBPF program does not compromise kernel stability and security. During the checks, the kernel analyzes the eBPF program's code to ensure it does not perform malicious operations such as system calls or memory accesses. If the eBPF program passes the kernel security checks, it can run normally in the kernel. It will use a JIT (Just-In-Time) compilation step to convert the program's general bytecode into machine-specific instruction sets (machine code) to optimize execution speed.

[0093] In one embodiment of the present invention, the step of calling the user-space program to load the kernel-space program into the kernel space further includes:

[0094] If the bytecode of the kernel space program fails to be verified by the verifier in the kernel space, a message refusing to load the kernel space program is returned to the user space program.

[0095] In this embodiment of the invention, if the bytecode of the eBPF program fails the check of the kernel security mechanism, a message refusing to load the kernel space program is returned to the user space program. At this time, the developer can check or adjust the eBPF program according to the message.

[0096] In one embodiment of the present invention, scheduling the task according to the directed acyclic graph and the scheduling policy includes:

[0097] The directed acyclic graph scheduling process is invoked to parse the directed acyclic graph and generate task topology relationships. The task topology relationships include the task nodes corresponding to the tasks, the topological order between the task nodes, and the in-degree and out-degree of each task node. The in-degree is used to represent the number of times the task node is dependent on other task nodes, and the out-degree is used to represent the number of times the task node depends on other task nodes.

[0098] The tasks are scheduled according to the task topology and the scheduling policy.

[0099] In one embodiment of the present invention, the task node includes a task process identifier, a task name, and a dependent task name, and scheduling the task according to the directed acyclic graph and the scheduling policy includes:

[0100] The task name of the task node is placed into the user queue of the kernel-mode program according to the topological order among the task nodes.

[0101] Use the task name corresponding to the task node with an out-degree of zero in the user queue as the target task name;

[0102] The target task name is added to the scheduling queue of the kernel program, and the task corresponding to the target task name in the scheduling queue is executed.

[0103] In one embodiment of the present invention, adding the target task name to the scheduling queue of the kernel-mode program and executing the task corresponding to the target task name in the scheduling queue includes:

[0104] Obtain the computing resources released by the user-space program;

[0105] The computing resources are placed into a global call queue, so that the task corresponding to the target task name in the call queue can be executed based on the computing resources in the global call queue.

[0106] Reference Figure 4 This diagram illustrates a task dependency mechanism according to an embodiment of the present invention. In specific implementations, to meet the requirements of correct orchestration of multiple tasks such as positioning, perception, planning, and control in intelligent driving, the system needs to be able to schedule user-specified tasks with dependencies. Figure 4 The task node pointed to by the middle arrow is the node it depends on. The task can only run after the task it depends on has been completed.

[0107] This task dependency and execution order problem is a typical Directed Acyclic Graph (DAG) problem. In the sched_dag scheduling system, tasks are nodes, dependencies form edges, and the execution order of tasks forms a flow without cycles in the graph. Each time a task is selected for execution, the scheduler must choose a node with no dependencies, i.e., a node with an out-degree of 0. Implementing task scheduling requires addressing the following issues: how to represent and store the DAG; how to handle circular dependencies; how to ensure tasks execute in the correct order; and how to minimize the amount of code modified by users.

[0108] The DAG scheduler runs as a server process, initializing the topology of task nodes through inter-process communication. Each task node is also an independent process. Users first start their task processes, then call the relevant interfaces to pass the directed acyclic graph (DAG) information to the server for scheduling. The DAG information can be defined in the user program using the following table structure:

[0109]

[0110]

[0111] Each item in the above table structure represents a task node. Each task node contains the task process PID, task name, and the task names of its dependent tasks. A Directed Acyclic Graph (DAG) is created by calling the encapsulated interface. The creation process involves the following steps: parsing the node relationships in the DAG; simultaneously detecting cycles during DAG parsing (topological sorting simulates the execution of task nodes; if the simulation finds that none of the remaining nodes in the DAG can be executed, then a cycle exists in the DAG); after ensuring the DAG parameters are correct, the Server process initiates DAG scheduling. After receiving the correct DAG parameters, the Server maintains the DAG using the node-edge related data structure shown in the following code, completing the binding of nodes to process PIDs. The specific binding can be as follows:

[0112]

[0113] In one embodiment of the present invention, acquiring the computing resources released by the user-space program includes:

[0114] After the task node completes its task, it enters the ready state to wait for the next scheduling.

[0115] Acquire the computing resources released by the task node that has entered the ready state to execute the task corresponding to the target task name in the scheduling queue, wherein the task corresponding to the target task name is the task corresponding to the task name with an out-degree of zero in the user queue.

[0116] In this embodiment of the invention, reference is made to Figure 5 This diagram illustrates a service monitoring connection of task nodes according to an embodiment of the present invention. After initializing the vertex and edge tables of the directed acyclic graph (DAG), the Server service monitors the connections of each task node. Once a task node completes a connection, it enters a ready state and awaits scheduling control from the scheduler. After all nodes are ready, a topological sorting method is used, selecting a node with an out-degree of 0 to wake it up each time. After a task node completes its task, it calls a system call to relinquish CPU computing resources and enters a ready state to await scheduling in the next cycle. While relinquishing CPU computing resources, the scheduler selects a task with an out-degree of 0 for execution. If there are multiple tasks with an out-degree of 0, the scheduler selects an idle CPU to allow multiple tasks to run in parallel.

[0117] Several synchronization control problems exist: 1) Repeated scheduling of a single directed acyclic graph (DAG) and node synchronization control; 2) Multiple task nodes may exist in parallel in a single DAG; 3) Parallel scheduling of multiple DAGs.

[0118] To address the above situation, it is necessary to manage the directed acyclic graph (DAG) using multiple graphs. In this embodiment of the invention, management can be implemented asynchronously. That is, the server does not actively wait for a node to finish running during scheduling, but instead drives the scheduling of the DAG through messages such as the connection of each task node, node execution, and graph creation.

[0119] Specifically, in one embodiment of the present invention, a directed acyclic graph can also be created or updated using the following method, and the task can be scheduled based on the created or updated directed acyclic graph and a scheduling policy, including:

[0120] When a message from a new task node is received, the directed acyclic graph is updated according to the new task node.

[0121] The tasks are scheduled according to the updated directed acyclic graph and the scheduling policy; and...

[0122] Upon receiving a message indicating that a task node has completed execution, the directed acyclic graph is updated based on the completed task node.

[0123] The tasks are scheduled according to the updated directed acyclic graph and the scheduling policy; and...

[0124] When a message to create a directed acyclic graph is received, a new directed acyclic graph is created.

[0125] The tasks are scheduled according to the created directed acyclic graph and the scheduling policy.

[0126] In this embodiment of the invention, when a new task node is connected, or a task node completes execution, or a new directed acyclic graph (DAG) is created, a corresponding message is sent to notify the scheduler to process it. After receiving the message, the scheduler dynamically adjusts the scheduling strategy based on the current state of the DAG and the dependencies between tasks. Then, it can select a suitable task node for execution based on the scheduling strategy, for example, selecting a task with an out-degree of zero for execution.

[0127] Advantages of asynchronous scheduling: 1. Minimal performance overhead; 2. No additional multi-threaded resource consumption; 3. No cumbersome synchronization issues. (See reference...) Figure 6a This is a flowchart of task execution provided by an embodiment of the present invention. The scenario in which the server initiates DAG scheduling is as follows: When a node accesses via IPC, if a graph has already been created, DAG scheduling is initiated; when a node finishes execution and relinquishes its CPU computing resources, all graphs associated with the current node are scheduled; when the control process sends a DAG creation message, the created graph is scheduled; task nodes need to perform one IPC (Inter-Process Communication) to notify the server to construct the DAG task topology relationship.

[0128] Reference Figure 6b This is a flowchart of task execution provided in an embodiment of the present invention. The task scheduling control is implemented in user space and is implemented through the sched_ext scheduler (scheduling class). All DAG tasks can be dynamically added to the DAG scheduling topology.

[0129] (1) In the DAG main scheduling process, it is responsible for loading the sched_ex bpf program (eBPF program) and controlling the process execution of the ext scheduling class.

[0130] (2) During the initialization and execution of a DAG task, the task's dependencies (Directed Acyclic Graph, DAG) are communicated to the DAG master scheduler via a message queue. The DAG master scheduler is responsible for maintaining the topological relationships of the DAG task processes. In a specific example, the programming model for a DAG task is as follows:

[0131]

[0132] (3) After the task is completed, call sched_yield to yield the CPU computing resources. The task will be added to the scheduling queue. In the sched_ex scheduling class, use the bpf program, dag_enqueue to control the thread to join the user-shared queue enqueued, bpf_map_push_elem(&enqueued,&task,0) to enter the ready state and wait for the scheduler's scheduling control. At the same time, dispatch_dag_scheduler is needed to make the DAG scheduler run to control the scheduling of DAG tasks.

[0133] (4) When the sched_ex dag scheduling process runs, dispatch_batch will use topological sorting to select tasks from nodes with an out-degree of 0 and delete them from the user queue enqueued. bpf_map_update_elem(dispatched_fd,NULL,&pid,0) will put the tasks into the scheduling queue dispatched. At the same time, drain_enqueued_map will query the threads scheduled by enqueued_fd and perform topological sorting based on the task dependencies before putting them into the user queue.

[0134] (5) The Linux kernel needs the sched_ex class to dispatch tasks. It will call the BPF program BPF_STRUCT_OPS(dag_dispatch), retrieve the thread p that the user master process (user space program) just woken up (thread p is the thread after the user space program releases the CPU computing resources) from if(bpf_map_pop_elem(&dispatched,&pid)), and scx_bpf_dispatch(p,SCX_DSQ_GLOBAL,SCX_SLICE_DFL,0); finally put it into the global scheduling queue SCX_DSQ_GLOBAL for kernel scheduling. In this way, the task is executed based on the thread after the CPU computing resources are released.

[0135] In this embodiment of the invention, `sched_ext` is a scheduling class that runs in parallel with existing scheduling classes such as CFS and realtime. However, it allows scheduling behavior to be implemented by an eBPF program, thus enabling rapid iteration of new scheduling strategies. This allows for customized scheduling behavior for autonomous driving and non-intrusive deployment of the scheduler in the production environment. The programmable scheduling class provides user-programmable scheduling control for the same type of processes, meeting user scheduling requirements. By using the `sched_ex` scheduling class developed based on eBPF, a DAG scheduling algorithm is implemented in user space to optimize the performance of DAG scheduling. Compared to directly using the Linux system's message queue wake-up and kernel-level scheduling, the `sched_dag` in this embodiment reduces wake-up latency and the time spent selecting runnable nodes in DAG scheduling.

[0136] Experiments have shown that the scheduling delay of 40-50µs (microseconds) introduced in this embodiment of the invention saves half the time compared to the average delay of 90µs when using message queues in Linux systems.

[0137] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.

[0138] Reference Figure 7 This diagram illustrates a structural schematic of a vehicle event processing device according to an embodiment of the present invention, applied to a vehicle's intelligent driving system. The intelligent driving system includes a user space and a kernel space. The user space includes user space programs and kernel space programs. The kernel space includes a directed acyclic graph scheduling process. The device includes:

[0139] The directed acyclic graph acquisition module 701 is used to acquire the directed acyclic graph corresponding to the event when the event of the intelligent driving system is triggered; the directed acyclic graph defines the task corresponding to the event and the dependency relationship between the tasks;

[0140] The kernel space program loading module 702 is used to call the user space program to load the kernel space program into the kernel space; the kernel space program and the user space program communicate through a kernel mapping table, and the kernel space program is configured with a scheduling policy for tasks;

[0141] A directed acyclic graph sending module 703 is used to send the directed acyclic graph to the directed acyclic graph scheduling process;

[0142] Kernel space program calling module 704 is used to call the directed acyclic graph scheduling process to load the kernel space program;

[0143] The task execution module 705 is used to schedule the task according to the directed acyclic graph and the scheduling strategy.

[0144] In one embodiment of the present invention, the kernel space program loading module 702 is used for:

[0145] The program code of the kernel space program is obtained by calling the user space program and then compiled into bytecode by the compiler;

[0146] Load the bytecode into the kernel space;

[0147] If the bytecode of the kernel space program is successfully verified by the verifier in the kernel space, the compiler in the kernel space will convert the bytecode of the kernel space program into a machine-specific instruction set so that the kernel space program can run in the kernel space.

[0148] In one embodiment of the present invention, the kernel space program loading module 702 is used for:

[0149] If the bytecode of the kernel space program fails to be verified by the verifier in the kernel space, a message refusing to load the kernel space program is returned to the user space program.

[0150] In one embodiment of the present invention, the task execution module 705 is used for:

[0151] The directed acyclic graph scheduling process is invoked to parse the directed acyclic graph and generate task topology relationships. The task topology relationships include the task nodes corresponding to the tasks, the topological order between the task nodes, and the in-degree and out-degree of each task node. The in-degree is used to represent the number of times the task node is dependent on other task nodes, and the out-degree is used to represent the number of times the task node depends on other task nodes.

[0152] The tasks are scheduled according to the task topology and the scheduling policy.

[0153] In one embodiment of the present invention, the task node includes a task process identifier, a task name, and a dependent task name; the task execution module 705 is used for:

[0154] The task name of the task node is placed into the user queue of the kernel-mode program according to the topological order among the task nodes.

[0155] Use the task name corresponding to the task node with an out-degree of zero in the user queue as the target task name;

[0156] The target task name is added to the scheduling queue of the kernel program, and the task corresponding to the target task name in the scheduling queue is executed.

[0157] In one embodiment of the present invention, adding the target task name to the scheduling queue of the kernel-mode program and executing the task corresponding to the target task name in the scheduling queue includes:

[0158] Obtain the computing resources released by the user-space program;

[0159] The computing resources are placed into a global call queue, so that the task corresponding to the target task name in the call queue can be executed based on the computing resources in the global call queue.

[0160] In one embodiment of the invention, the kernel space program is written based on an extended Berkeley packet filter.

[0161] This invention can be applied to intelligent driving systems for vehicles. The intelligent driving system includes a user space and a kernel space. The user space includes user space programs and kernel space programs, while the kernel space includes a directed acyclic graph (DAG) scheduling process. When an event is triggered in the intelligent driving system, the corresponding DAG is obtained. The DAG defines the tasks corresponding to the event and the dependencies between tasks. The user space program is invoked to load the kernel space program into the kernel space. The kernel space program and the user space program can communicate through a kernel mapping table. The kernel space program has a scheduling policy for tasks. The DAG is sent to the DAG scheduling process, which then loads the kernel space program and schedules tasks according to the DAG and the scheduling policy. This invention reduces the latency of waking up messages in user space via the operating system's message queue, as is done in existing technologies, by writing a kernel space program to load the kernel space program implemented in user space into the kernel space for execution. Furthermore, this embodiment of the invention uses a directed acyclic graph (DAG) to schedule processes, and performs task scheduling based on the dependencies and scheduling strategies between tasks in the DAG, thereby reducing the time spent selecting runnable tasks and improving the efficiency of event processing for the intelligent driving system.

[0162] An embodiment of the present invention also provides an electronic device, which may include a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the vehicle event handling method described above.

[0163] An embodiment of the present invention also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, it implements the above-described vehicle event handling method.

[0164] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0165] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0166] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0167] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0168] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0169] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0170] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the present invention.

[0171] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.

[0172] The above provides a detailed description of the vehicle event handling method, apparatus, vehicle, equipment, and medium. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A vehicle event processing method, characterized by, The application relates to a smart driving system applied to a vehicle, wherein the smart driving system comprises a user space and a kernel space, the user space comprises a user space program and a kernel space program, the kernel space comprises a directed acyclic graph scheduling process, and the method comprises the following steps: When an event of the smart driving system is triggered, a directed acyclic graph corresponding to the event is acquired; the directed acyclic graph defines tasks corresponding to the event and a dependency relationship between the tasks; A user space program is called to load a kernel space program into the kernel space; the kernel space program and the user space program communicate through a kernel mapping table, and a scheduling strategy for the tasks is set in the kernel space program; The directed acyclic graph is sent to the directed acyclic graph scheduling process; The directed acyclic graph scheduling process is called to load the kernel space program; The tasks are scheduled according to the directed acyclic graph and the scheduling strategy.

2. The method of claim 1, wherein, The calling of the user space program to load the kernel space program into the kernel space comprises the following steps: The user space program is called to acquire program codes of the kernel space program to form byte codes through a compiler; The byte codes are loaded into the kernel space; If the byte codes of the kernel space program are verified successfully by a verifier of the kernel space, the byte codes of the kernel space program are converted into a machine-specific instruction set through the compiler of the kernel space, so that the kernel space program runs in the kernel space.

3. The method of claim 2, wherein, The calling of the user space program to load the kernel space program into the kernel space further comprises the following steps: If the byte codes of the kernel space program fail to pass the verification of the verifier of the kernel space, a message of refusing to load the kernel space program is returned to the user space program.

4. The method according to any one of claims 1 to 3, characterized in that, The scheduling of the tasks according to the directed acyclic graph and the scheduling strategy comprises the following steps: The directed acyclic graph scheduling process is called to parse the directed acyclic graph and generate a task topology relationship; the task topology relationship comprises task nodes corresponding to the tasks, a topology order between the task nodes, and in-degree and out-degree of each task node, wherein the in-degree represents a number of times that the task node is depended on by other task nodes, and the out-degree represents a number of times that the task node depends on other task nodes; The tasks are scheduled according to the task topology relationship and the scheduling strategy.

5. The method of claim 4, wherein, The task nodes comprise task process identifiers, task names and names of depended tasks, and the scheduling of the tasks according to the task topology relationship and the scheduling strategy comprises the following steps: The task names of the task nodes are put into a user queue of the kernel state program according to the topology order between the task nodes; Task names corresponding to task nodes with zero out-degree in the user queue are taken as target task names; The target task names are added to a scheduling queue of the kernel state program, and tasks corresponding to the target task names in the scheduling queue are executed.

6. The method of claim 5, wherein, The adding of the target task names to the scheduling queue of the kernel state program and the execution of the tasks corresponding to the target task names in the scheduling queue comprise the following steps: Computing resources released by the user space program are acquired; Put the computing resource into a global call queue to execute a task corresponding to a target task name in the call queue based on the computing resource in the global call queue.

7. The method of claim 6, wherein, The computing resource released by the user space program is obtained, including: After the task node completes the task, the task node enters a ready state to wait for the next scheduling; The computing resource released by the task node in the ready state is obtained to execute a task corresponding to the target task name in the scheduling queue, and the task corresponding to the target task name is a task corresponding to a task name with an out-degree of zero in the user queue.

8. The method of claim 1, wherein, The method further comprises: When a message of a new task node is received, updating the directed acyclic graph according to the new task node; Scheduling the tasks according to the updated directed acyclic graph and the scheduling strategy.

9. The method of claim 1, wherein, The method further comprises: When a message of a task node execution completion is received, updating the directed acyclic graph according to the task node execution completion; Scheduling the tasks according to the updated directed acyclic graph and the scheduling strategy.

10. The method of claim 1, wherein, The method further comprises: When a message of creating a directed acyclic graph is received, creating a new directed acyclic graph; Scheduling the tasks according to the created directed acyclic graph and the scheduling strategy.

11. The method of claim 1, wherein, The kernel space program is written according to an extended Berkeley packet filter.

12. A vehicle event processing apparatus characterized by comprising: The intelligent driving system applied to a vehicle, the intelligent driving system including a user space and a kernel space, the user space including a user space program and a kernel space program, and the kernel space including a directed acyclic graph scheduling process, the apparatus comprising: A directed acyclic graph obtaining module is configured to obtain a directed acyclic graph corresponding to an event of the intelligent driving system when the event is triggered, and the directed acyclic graph defines tasks corresponding to the event and a dependency relationship between the tasks. A kernel space program loading module is configured to load the kernel space program to the kernel space by calling the user space program, and the kernel space program and the user space program communicate through a kernel mapping table, and a scheduling strategy for the tasks is set in the kernel space program. A directed acyclic graph sending module is configured to send the directed acyclic graph to the directed acyclic graph scheduling process. A kernel space program calling module is configured to load the kernel space program by calling the directed acyclic graph scheduling process. A task execution module is configured to schedule the tasks according to the directed acyclic graph and the scheduling strategy.

13. An electronic device, comprising: The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the vehicle event processing method according to any one of claims 1 to 11.

14. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the vehicle event processing method according to any one of claims 1 to 11.