From 0cf6c6c7db0b22b01aebf8e83878b0bac9066eb6 Mon Sep 17 00:00:00 2001 From: Steven Dake Date: Sun, 21 Jun 2009 16:33:25 +0000 Subject: [PATCH] Add tests for posix scheduling apis to configure.ac and use them to determine if we should set scheduling priorities or not. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2277 fd59a12c-fef9-0310-b244-a6a79926bd2f --- configure.ac | 3 ++- exec/coroipcs.c | 2 ++ exec/logsys.c | 2 ++ exec/main.c | 5 +++-- exec/timer.c | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 8c7b8fc9..2d08e63f 100644 --- a/configure.ac +++ b/configure.ac @@ -104,7 +104,8 @@ AC_CHECK_FUNCS([alarm alphasort atexit bzero dup2 endgrent endpwent fcntl \ getcwd getpeerucred getpeereid gettimeofday inet_ntoa memmove \ memset mkdir scandir select socket strcasecmp strchr strdup \ strerror strrchr strspn strstr pthread_spin_lock \ - pthread_spin_unlock]) + pthread_spin_unlock pthread_setschedparam \ + sched_get_priority_max]) # add man and init dirs? AC_CONFIG_FILES([Makefile diff --git a/exec/coroipcs.c b/exec/coroipcs.c index f20b4f61..96c43dc5 100644 --- a/exec/coroipcs.c +++ b/exec/coroipcs.c @@ -528,10 +528,12 @@ static void *pthread_ipc_consumer (void *conn) int send_ok; unsigned int new_message; +#if defined(HAVE_PTHREAD_SETSCHEDPARAM) && defined(HAVE_SCHED_GET_PRIORITY_MAX) if (api->sched_policy != 0) { res = pthread_setschedparam (conn_info->thread, api->sched_policy, api->sched_param); } +#endif for (;;) { sop.sem_num = 0; diff --git a/exec/logsys.c b/exec/logsys.c index 2c529fcf..faa1bd2c 100644 --- a/exec/logsys.c +++ b/exec/logsys.c @@ -1609,9 +1609,11 @@ int logsys_thread_priority_set ( { int res = 0; +#if defined(HAVE_PTHREAD_SETSCHEDPARAM) && defined(HAVE_SCHED_GET_PRIORITY_MAX) if (policy != SCHED_OTHER) { res = pthread_setschedparam (logsys_thread_id, policy, param); } +#endif if (after_log_ops_yield > 0) { logsys_after_log_ops_yield = after_log_ops_yield; } diff --git a/exec/main.c b/exec/main.c index 500f7c11..6a1ed8d9 100644 --- a/exec/main.c +++ b/exec/main.c @@ -326,7 +326,7 @@ static void corosync_tty_detach (void) static void corosync_setscheduler (void) { -#if ! defined(TS_CLASS) && (defined(COROSYNC_BSD) || defined(COROSYNC_LINUX) || defined(COROSYNC_SOLARIS)) +#if defined(HAVE_PTHREAD_SETSCHEDPARAM) && defined(HAVE_SCHED_GET_PRIORITY_MAX) int res; sched_priority = sched_get_priority_max (SCHED_RR); @@ -342,7 +342,8 @@ static void corosync_setscheduler (void) sched_priority = 0; } #else - log_printf(LOGSYS_LEVEL_WARNING, "Scheduler priority left to default value (no OS support)\n"); + log_printf(LOGSYS_LEVEL_WARNING, + "The Platform is missing process priority setting features. Leaving at default."); #endif } diff --git a/exec/timer.c b/exec/timer.c index 3c47019e..69f9a955 100644 --- a/exec/timer.c +++ b/exec/timer.c @@ -107,7 +107,7 @@ static void *prioritized_timer_thread (void *data) int fds; unsigned long long timeout; -#if ! defined(TS_CLASS) && (defined(COROSYNC_BSD) || defined(COROSYNC_LINUX) || defined(COROSYNC_SOLARIS)) +#if defined(HAVE_PTHREAD_SETSCHEDPARAM) && defined(HAVE_SCHED_GET_PRIORITY_MAX) if (sched_priority != 0) { struct sched_param sched_param;