[dpdk-dev] [PATCH v1 1/2] eal: add nanosleep based delay function
Stephen Hemminger
stephen at networkplumber.org
Wed Sep 5 15:10:59 CEST 2018
On Mon, 3 Sep 2018 17:47:42 +0300
Ilya Maximets <i.maximets at samsung.com> wrote:
>
> +void __rte_experimental
> +rte_delay_us_sleep(unsigned int us)
> +{
> + struct timespec wait[2];
> + int ind = 0;
> +
> + wait[0].tv_sec = 0;
> + if (us >= US_PER_S) {
> + wait[0].tv_sec = us / US_PER_S;
> + us -= wait[0].tv_sec * US_PER_S;
> + }
> + wait[0].tv_nsec = 1000 * us;
> +
> + while (nanosleep(&wait[ind], &wait[1 - ind]) == EINTR)
> + ind = 1 - ind;
> +}
> +
This seems like a complex/tricky way to handle the case where
nanosleep is interrupted. It needs a comment.
More information about the dev
mailing list