Coroutine Task Switching for Parallel Unmanned Vehicle Computing
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Conventional multi-thread solutions for unmanned vehicle systems face significant overhead in thread switching and limited parallelism due to insufficient computing resources, leading to performance and extensibility issues in on-vehicle computing.
Innovation Solution
A coroutine framework that allows for efficient task switching by creating multiple coroutines at the user layer, executed by a thread at the kernel layer, with a context-saving and recovery mechanism to minimize overhead and enhance parallel task processing.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If multiple threads are employed for parallel execution in the kernel layer, then task parallelism is achieved, but thread switching overhead becomes considerable
Solution Approach 1:
The patent segments the thread execution model into user-level coroutines and kernel-level threads. Multiple coroutines are created at the user layer, each handling specific tasks, while the kernel layer maintains a small number of threads. This segmentation allows frequent switching between coroutines without incurring kernel-level thread switching overhead, as coroutine switching occurs in user space only.
Solution Approach 2:
The patent introduces coroutines as an intermediary layer between user-space tasks and kernel-space threads. The coroutine framework acts as a mediator that manages task execution and switching in user space, translating high-level coroutine operations into low-level thread operations only when necessary. This intermediary mechanism eliminates direct kernel-level thread switching for most task transitions.
2Productivity
If conventional multi-thread solutions are used, then parallel computing tasks can be executed, but computing resources are insufficient and performance is limited
Solution Approach 1:
The patent merges multiple user-level coroutine executions onto a single or few kernel-level threads. By combining the management of multiple coroutines within the coroutine framework and only invoking kernel threads when necessary (e.g., for system calls or blocking operations), the system achieves high-level parallelism without requiring proportional hardware resources. This merging allows efficient utilization of limited computing resources.
3Ease of operation
If thread switching is performed at the kernel layer, then task execution can be switched, but the overhead significantly impacts performance
Solution Approach 1:
The patent inverts the traditional approach by performing task switching in user space rather than kernel space. Instead of switching threads at the kernel layer, the system creates and switches coroutines at the user layer, keeping kernel thread switching to a minimum. This inversion moves the frequent switching operations to a lower-overhead user-space environment, dramatically reducing switching overhead while maintaining task switching capability.
Data Source
AI summary
Embodiments of the present disclosure provide a method and a coroutine framework for processing parallel tasks, a device, a medium and an unmanned vehicle. The method includes: switching a current coroutine to a target coroutine in response to a task switching instruction, in which, the coroutine is created at a user layer for processing a task, and the coroutine at the user layer is executed by a thread at a kernel layer; and saving context of a task processed by the current coroutine, and reading context of a task processed by the target coroutine, such that the thread at the kernel layer corresponding to the target coroutine processes the task based on the context of the target coroutine when executing the target coroutine.

