sched: Add sched_request_barrier_or_min_delay().
authorAndre Noll <maan@systemlinux.org>
Sat, 30 Jan 2010 13:22:32 +0000 (14:22 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 30 Jan 2010 13:22:32 +0000 (14:22 +0100)
This is what some tasks need, so add this public function to the scheduler.

sched.c
sched.h

diff --git a/sched.c b/sched.c
index 5c18571..b6efb1a 100644 (file)
--- a/sched.c
+++ b/sched.c
@@ -289,4 +289,11 @@ void sched_request_barrier(struct timeval *barrier, struct sched *s)
        sched_request_timeout(&diff, s);
 }
 
+void sched_request_barrier_or_min_delay(struct timeval *barrier, struct sched *s)
+{
+       struct timeval diff;
 
+       if (tv_diff(now, barrier, &diff) > 0)
+               return sched_min_delay(s);
+       sched_request_timeout(&diff, s);
+}
diff --git a/sched.h b/sched.h
index 27c7239..452e749 100644 (file)
--- a/sched.h
+++ b/sched.h
@@ -83,3 +83,4 @@ void sched_min_delay(struct sched *s);
 void sched_request_timeout(struct timeval *timeout, struct sched *s);
 void sched_request_timeout_ms(long unsigned ms, struct sched *s);
 void sched_request_barrier(struct timeval *barrier, struct sched *s);
+void sched_request_barrier_or_min_delay(struct timeval *barrier, struct sched *s);