Thread Carefully: Preventing Starvation in the ROS 2 Multithreaded Executor
The robot operating system 2 (ROS 2) is a widely used collection of tools and libraries for building robot applications. It is designed to be flexible and easy to use when creating complex robot systems with many interacting components.Since its alpha version release in 2015, ROS 2 provides two options in a multithreading operating system, namely the single-threaded executor and the multithreaded executor. The single-threaded executor is starvation-free by design (i.e., every task is eventually executed) even in over-utilized systems, since the set of eligible task instances (called wait set) is only refilled once all the task instances in the wait set are executed. The multithreaded executor extends this mechanism to multiple threads that manage the wait set collaboratively. While intuitively this extension preserves the starvation-free property, and analyses for the multithreaded executor even build upon this assumption, the multithreaded executor has not been shown to be starvation-free.In this work, we examine the mechanism of the multithreaded executor in ROS 2 and demonstrate that it is prone to starvation, i.e., some tasks may never be executed even in under-utilized systems. This indicates risks for multithreaded executors in the current ROS 2 design and further leads to counterexamples to the state-of-the-art response-time analyses by Jiang et al. (RTSS 2022) and Sobhani et al. (RTAS 2023). We propose a minimal change in the software architecture of the ROS 2 multithreaded executor to enable starvation- and deadlock-free behavior. We empirically test that we prevent starvation in concrete ROS 2 system configurations, and show that our solution incurs a negligible overhead using the autoware reference benchmark. Moreover, we prove that our solution is starvation- and deadlock-free using formal proofs and model checking.
- Published in:
IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems - Type:
Article - Authors:
Teper, Harun; Kuhse, Daniel; Günzel, Mario; Brüggen, Georg von der; Howar, Falk; Chen, Jian-Jia - Year:
2024 - Source:
https://ieeexplore.ieee.org/abstract/document/10745787
Citation information
Teper, Harun; Kuhse, Daniel; Günzel, Mario; Brüggen, Georg von der; Howar, Falk; Chen, Jian-Jia: Thread Carefully: Preventing Starvation in the ROS 2 Multithreaded Executor, IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, 2024, 43, https://ieeexplore.ieee.org/abstract/document/10745787, Teper.etal.2024a,
@Article{Teper.etal.2024a,
author={Teper, Harun; Kuhse, Daniel; Günzel, Mario; Brüggen, Georg von der; Howar, Falk; Chen, Jian-Jia},
title={Thread Carefully: Preventing Starvation in the ROS 2 Multithreaded Executor},
journal={IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems},
volume={43},
url={https://ieeexplore.ieee.org/abstract/document/10745787},
year={2024},
abstract={
The robot operating system 2 (ROS 2) is a widely used collection of tools and libraries for building robot applications. It is designed to be flexible and easy to use when creating complex robot systems with many interacting components.Since its alpha version release in 2015, ROS 2 provides two options in a multithreading operating system, namely the single-threaded executor and the...}}