[dpdk-dev] [PATCH v1 1/2] eal: add nanosleep based delay function

Ilya Maximets i.maximets at samsung.com
Mon Sep 10 17:11:10 CEST 2018


On 05.09.2018 16:10, Stephen Hemminger wrote:
> 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.

OK. I can add some comment here.

Best regards, Ilya Maximets.


More information about the dev mailing list