-
Notifications
You must be signed in to change notification settings - Fork 3k
[RTOS] Added idle hook API #1597
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
Conversation
Added a new API for attaching a user-provided function to be executed by the idle task.
@adamgreen, I've created a new pull-request for my RTOS idle hook API, and incorporated your recommendations from #1463. |
@@ -204,17 +204,12 @@ | |||
/*---------------------------------------------------------------------------- | |||
* OS Idle daemon | |||
*---------------------------------------------------------------------------*/ | |||
extern void rtos_idle_loop(void); |
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.
Why did you not just #include "rtos_idle.h" instead to get the function prototype for rtos_idle_loop() since that header contains the prototype as well? Or maybe consider removing the prototype for rtos_idle_loop() from rtos_idle.h so it isn't exposed from the more public header and then keep these forward declarations in the RTX_Conf* sources.
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.
I was mirroring the way mbed_die()
is forward declared for the error functions, and forgot to remove the unnecessary declaration from rtos_idle.h. Fixed in c52e0dc.
Removed unnecessary loop function prototype.
👍 |
Looks good to me. cc @sg- |
👍 As a future improvement it'd be nice to have the same interface that supports https://github.com/mbedmicro/mbed/blob/master/libraries/mbed/api/FunctionPointer.h |
@neilt6 Referenced PR is having troubles, I'll investigate why CI did not catch this |
@0xc0170 That's interesting... What if we added a prototype for Proposed rtos_idle.h:
Proposed RTX_Conf_CM.c:
|
I suspect that this has something to do with a circular dependency. Previously the C++ code in rtos/rtos just depended on the rtos/rtx code but this change introduced a circular dependency where rtos/rtx now depends on rtos/rtos as well. Can the rtos_idle.* files not be placed in the RTX directory with the rest of the C code? |
Yes, they just need to be duplicated for the three "versions" of RTX. |
Added a new API for attaching an idle hook to be executed by the idle task. This will allow developers to add custom logic to the idle task (e.g. to call
sleep()
) without modifying the library code.Updated version of #1463.