forked from ros2/rcl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Thread configuration prototype
This is a prototype implementation of RCL for discussion about the thread configuration feature to receive and apply a set of scheduling parameters for the threads controlled by the ROS 2 executor. Our basic idea is as below. 1. Implement a new class rclcpp::thread and modify rclcpp to use it. This class has the same function set as the std::thread but also additional features to control its thread attributions. 2. Modify the rcl layer to receive a set of scheduling parameters. The parameters are described in YAML format and passed via command line parameters, environment variables, or files. 3. the rclcpp reads the parameters from rcl and applies them to each thread in the thread pool. There have been some discussions about this pull request, as below. [ROS Discourse] https://discourse.ros.org/t/adding-thread-attributes-configuration-in-ros-2-framework/30701 [ROS 2 Real-Time Working Group] ros-realtime/ros-realtime.github.io#18 Signed-off-by: Shoji Morita <[email protected]>
- Loading branch information
1 parent
1cb1209
commit 73718ca
Showing
19 changed files
with
1,095 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2023 eSOL Co.,Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/// @file | ||
|
||
#ifndef RCL__THREAD_ATTR_H_ | ||
#define RCL__THREAD_ATTR_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
#include <stddef.h> | ||
|
||
#include "rcl/allocator.h" | ||
#include "rcl/macros.h" | ||
#include "rcl/types.h" | ||
#include "rcl/visibility_control.h" | ||
#include "rcl_yaml_param_parser/types.h" | ||
|
||
extern const char * const RCL_THREAD_ATTR_VALUE_ENV_VAR; | ||
extern const char * const RCL_THREAD_ATTR_FILE_ENV_VAR; | ||
|
||
/// Determine the default thread attribute from string, based on the environment. | ||
/// \param[out] thread_attrs Must not be NULL. | ||
/// \param[in] allocator memory allocator to be used | ||
/// \return #RCL_RET_INVALID_ARGUMENT if an argument is invalid, or | ||
/// \return #RCL_RET_ERROR in case of an unexpected error, or | ||
/// \return #RCL_RET_BAD_ALLOC if allocating memory failed, or | ||
/// \return #RCL_RET_OK. | ||
RCL_PUBLIC | ||
rcl_ret_t | ||
rcl_get_default_thread_attrs_from_value( | ||
rcl_thread_attrs_t * thread_attrs, | ||
rcl_allocator_t allocator); | ||
|
||
/// Determine the default thread attribute from file path, based on the environment. | ||
/// \param[out] thread_attrs Must not be NULL. | ||
/// \param[in] allocator memory allocator to be used | ||
/// \return #RCL_RET_INVALID_ARGUMENT if an argument is invalid, or | ||
/// \return #RCL_RET_ERROR in case of an unexpected error, or | ||
/// \return #RCL_RET_BAD_ALLOC if allocating memory failed, or | ||
/// \return #RCL_RET_OK. | ||
RCL_PUBLIC | ||
rcl_ret_t | ||
rcl_get_default_thread_attrs_from_file( | ||
rcl_thread_attrs_t * thread_attrs, | ||
rcl_allocator_t allocator); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // RCL__THREAD_ATTR_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.