diff mbox

[lng,API-NEXT,v2,3/7] linux-generic: schedule: use schedule time in ns

Message ID 1447350305-3254-4-git-send-email-ivan.khoronzhuk@linaro.org
State Superseded
Headers show

Commit Message

Ivan Khoronzhuk Nov. 12, 2015, 5:45 p.m. UTC
In the schedule_loop the wait time is passed in units of scheduler
time. At this moment there is no difference between wait time and
odp_time, but in case if odp_time is smth different from uint64_t,
it cannot be directly passed as uint64_t. So better to pass scheduler
time as ns and convert them before entering a loop.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 platform/linux-generic/odp_schedule.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c
index 884ae60..96b3ac5 100644
--- a/platform/linux-generic/odp_schedule.c
+++ b/platform/linux-generic/odp_schedule.c
@@ -586,11 +586,10 @@  static int schedule_loop(odp_queue_t *out_queue, uint64_t wait,
 			 odp_event_t out_ev[],
 			 unsigned int max_num, unsigned int max_deq)
 {
-	odp_time_t start_time, time, diff;
+	odp_time_t start_time, time, diff, wtime;
+	int first = 1;
 	int ret;
 
-	start_time = ODP_TIME_NULL;
-
 	while (1) {
 		ret = schedule(out_queue, out_ev, max_num, max_deq);
 
@@ -603,15 +602,17 @@  static int schedule_loop(odp_queue_t *out_queue, uint64_t wait,
 		if (wait == ODP_SCHED_NO_WAIT)
 			break;
 
-		if (!odp_time_cmp(ODP_TIME_NULL, start_time)) {
+		if (first) {
+			wtime = odp_time_local_from_ns(wait);
 			start_time = odp_time_local();
+			first = 0;
 			continue;
 		}
 
 		time = odp_time_local();
 		diff = odp_time_diff(time, start_time);
 
-		if (odp_time_cmp(wait, diff) < 0)
+		if (odp_time_cmp(wtime, diff) < 0)
 			break;
 	}
 
@@ -652,7 +653,7 @@  void odp_schedule_resume(void)
 
 uint64_t odp_schedule_wait_time(uint64_t ns)
 {
-	return odp_time_to_u64(odp_time_local_from_ns(ns));
+	return ns;
 }