-
Notifications
You must be signed in to change notification settings - Fork 3k
poll is not blocking in presence of rtos #9112
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
Comments
Internal Jira reference: https://jira.arm.com/browse/MBOCUSTRIA-323 |
(Comment moved from #9113) Thanks for looking at this (and noticing it, and caring). This is a sore point in the design, and if it was as simple as #9113, it would have been done some time ago.
Now, I do have my own prototype solution, but it's been parked for a while, due to combination of lack of interest and some contention over design (mainly "does this encourage critical section use too much?", iirc). What I was aiming for with it:
First attempt is here: https://github.com/kjbracey-arm/mbed-os/commits/cv_cs Care to try that |
@kjbracey-arm The non busy waiting is important for us as we want to sleep a lot to save power. So we rolled this as our own ad-hoc solution. Lack of interest is definetly not the case if this was the reason for your delay :) |
Right, you're probably more familiar than that than I am - I had totally forgotten about Let me try to get this clear in my own head too. The FileHandle abstract API already provides:
There are currently no helpers for someone implementing
All blocks are inside the driver/helper/poll, and are always based on a
|
Okay. So it seems I understand the design. What I still don't quite get is how the global If there is such divergence in functionality, maybe this should be a separate function, it is less intrusive as a change:
The fundamental design question is - should non-blocking be imposed on the user of For the drivers the question is silly as they should use poll-wake if they can, but for normal down-to-earth file handles, this is contentious. What do you think? |
The work on that branch is not supposed to change anything about the application-facing API of
The non-wakeable filehandles are, in my version, not publically distinguished at all to users. The same API works either way, it's just an efficiency issue. Ultimately the "non-wake" case could be deprecated and retired. (Maybe it doesn't even go in in the first place? Almost every FileHandle out there I know of is either a real file or Stream derived, so has no use for So, anyway, poll currently takes non-wakeable filehandles and works, and I see no reason the user can't mix wakeable and non-wakeable. Conceivably we could have an optimisation for one that took an array of wakeable ones, but that means a new type, new PollFH, and I don't know how to work it into the POSIX I don't see any benefit to making in the dual modes into public-facing API when the old mode will be retired. And I don't want to force applications to change their existing working code to get the benefit of waking file handles. Maybe it simplifies the current implementation of
You've lost me there. Users always have the choice of blocking or non-blocking, or they can kind of mix by setting the FileHandle to nonblocking and using |
If you think the poll-wake mechansim should not be reflected in application API then I agree, but I raised it as a design question that should be answered (as it can offer an adavantage).
Maybe add to
The last sentance came out wrong :) |
So that would then be a precheck on every file descriptor in the poll array, and if every one is wakeable, call the wakeable version else the non-wakeable version. And that will always pull in both versions of poll because of that runtime test. Don't see how that's really any better than doing the test inside the first poll loop. I guess it leaves the door open to the optimised wakeable-only form for the C++, but leaves the POSIX form seriously code-size disadvantaged, which seems unhelpful. Total code size is probably bigger if you use that POSIX version.
In which case I still don't understand what the question was. Are you asking about code size cost of supporting both? If so, then my answer is to address that by dropping support for the hypothetical old FileHandles, or just not putting it in in the first place. I wouldn't want to address it by requiring anything of the application users, who have done nothing wrong. It's not their fault that |
You are right here.
If the design goal is no user intervention whatsoever then I agree, but you did not state it in the design goals you mentioned :) You have convinced me fully of your approach now :) If the way to go forward is deprecation of non-wakeble file handles with plans to remove them in the future, then how does this work? It's a deprecation of a "concept" and not specific function or something - How do users get notified of such change? I think the way forward is to kick-start your branch as a PR as you mentioned earlier. |
Good question. Best mechanism we've come up with so far is "MBED_ERROR in debug builds". Issue came up in adjustments to
Okay, I'll recheck at least the base cv_cs version and make a PR for it this week. I'm not sure if I also want to incorporate the |
Is there a TODO list for the PR? We want to help. |
Afraid I've had other stuff on my plate. #10104 in particular, and this ties in with it. I'll raise this up in 5.13 planning - this issue is another facet of power saving, but I think very few people are using these blocking APIs in such a way that they notice the issue, so it's not really got any attention. The focus has been more on identifying background periodic tickers you see generally. These tickers only show up while you're blocking, and the vast majority of our middleware is non-blocking and event-driven... |
Thank you for raising this issue. Please note we have updated our policies and |
Description
mbed_poll
does not do proper blocking in the presence of rtos.It is a form of busy waiting that prevents the microcontroller sleeping.
Note: this issue is in a TODO comment in the file, but quick search in this github does not result in any issue matching it.
Issue request type
The text was updated successfully, but these errors were encountered: