From: Andre Noll Date: Wed, 13 Jul 2011 19:13:32 +0000 (+0200) Subject: sched: Improve sched_request_barrier() and friends. X-Git-Tag: v0.4.8~10^2~1 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=3d6ca6e3ae198017164e544c59d622b11a5afdde;p=paraslash.git sched: Improve sched_request_barrier() and friends. Make these functions tell its caller whether the given barrier was in the past. This is useful for vss because for certain barriers, no other actions should be performed before the barrier has passed. --- diff --git a/alsa_write.c b/alsa_write.c index 6850221a..34a71f9b 100644 --- a/alsa_write.c +++ b/alsa_write.c @@ -150,10 +150,14 @@ static void alsa_write_pre_select(struct sched *s, struct task *t) if (ret == 0) return; - if (!pad) - return sched_min_delay(s); - if (ret < 0) - return sched_request_barrier_or_min_delay(&pad->drain_barrier, s); + if (!pad) { + sched_min_delay(s); + return; + } + if (ret < 0) { + sched_request_barrier_or_min_delay(&pad->drain_barrier, s); + return; + } /* * Data is available to be written to the alsa handle. Compute number * of milliseconds until next buffer underrun would occur. diff --git a/sched.c b/sched.c index 8baed496..65176bd9 100644 --- a/sched.c +++ b/sched.c @@ -302,17 +302,19 @@ void sched_request_timeout_ms(long unsigned ms, struct sched *s) * \param barrier Absolute time before select() should return. * \param s Pointer to the scheduler struct. * - * If \a barrier is in the past, this function does nothing. + * \return If \a barrier is in the past, this function does nothing and returns + * zero. Otherwise it returns one. * * \sa sched_request_barrier_or_min_delay(). */ -void sched_request_barrier(struct timeval *barrier, struct sched *s) +int sched_request_barrier(struct timeval *barrier, struct sched *s) { struct timeval diff; if (tv_diff(now, barrier, &diff) > 0) - return; + return 0; sched_request_timeout(&diff, s); + return 1; } /** @@ -321,15 +323,19 @@ void sched_request_barrier(struct timeval *barrier, struct sched *s) * \param barrier Absolute time before select() should return. * \param s Pointer to the scheduler struct. * - * If \a barrier is in the past, this function requests a minimal timeout. + * If \a barrier is in the past, this function requests a minimal timeout and + * returns zero. Otherwise it returns one. * * \sa sched_min_delay(), sched_request_barrier(). */ -void sched_request_barrier_or_min_delay(struct timeval *barrier, struct sched *s) +int 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); + if (tv_diff(now, barrier, &diff) > 0) { + sched_min_delay(s); + return 0; + } sched_request_timeout(&diff, s); + return 1; } diff --git a/sched.h b/sched.h index e018c2fe..ea9578f7 100644 --- a/sched.h +++ b/sched.h @@ -81,5 +81,5 @@ void sched_shutdown(void); void sched_min_delay(struct sched *s); void sched_request_timeout(struct timeval *to, 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); +int sched_request_barrier(struct timeval *barrier, struct sched *s); +int sched_request_barrier_or_min_delay(struct timeval *barrier, struct sched *s);