-
Notifications
You must be signed in to change notification settings - Fork 11
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
Feature request: sleep() function #156
Comments
It seems like a reasonable request. We already have some POSIX functions that work in a relatively special way. I guess the implementation could check if there is any free timer and use that one, or we could hardcode a timer, or even have a helper function that can switch the timer that is used. I don't expect almost any game to use We would need to document the final behaviour of the function too. I'm open to suggestions. |
I think this should wait until at least one broader thing is considered: a system for allocating and freeing hardware resources like timers, DMA, etc., that homebrew in general can be encouraged to use, so we don't fall into conflicts. |
Similar to Working with ports of libraries (LVGL, lwip and others) I've noticed they want callbacks for a tick or millisecond counter, to use as a monotonic clock. This is a very common feature to have (Linux has My suggestion would be a system similar to the background APIs (like the syscall [ Another function could be made available to enable the monotonic timer systemwide. The POSIX API in particular can handle a clock not existing. It's also nice because it can get the real time clock and we already use POSIX APIs elsewhere (sockets, files). So perhaps this API doesn't need to be designed from scratch. I can work on this feature if you'd like, after the API things are decided on. |
Really, at that point we should consider morphing the coroutine system into some kind of RTOS - but I don't have the necessary field experience to start that conversation. |
I see what you mean. I don't have that experience writing OSes either. I think in the meantime I'm going to write it as an external library with the POSIX API. That way the source code is available if we ever get there. |
Yes, I think that you having your own implementation of |
Sounds good! I'm closing the feature request as "not planned". |
That is appreciated, but we still want to get around to this at some point; just not soon. |
To complement the growing set of POSIX functions, a sleep() and usleep() functions could be added to BlocksDS, making use of a hardware timer as a monotonic clock.
I understand using up timers this can interfere with some games, but it's so handy for applications (and since we have the monotonic clock, we can also implement a bunch of other time functions). In my opinion, it should be available by default under
unistd.h
, with an option to be disabled by something like#define NO_MONOTONIC
.The text was updated successfully, but these errors were encountered: