-
Notifications
You must be signed in to change notification settings - Fork 14
multi-threading for nuttx #29
Description
Hi,
@jamoralp @pablogs9 @ralph-lange
I am running into problems for an application with multiple threads for NuttX and Olimex board. You know, that I try to get the multi-threaded executor for NuttX running.
What I have done so far:
- I tested the multi-threaded exectutor under Linux (Ubuntu 18.04, local Foxy installation), which works.
- I tested single-threaded executor with a ping-pong example (communication of Agent (linux, Ubuntu 18.04, Foxy) and Olimex/NuttX , branch Foxy works
- Now I am trying to get the multi-threading executor running with micro-ros on the Olimex board. The high level concept of multithreadd executor (with single-threaded access to RCL):
- There is one executor thread, which accesses RCL layer (rcl_wait, rcl_take)
- The executor thread spawns one thread for every subscription
- If a new message arrives (tested with rcl_wait) , then it takes the data (with rcl_take), copies it and signals the worker thread to start, which will then call the callback of the subscription (using condition variables and locks)
When I try to run it on Olimex board, the threads start, but there is no progress in the main thread (aka executor).
The application uses two subscriptions and two publishers and one executor. So I don't need to change anything in the micro-ros configuration, right?
nuttx_apps/examples/uros_rbs/main_rbs.c
Line 216 in 0746a00
| RCCHECK(rclc_executor_start_multi_threading_for_nuttx(&high_executor)); |
The processing just stops after calling rcl_wait
https://github.com/micro-ROS/rclc/blob/7a5d0d254f4dbf744b04f46a14fd05de061bbeb3/rclc/src/rclc/executor.c#L1559
However, rcl_wait might not be the problem - maybe something goes wrong with the other threads and then everything stops.
I configured also the priorities:
- main_thread (aka executor loop): 130
- worker thread 1: 120
- worker thread 2: 100
So even if the worker threads are executing, the NuttX OS should be able to execute the executor loop.
I also noticed that sometimes the green light on the Olimex board starts blinking. after that not output is seen in the nsh shell (via screen terminal). What does that mean? Something really went wrong?
I wrote a simple program a main thread and two worker threads, which seems to works fine (without micro-ros functions used).
Is there anything regarding STACKSIZE I have to consider? Currently it is set to 65000 in the Makefile
When spawning threads (pthread_create), then no stack size is configured. What is the default stack size. Is it maybe too small, too large?
rclc executor:
https://github.com/micro-ROS/rclc/tree/feature/rbs-nuttx
application on olimex:
https://github.com/micro-ROS/nuttx_apps/tree/feature/foxy_rbs_executor_demo/examples/uros_rbs