Просмотр исходного кода

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

Steven Dake 16 лет назад
Родитель
Сommit
0cf6c6c7db
5 измененных файлов с 10 добавлено и 4 удалено
  1. 2 1
      configure.ac
  2. 2 0
      exec/coroipcs.c
  3. 2 0
      exec/logsys.c
  4. 3 2
      exec/main.c
  5. 1 1
      exec/timer.c

+ 2 - 1
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

+ 2 - 0
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;

+ 2 - 0
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;
 	}

+ 3 - 2
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
 }
 

+ 1 - 1
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;