Replies: 1 comment 3 replies
-
According to the code, the What hw this is? Note that for offloaded drivers, the resolution is milliseconds (instead of microseconds) for the poll/select API. zephyr/subsys/net/lib/sockets/sockets.c Lines 1594 to 1606 in 868b180 |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
While my testing was using the zsock_select() API, since it appears to be a wrapper on the zsock_poll() API, I believe this issue applies to both APIs (z_impl_zsock_select calls zsock_poll_internal).
I have used this statement in both desktop and embedded Linux for multiplexed i/o with sockets, but it also to provide a high precision timer mechanism for epoch based activities. The specification for the Linux "select" statement indicates that when the thread pending on this statement is awaken due to a timeout condition, "that the blocking interval may overrun by a small amount", where this amount is not specified in the function definition - but in my experience was measured in single and double digit microseconds.
https://man7.org/linux/man-pages/man2/select.2.html
In my current Zephyr experience, I am finding this small amount to be measured in 2 to 6 milliseconds with some operational frequency as many times per second.
An example log is show as follows, where the conditions for zsock_select() are logged as "select IN" where for testing, I am using a fixed timeout of 500 usec only. Nominally, the timeout value used would be the time until the start of the next 10 ms epoch.
The "select OUT" statement is written only when the elapsed time that the thread was pending in the zsock_select() statement measured exceeds the 500 used timeout. I am using the system time at a 10 ms epoch rate, where I need to hit the epoch boundary with an accuracy to hundreds of microseconds. This sample shows an elapsed time of almost 3 ms whereas the timeout value into the API is 500 microseconds, a six fold "overrun".
I am trying to understand why this thread wake up on timeout condition has significant "overrun" relative to my embedded Linux experiences - and if there is anything that I can do about it to be able to used this statement for high precision timing.
If this is simply the way it behaves, and that behavior is well understood, perhaps a suggestion on an implementation using a Zephyr timer would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions