-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add overridable wait hook #10693
Add overridable wait hook #10693
Conversation
This comment has been minimized.
This comment has been minimized.
4 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Related issies;: |
Basic idea seems reasonable to me. But note that #10104 significantly reworks the non-RTOS case, to the extent that spinning like this will be happening much less. You should be sleeping instead. Also, having the hook in |
After #10104 in particular, a common hook point becomes The spins should just be left for I've argued against But if it was "intercept and do something else rather than sleeping" - potentially the basis for a low-priority "thread" in non-RTOS, seems potentially useful. |
Ah! I knew you were the right person to cc :) Sorry, I've been working through a long backlog and am not on top of all of the work that is going on. We can just drop the hook from wait_us, from a second look it isn't productive. And only yielding in wait_ms matches the RTOS version. I think you're right adding this to|after #10104 is the most appropriate, though this raises a few questions. I think I'll create a PR against your fork to ask them. It seems like the best places to hook into sleep are here and here (two because we only yield outside of critical sections)? Sorry I'm late on all of this, it's probably past reasonable statute of limitations for me to critically review #10104, but it looks good! Does this mean we can deprecate PlatformMutex? Deprecating |
Created PR PR here kjbracey#1 |
Useful for external yield functions, currently there's no other way to hook a yield function into a driver
I've also updated this PR to be compatible with kjbracey#1, feel free to take either. It's also out of wait_us now, although that required some duplication. |
Yes -
#10104 has just missed 5.13, so there is now time to look at it further before having it land, if you want to. Input would be appreciated. |
@kjbracey-arm what is the status of this PR ? |
Needs work - discussion is happening over on my fork (although no progress in last couple of weeks). |
I'll close this , will revise later cc @ARMmbed/mbed-os-core |
Description
Added an overridable wait hook. Intended to match the semantics of mbed_override_console.
All you need to do is create a function named "mbed_override_wait_hook", and this function will be called anytime someone attempts to wait. This will let you run other code when a device would normally be wasting cycles.
Note that mbed_override_wait_hook is explicitly not called when we are in an interrupt (the reason for core_util_are_interrupts_enabled()). This is because interrupts violate a lot of the expectations of when you would be waiting, and interrupts really shouldn't be calling wait for anything other than small nanosecond delays.
Useful for external yield functions when there is no RTOS present, currently there's no other way to hook a function into when drivers are waiting for hardware.
Related: #9141
Pull request type
Reviewers
@kjbracey-arm, @0xc0170, @loverdeg-ep
Release Notes
Same as description?