]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
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 5c1857151ffd3d2efd26c5780056a513e1ed1ad0..b6efb1ae815309e672997abca57ae97a8f6906d1 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 27c723919c21c429e327f0a6eb7effa45ea0a219..452e749e10dd905592c37bb0bac78f81d403f563 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);