-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dispatcher Executor #87
Conversation
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
…elper functions Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
… creation of threads does not work on the micro-ros board, yet. green light is blinking and no response from nsh shell. updated unit test accordingly. Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
…ocessing - for some reason. Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
… New mutex micro_ros_mutex for guarding access to rcl-layer including any potential rcl_publish in subscription callbacks, removed guard condtiion, Pablo says that guard condition does not wake up rcl_wait, but only after the timeout the bit will be set, removed bool any_worker_thread_state_changed because wait_set needs to be always updated. Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
…ng parameter with both policy and sched param. Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
0149c56
to
1bd2891
Compare
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Codecov Report
@@ Coverage Diff @@
## master #87 +/- ##
==========================================
- Coverage 69.20% 69.14% -0.07%
==========================================
Files 16 16
Lines 2715 2716 +1
Branches 765 765
==========================================
- Hits 1879 1878 -1
- Misses 450 451 +1
- Partials 386 387 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Co-authored-by: Ralph Lange <ralph-lange@users.noreply.github.com>
Co-authored-by: Ralph Lange <ralph-lange@users.noreply.github.com>
Co-authored-by: Ralph Lange <ralph-lange@users.noreply.github.com>
Co-authored-by: Ralph Lange <ralph-lange@users.noreply.github.com>
Co-authored-by: Ralph Lange <ralph-lange@users.noreply.github.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Created this branch feature/dispatcher-executor-with-guard-condition-check on github/micro-ros including the guard_condition check (if a thread becomes available). |
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hello @JanStaschulat, I guess that we need a refactor here in order to merge into My proposals are:
Ideally, I would like to see this as another package in this RCLC repo and outside of So, ideally for me, this contribution shall add the new functionality letting the old mode by default. |
Hi @pablogs9, thanks for pointing that out. I would propose
Benefit:
rclc_executor.h /// Container for RCLC-Executor
typedef struct
{
// ...
/// interface for multi-threaded executor
void * mt;
} rclc_executor_t; rclc_executor_handle.h /// Container for a handle.
typedef struct
{
// ...
/// interface for multi-threaded executor handle
void * mt;
} rclc_executor_handle_t; rclc_multi_threaded_executor.h #include <pthread.h>
#include <sched.h>
typedef struct
{
pthread_mutex_t * thread_state_mutex;
pthread_mutex_t * micro_ros_mutex;
rclc_executor_handle_t * handle;
}
rclc_executor_worker_thread_param_t;
/// Implementation for sporadic server scheduler
typedef enum
{
RCLC_THREAD_NONE,
RCLC_THREAD_READY,
RCLC_THREAD_BUSY
} rclc_executor_thread_state_t;
/// Scheduling policy (SCHED_FIFO, SCHED_SPORADIC) and sched_param
typedef struct
{
int policy;
struct sched_param param;
} rclc_executor_sched_parameter_t;
.... // all the other strucs and #includes
typedef struct
{
pthread_mutex_t thread_state_mutex;
/// multi-threaded executor: mutex for RCL layer
pthread_mutex_t micro_ros_mutex;
} rclc_executor_multi_threaded_interface_t;
typedef struct
{
/// variables for multi-threading
/// worker thread
pthread_t worker_thread;
/// worker thread state and its mutex
rclc_executor_thread_state_t worker_thread_state;
/// signaling condition variable and its mutex
pthread_cond_t new_msg_cond;
pthread_mutex_t new_msg_mutex;
bool new_msg_avail;
/// scheduling parameter
rclc_executor_sched_parameter_t * sparam;
pthread_attr_t tattr;
} rclc_executor_handle_multi_threaded_interface_t;
void rclc_executor_multi_threaded_init(rclc_executor_t * executor, ...)
{
rclc_executor_multi_threaded_interface_t * mt_interface = executor->allocator->allocate(
(sizeof(rclc_executor_multi_threaded_interface_t)),
executor->allocator->state);
executor->mt = mt_interface;
}
// similar add the struct to each rclc_executor_handle |
That approach looks great to me. Please use Just for curiosity, that would enable us to create independent packages with different multithread executors targets such as |
Yes, absolutly. We were even thinking about some intermediate executor interface functions to abstract the actual operating system function calls; similar to the approach for custom_transport layer in xrce-dds. |
That abstraction layer is interesting, ideally, IMO it shall be implemented in RCL or RMW. But it can be such a big business. |
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
…rker threads Signed-off-by: Jan Staschulat <jan.staschulat@de.bosch.com>
Hi @pablogs9 @ralph-lange , I moved all the code of the multi-threaded executor to a new package I added also an example program There are still some issues open:
Note: the build job on the OpenRobotics build farm (Rpr__rclc__ubuntu_jammy_amd64) fails only because of a timeout of |
will be part of the pull request #339 |
Implements a multi-threaded Executor.
New API Feature:
Implementation:
Limitation:
Example:
Publication: