-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[tasklet] add generic tasklet functionality #10027
base: main
Are you sure you want to change the base?
Conversation
This commit adds support for a generic tasklet class and object that allows a callback to be executed on the context on the Thread task. This is very usefull for the platform UDP functionality and allows the execution of socket handlers on the context of the OT task instead of the task of the plaftorm UDP. GenericTasklet functionality and API are now available when OPENTHREAD_CONFIG_GENERIC_TASKLET_ENABLE is enabled
Size Report of OpenThread
|
Hi @abtink, can you please, have a look at this proposal and let me know what you think? The general idea behind this PR is to be able to re-use, in an RTOS environment, the openthread task for executing socket handlers of openthread modules that receive data from an external interface. Some examples would be mDNS or Meschop when connecting to an external commissioner. Packets received on the external interface are processed on the external IP task and are delivered to openthread using platform UDP. We don't want the openthread processing to happen on the external IP task. We also don't want to create another task that handles this processing as it consumes more heap for the stack size. So this new tasklet functionality allows us to handle this problem in a simple and clean way. There are other external ways to post to the openthread task depending on the application but this solution allows us to make this application and RTOS agnostic. Thanks! |
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.
Thanks!
The feature and code look well-implemented, and I can see its potential usefulness.
However, I believe this functionality is better suited for the platform or OS level, rather than being part of the OpenThread stack and API. We aim to keep OpenThread focused on providing Thread-specific networking capabilities, avoiding extensions that could potentially overlap with OS responsibilities.
Similar to this, we've had requests in the past to expose timer APIs for use by applications. We intentionally avoided this, instead expecting the platform/OS to provide timer functionality.
@@ -51,6 +51,33 @@ extern "C" { | |||
* | |||
*/ | |||
|
|||
#if OPENTHREAD_CONFIG_GENERIC_TASKLET_ENABLE |
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.
Public/platform headers cannot use OPENTHREAD_CONFIG_*
definitions because these headers might be included by external projects lacking those definitions.
Instead, we document it as a requirement. "Requires OPENTHREAD_CONFIG_*".
Hi @abtink, I see your point but am returning to this subject with another idea as we still want to use a simpler solution than creating a new functionality at the platform/OS level. My main goal is to have a Matter and OT example working without specific code in Platform UDP. The proposed approach is to implement a new platform API, The API description would explain that when a dedicated task is available the socket handler can be executed directly from that task but when there is no such task, this API should be used instead to ensure that the handler is executed in the context of the OT task to prevent any unwanted issues like deadlocks or stack overflows. What do you think about this idea? If this is a good contribution to the OT stack I will start working on a PR. |
I am not sure if this would be possible. All OT APIs, callbacks and internal methods must run in the same OS execution context (the same RTOS task or same thread). This would apply to So if the intention is to allow |
This commit adds support for a generic tasklet class and object that allows a callback to be executed on the context on the Thread task. This is very usefull for the platform UDP functionality and allows the execution of socket handlers on the context of the OT task instead of the task of the plaftorm UDP.
GenericTasklet functionality and API are now available when OPENTHREAD_CONFIG_GENERIC_TASKLET_ENABLE is enabled