From 47f8db48b1012ec5571a9946ac9d9e39b26ba9be Mon Sep 17 00:00:00 2001 From: Timo Hirvonen Date: Sun, 11 May 2008 18:50:08 +0300 Subject: [PATCH] Check if real-time scheduling is supported --- configure | 30 ++++++++++++++++++++++++++++++ player.c | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 1036cf3..07e6ee1 100755 --- a/configure +++ b/configure @@ -44,6 +44,35 @@ check_compat() makefile_vars COMPAT_LIBS } +rtsched_code=" +#include + +int main(int argc, char *argv[]) +{ + pthread_attr_t attr; + struct sched_param param; + + pthread_attr_init(&attr); + pthread_attr_setschedpolicy(&attr, SCHED_RR); + param.sched_priority = sched_get_priority_max(SCHED_RR); + pthread_attr_setschedparam(&attr, ¶m); + return 0; +} +" + +check_rtsched() +{ + msg_checking "for realtime scheduling" + if try_compile_link "$rtsched_code" $PTHREAD_CFLAGS $PTHREAD_LIBS + then + msg_result yes + EXTRA_CFLAGS="$EXTRA_CFLAGS -DREALTIME_SCHEDULING" + else + msg_result no + fi + return 0 +} + check_ncurses() { if check_library NCURSES "" -lncursesw @@ -269,6 +298,7 @@ check check_endianness check check_compat check check_dl check check_pthread +check check_rtsched check check_ncurses check check_iconv diff --git a/player.c b/player.c index b13f337..4e0c046 100644 --- a/player.c +++ b/player.c @@ -868,7 +868,7 @@ static void *producer_loop(void *arg) void player_init(const struct player_callbacks *callbacks) { int rc; -#if defined(__linux__) || defined(__FreeBSD__) +#ifdef REALTIME_SCHEDULING pthread_attr_t attr; #endif pthread_attr_t *attrp = NULL; @@ -881,7 +881,7 @@ void player_init(const struct player_callbacks *callbacks) player_cbs = callbacks; -#if defined(__linux__) || defined(__FreeBSD__) +#ifdef REALTIME_SCHEDULING rc = pthread_attr_init(&attr); BUG_ON(rc); rc = pthread_attr_setschedpolicy(&attr, SCHED_RR); -- 2.11.4.GIT