Skip to content
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

Refactor ExecutionEngine operation processing for slave components #289

Conversation

meyerj
Copy link
Member

@meyerj meyerj commented May 8, 2019

The patch reverts most of the previous patches applied to the ExecutionEngine to fix the issue that OwnThread operations provided by components running in a SlaveActivity have only been executed when the slave was updated, but never asynchronously like for normal activities. This caused dead-locks in certain situations when calling operations of slaves that are never updated before the call returns. The history of the reverted patches started with #35, with follow-ups in #59, #60 and #71.

The slave_test added in https://github.com/orocos-toolchain/rtt/pull/71/files#diff-926cb9fdc506c3abaed334876a3402a5 was not reverted and still succeeds with the new patch.

The new solution to the original problem is much less intrusive: Instead of forwarding the operations calls itself and making the ExecutionEngine aware of the existence of masters and slaves, the SlaveActivity that gets triggered (e.g. as a consequence of an operation call) enqueues a message in the master's ExecutionEngine that processes the triggers in the slave's ExecutionEngine work(Trigger) callback, which then processes all the pending messages (and port callbacks) of the slave. This also works across multiple levels of master/slave relations. The difference to the previous solutions is that the pending messages are still enqueued in the engine of the actual runner and explicit calls to Slave.update() from the master thread will also process the pending operations of the slave - but not of the master itself.

The work(Trigger) callback was only introduced in #91 and not yet available back in 2014. Without, it would not be possible to selectively process asynchronous messages of the slave without also triggering synchronous processing steps like updateHook(). In general, since #91 operations and event port callbacks are executed asynchronously, as part of the callback step, while before they were only executed through a full (periodic or non-periodic) update step.

@goldhoorn As the original reporter and author of the first proposed solution in #35, and in case you are still using RTT, could you please test this alternative approach for your application(s)?

The patch reverts most of the previous patches applied to fix the issue that `OwnThread` operations provided by components running in a SlaveActivity have only been executed when the slave was updated, but never asynchronously like for normal activities. This caused dead-locks in certain situations when calling operations of slaves that are never updated before the call returns. The history of the reverted patches started with #35, with follow-ups in https://github.com/orocos-toolchain/rtt/issue/59, #60 and #71.

The `slave_test` added in one of the original PRs was not reverted and still succeeds with the new patch.

The new solution to the original problem is much less intrusive: Instead of forwarding the operations calls itself and making the ExecutionEngine aware of the existence of masters and slaves, the SlaveActivity that gets triggered (e.g. as a consequence of an operation call) enqueues a message in the master's ExecutionEngine that processes the triggers in the slave's ExecutionEngine `work(Trigger)` callback, which then processes all the pending messages (and port callbacks) of the slave. This also works across multiple levels of master/slave relations. The difference to the previous patch is the pending messages are still enqueued in the engine of the actual runner and explicit calls to `Slave.update()` from the master thread will also process the pending operations of the slave - but not of the master.

Signed-off-by: Johannes Meyer <johannes@intermodalics.eu>
@meyerj meyerj added this to the 2.10 milestone May 8, 2019
Copy link
Contributor

@francisco-miguel-almeida francisco-miguel-almeida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@francisco-miguel-almeida francisco-miguel-almeida merged commit 809e15c into master May 27, 2019
@meyerj meyerj deleted the master-refactoring-executionengine-slave-behavior branch June 3, 2019 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants