Thread (24 messages) 24 messages, 5 authors, 2018-10-26

Re: [PATCH v1 1/2] eal: add nanosleep based delay function

From: Ilya Maximets <hidden>
Date: 2018-09-10 15:09:32

On 05.09.2018 16:10, Stephen Hemminger wrote:
On Mon,  3 Sep 2018 17:47:42 +0300
Ilya Maximets [off-list ref] wrote:
quoted
 
+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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help