-
Notifications
You must be signed in to change notification settings - Fork 2k
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
vtimer: Callback timer #860
Comments
One has to think about how to determine the best stack size for this handler thread. |
Because I did not know an answer for this, I did not started an actual pull request. |
I'd prefer instead of the content of the inner if in
for consistency and readability. |
I don't like this idea:
|
I agree that there some open points to discuss, but I wouldn't discard the idea in general.
Definitely a point to discuss, but I guess setting it to an default value of
I don't understand this question.
Valid question, but if it is well-defined, I don't see a fundamental problem here.
Also up to discuss, but assigning a very priority to the thread itself and then evaluating the calling threads priority seems like a good approach to me. |
Though the issue number is low, I would like to untag this issue, since I still like the idea but wouldn't give it a high priority. |
Hm, although I agree to Kaspar's concerns, I still think that we should have some solution for this issue. |
And I'm still thinking this. |
Me to, It would be nice to not have to create a task and stack for just one periodical timer which have to run once in a while... One solution would be to use the IDLE task to schedule |
If you are using a stack for your main anyways then you don't need an extra thread for your periodic task. .. assuming you do msg_recv() in your main loop |
Valid, but than you would need to write your own API in your application and copy past it to all your projects. Because I would like to give all my event / interrupt driven systems to periodically update something... I use the ARM system clock for this, but it could be any timer, like xtimer
|
Maybe I didn't understand it correctly, but this seems like a re-implementation of the xtimer. Why not just use the xtimer? You could then concentrate only on receiving your custom event in your main loop and executing whatever callback fits to the incoming msg_t. But you would need to re-trigger the timer to make it periodic in the current xtimer implementation. However, that's just one extra line |
This is something I use on bare metal projects :) But I think your right, although it could be nice to add the functionality you described to a module so it's easier to use for everyone. Would this be a good idea? This would also come in handy for modules I wrote like TFTP and DNS. Since this probably will be system modules, they can't use this "application" logic per default. |
I would go for something similar like drafted below. I don't know how to put this programming paradigm into a module (: Doesn't this example fit your needs?
|
Not entierly, but I get the idea. One message type and one xtimer would be enough for me. If you sort them and get the first one that should be triggered. And I want them to be able to dynamically (un)register, so the LCD drawer (for example) won't depend on specific code for the LCD drawer in another location than the LCD drawer itself. Every module / application part needs to be able to work on it's own without depending on code in common sources. Which I most of the time only use to connect parts to one another. Please note that I most of the time don't use embedded OS'es, only when networking is required. |
I'm happy with the solution provided by xtimer. Since vtimer is basically not existent anymore I would prefer to close this issue. If you want to discuss more complex timer callbacks I would prefer to do this in a new issue. |
Ok |
Did someone open a new issue? I think the problem of how to trigger a callback function when a timer expires does still exist in xtimer or am I mistaken? |
I take this as a no. |
@OlegHahm Correct, same "problem" with xtimer. At least xtimer clearly documents the dangers of using in-ISR callbacks. |
I guess I never understood the question correctly. It is possible with xtimer (and was with vtimer) to listen to a message, receive this message and act appropriately to this message with a function call (callback). |
@cgundogan On other systems (POSIX...), it is possible to have asynchronous timer callbacks, e.g., set timer, continue work, and the timer's callback will do stuff without any waiting-for-message loop, possibly on another CPU, in the background. This has been possible with hwtimer, vtimer and xtimer forever, but only with the callback firing in ISR context. This is not considered "safe" by some, e.g., those callbacks might not behave as expected and it's easy to break stuff. |
Currently vtimer does not support callbacks publicly. As far as I know the current approach to circumvent this flaw is to start a thread everytime a certain action is needed after a certain time interval, either by the use of
vtimer_sleep()
,vtimer_set_wakeup()
, orvtimer_set_msg()
. Maybe some efficiency would be gained if these actions all were handled by a single thread. A rough scetch would beThe text was updated successfully, but these errors were encountered: