[chrony-dev] [PATCH] doc: fix chronyd platform support for -P and -m

2021-08-07 Thread Stefan R. Filipek
A while back, support for memory locking and real-time scheduling was
added to more platforms. The chronyd documentation wasn't updated at
that time (chronyd.conf was). This patch fixes that.

---
 doc/chronyd.adoc | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/doc/chronyd.adoc b/doc/chronyd.adoc
index d3b78a4..8f2051e 100644
--- a/doc/chronyd.adoc
+++ b/doc/chronyd.adoc
@@ -146,15 +146,15 @@ system calls. If the filter is missing some system call, 
*chronyd* could be
 killed even in normal operation.
 
 *-P* _priority_::
-On Linux, this option will select the SCHED_FIFO real-time scheduler at the
-specified priority (which must be between 0 and 100). On macOS, this option
-must have either a value of 0 (the default) to disable the thread time
-constraint policy or 1 for the policy to be enabled. Other systems do not
-support this option.
+On Linux, FreeBSD, NetBSD, and Solaris, this option will select the SCHED_FIFO
+real-time scheduler at the specified priority (which must be between 0 and
+100). On macOS, this option must have either a value of 0 (the default) to
+disable the thread time constraint policy or 1 for the policy to be enabled.
+Other systems do not support this option.
 
 *-m*::
 This option will lock *chronyd* into RAM so that it will never be paged out.
-This mode is only supported on Linux.
+This mode is only supported on Linux, FreeBSD, NetBSD, and Solaris.
 
 *-x*::
 This option disables the control of the system clock. *chronyd* will not try to
-- 
2.32.0


-- 
To unsubscribe email chrony-dev-requ...@chrony.tuxfamily.org with "unsubscribe" 
in the subject.
For help email chrony-dev-requ...@chrony.tuxfamily.org with "help" in the 
subject.
Trouble?  Email listmas...@chrony.tuxfamily.org.



[chrony-dev] [PATCH v2] sys_posix: support SCHED_FIFO and mlockall on more OSs

2019-04-19 Thread Stefan R. Filipek
Real-time scheduling and memory locking is available on posix compliant
OSs. This patch centralizes this functionality and brings support to
FreeBSD, NetBSD, and Solaris.
---
 configure|  27 ---
 doc/chrony.conf.adoc |  46 +-
 sys.c|  13 +++--
 sys_linux.c  |  67 --
 sys_linux.h  |   4 --
 sys_posix.c  | 111 +++
 sys_posix.h  |  36 ++
 7 files changed, 198 insertions(+), 106 deletions(-)
 create mode 100644 sys_posix.c
 create mode 100644 sys_posix.h

diff --git a/configure b/configure
index c434127..9e21a8b 100755
--- a/configure
+++ b/configure
@@ -396,7 +396,7 @@ SYSTEM=${OPERATINGSYSTEM}-${MACHINE}
 
 case $OPERATINGSYSTEM in
 Linux)
-EXTRA_OBJECTS="sys_generic.o sys_linux.o sys_timex.o"
+EXTRA_OBJECTS="sys_generic.o sys_linux.o sys_timex.o sys_posix.o"
 [ $try_libcap != "0" ] && try_libcap=1
 try_rtc=1
 [ $try_seccomp != "0" ] && try_seccomp=1
@@ -411,7 +411,9 @@ case $OPERATINGSYSTEM in
 # recvmmsg() seems to be broken on FreeBSD 11.0 and it's just
 # a wrapper around recvmsg()
 try_recvmmsg=0
-EXTRA_OBJECTS="sys_generic.o sys_netbsd.o sys_timex.o"
+EXTRA_OBJECTS="sys_generic.o sys_netbsd.o sys_timex.o sys_posix.o"
+try_setsched=1
+try_lockmem=1
 add_def FREEBSD
 if [ $feat_droproot = "1" ]; then
   add_def FEAT_PRIVDROP
@@ -420,8 +422,10 @@ case $OPERATINGSYSTEM in
 echo "Configuring for $SYSTEM"
 ;;
 NetBSD)
-EXTRA_OBJECTS="sys_generic.o sys_netbsd.o sys_timex.o"
+EXTRA_OBJECTS="sys_generic.o sys_netbsd.o sys_timex.o sys_posix.o"
 try_clockctl=1
+try_setsched=1
+try_lockmem=1
 add_def NETBSD
 echo "Configuring for $SYSTEM"
 ;;
@@ -446,9 +450,11 @@ case $OPERATINGSYSTEM in
 echo "Configuring for macOS (" $SYSTEM "macOS version" $VERSION ")"
 ;;
 SunOS)
-EXTRA_OBJECTS="sys_generic.o sys_solaris.o sys_timex.o"
+EXTRA_OBJECTS="sys_generic.o sys_solaris.o sys_timex.o sys_posix.o"
 EXTRA_LIBS="-lsocket -lnsl -lresolv"
 EXTRA_CLI_LIBS="-lsocket -lnsl -lresolv"
+try_setsched=1
+try_lockmem=1
 add_def SOLARIS
 # These are needed to have msg_control in struct msghdr
 add_def __EXTENSIONS__
@@ -800,13 +806,20 @@ fi
 if [ $try_lockmem = "1" ] && \
   test_code \
 'mlockall()' \
-'sys/mman.h sys/resource.h' '' '' '
- struct rlimit rlim;
- setrlimit(RLIMIT_MEMLOCK, );
+'sys/mman.h' '' '' '
  mlockall(MCL_CURRENT|MCL_FUTURE);'
 then
   add_def HAVE_MLOCKALL
 fi
+if [ $try_lockmem = "1" ] && \
+  test_code \
+'setrlimit(RLIMIT_MEMLOCK, ...)' \
+'sys/resource.h' '' '' '
+ struct rlimit rlim;
+ setrlimit(RLIMIT_MEMLOCK, );'
+then
+  add_def HAVE_SETRLIMIT_MEMLOCK
+fi
 
 if [ $feat_forcednsretry = "1" ]
 then
diff --git a/doc/chrony.conf.adoc b/doc/chrony.conf.adoc
index 7aa2116..aa5cafe 100644
--- a/doc/chrony.conf.adoc
+++ b/doc/chrony.conf.adoc
@@ -2063,11 +2063,11 @@ file when the <> command is 
issued by *chronyc*).
 
 [[lock_all]]*lock_all*::
 The *lock_all* directive will lock chronyd into RAM so that it will never be
-paged out. This mode is only supported on Linux. This directive uses the Linux
-*mlockall()* system call to prevent *chronyd* from ever being swapped out. This
-should result in lower and more consistent latency. It should not have
-significant impact on performance as *chronyd's* memory usage is modest. The
-*mlockall(2)* man page has more details.
+paged out. This mode is supported on Linux, FreeBSD, NetBSD, and Solaris.  This
+directive uses the POSIX *mlockall()* system call to prevent *chronyd* from
+ever being swapped out. This should result in lower and more consistent
+latency. It should not have significant impact on performance as *chronyd's*
+memory usage is modest. The *mlockall(2)* man page has more details.
 
 [[pidfile]]*pidfile* _file_::
 Unless *chronyd* is started with the *-Q* option, it writes its process ID
@@ -2081,26 +2081,26 @@ pidfile /run/chronyd.pid
 
 
 [[sched_priority]]*sched_priority* _priority_::
-On Linux, the *sched_priority* directive will select the SCHED_FIFO real-time
-scheduler at the specified priority (which must be between 0 and 100). On
-macOS, this option must have either a value of 0 (the default) to disable the
-thread time constraint policy or 1 for the policy to be enabled. Other systems
-do not support this option.
-+
-On Linux, this directive uses the *sched_setscheduler()* system call to
-instruct the kernel to use the SCHED_FIFO first-in, first-out real-time
-scheduling policy for *chronyd* with the specified priority. This means that
-whenever *chronyd* is ready to run it will run, interrupting whatever else is
-running unless it is a higher priority real-time 

Re: [chrony-dev] [PATCH] sys_posix: support SCHED_FIFO and mlockall on more OSs

2019-04-16 Thread Stefan R. Filipek
Thanks for the feedback.

> Could that not lead into situations where chronyd randomly fails later after 
> start when it needs to allocate more memory?

With MCL_FUTURE specified, yes it could fail. The thought was to just
abide by the previously set system limits (assuming that is why it
failed), but that would cause more problems than its worth. I'll
revert the behavior.

With Solaris, since it does not have this artificial limit, we should
be safe to use mlockall by itself (according to my understanding of
the docs).

>> +add_def POSIX
> I don't like this definition very much.

I didn't either, but I wasn't sure what the preferred style would be.
I'll change the conditional calls to check for supported platforms
individually.

> it's a good opportunity to update the coding style to match the majority of 
> the code

I'll do what I can, but please fill in the gaps on the final patch.

> As for sending the patches, have you tried git send-email? That should avoid 
> problems with formatting.

Maybe one day I'll learn how to copy and paste patches out of a
terminal and into gmail. In the mean time, I'll try your suggestion.

Regards,
Stefan

-- 
To unsubscribe email chrony-dev-requ...@chrony.tuxfamily.org with "unsubscribe" 
in the subject.
For help email chrony-dev-requ...@chrony.tuxfamily.org with "help" in the 
subject.
Trouble?  Email listmas...@chrony.tuxfamily.org.



Re: [chrony-dev] [PATCH] Use pthread_setschedparam instead of sched_setscheduler

2019-04-08 Thread Stefan R. Filipek
The extra line wrapping caused the issue.

Updated patch attached with an expanded commit message.

Regards,
Stefan
From d49ca2c7984bc43c2a71bccb382e445844b4acf3 Mon Sep 17 00:00:00 2001
From: "Stefan R. Filipek" 
Date: Thu, 4 Apr 2019 19:12:39 -0400
Subject: [PATCH] sys_linux: use pthread_setschedparam instead of
 sched_setscheduler

Fix an issue with Linux and musl libc where sched_setscheduler is not
implemented. It seems that pthread_setschedparam is more widely
supported across different C libraries and OSs. For our use case, it
should make no difference which call is used.
---
 configure   | 16 +++-
 sys.c   |  2 +-
 sys_linux.c | 11 ++-
 3 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index 486b0bc..c434127 100755
--- a/configure
+++ b/configure
@@ -227,6 +227,7 @@ feat_timestamping=1
 try_timestamping=0
 feat_ntp_signd=0
 ntp_era_split=""
+use_pthread=0
 default_user="root"
 default_hwclockfile=""
 default_pidfile="/var/run/chrony/chronyd.pid"
@@ -652,7 +653,7 @@ then
   add_def FEAT_ASYNCDNS
   add_def USE_PTHREAD_ASYNCDNS
   EXTRA_OBJECTS="$EXTRA_OBJECTS nameserv_async.o"
-  MYCFLAGS="$MYCFLAGS -pthread"
+  use_pthread=1
 fi
 
 if test_code 'arc4random_buf()' 'stdlib.h' '' '' 'arc4random_buf(NULL, 0);'; 
then
@@ -786,13 +787,14 @@ fi
 
 if [ $try_setsched = "1" ] && \
   test_code \
-'sched_setscheduler()' \
-'sched.h' '' '' '
+'pthread_setschedparam()' \
+'pthread.h sched.h' '-pthread' '' '
  struct sched_param sched;
  sched_get_priority_max(SCHED_FIFO);
- sched_setscheduler(0, SCHED_FIFO, );'
+ pthread_setschedparam(pthread_self(), SCHED_FIFO, );'
 then
-  add_def HAVE_SCHED_SETSCHEDULER
+  add_def HAVE_PTHREAD_SETSCHEDPARAM
+  use_pthread=1
 fi
 
 if [ $try_lockmem = "1" ] && \
@@ -896,6 +898,10 @@ if [ $feat_sechash = "1" ] && [ "x$HASH_LINK" = "x" ] && [ 
$try_tomcrypt = "1" ]
   fi
 fi
 
+if [ $use_pthread = "1" ]; then
+  MYCFLAGS="$MYCFLAGS -pthread"
+fi
+
 SYSCONFDIR=/etc
 if [ "x$SETSYSCONFDIR" != "x" ]; then
   SYSCONFDIR=$SETSYSCONFDIR
diff --git a/sys.c b/sys.c
index 4d68b37..2c42db1 100644
--- a/sys.c
+++ b/sys.c
@@ -124,7 +124,7 @@ void SYS_EnableSystemCallFilter(int level)
 
 void SYS_SetScheduler(int SchedPriority)
 {
-#if defined(LINUX) && defined(HAVE_SCHED_SETSCHEDULER)
+#if defined(LINUX) && defined(HAVE_PTHREAD_SETSCHEDPARAM)
   SYS_Linux_SetScheduler(SchedPriority);
 #elif defined(MACOSX)
   SYS_MacOSX_SetScheduler(SchedPriority);
diff --git a/sys_linux.c b/sys_linux.c
index 6ae7c0d..9e4ab3f 100644
--- a/sys_linux.c
+++ b/sys_linux.c
@@ -33,7 +33,8 @@
 
 #include 
 
-#if defined(HAVE_SCHED_SETSCHEDULER)
+#if defined(HAVE_PTHREAD_SETSCHEDPARAM)
+#  include 
 #  include 
 #endif
 
@@ -632,7 +633,7 @@ add_failed:
 
 /* == */
 
-#if defined(HAVE_SCHED_SETSCHEDULER)
+#if defined(HAVE_PTHREAD_SETSCHEDPARAM)
   /* Install SCHED_FIFO real-time scheduler with specified priority */
 void SYS_Linux_SetScheduler(int SchedPriority)
 {
@@ -651,8 +652,8 @@ void SYS_Linux_SetScheduler(int SchedPriority)
 else if ( SchedPriority < pmin ) {
   sched.sched_priority = pmin;
 }
-if ( sched_setscheduler(0, SCHED_FIFO, ) == -1 ) {
-  LOG(LOGS_ERR, "sched_setscheduler() failed");
+if ( pthread_setschedparam(pthread_self(), SCHED_FIFO, ) == -1 ) {
+  LOG(LOGS_ERR, "pthread_setschedparam() failed");
 }
 else {
   DEBUG_LOG("Enabled SCHED_FIFO with priority %d",
@@ -660,7 +661,7 @@ void SYS_Linux_SetScheduler(int SchedPriority)
 }
   }
 }
-#endif /* HAVE_SCHED_SETSCHEDULER */
+#endif /* HAVE_PTHREAD_SETSCHEDPARAM  */
 
 #if defined(HAVE_MLOCKALL)
 /* Lock the process into RAM so that it will never be swapped out */ 
-- 
2.21.0



Re: [chrony-dev] [PATCH] Use pthread_setschedparam instead of sched_setscheduler

2019-04-08 Thread Stefan R. Filipek
> sched.h should be pthread.h?

I should actually include both. sched_get_priority_min/max() is still used.

Updated and squashed patch below.

Regards,
Stefan

>From 6ae435f7417a3d0c634183276a7e9e9ed04f2611 Mon Sep 17 00:00:00 2001
From: "Stefan R. Filipek" 
Date: Thu, 4 Apr 2019 19:12:39 -0400
Subject: [PATCH] sys_linux: use pthread_setschedparam instead of
 sched_setscheduler

---
 configure   | 16 +++-
 sys.c   |  2 +-
 sys_linux.c | 11 ++-
 3 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index 486b0bc..c434127 100755
--- a/configure
+++ b/configure
@@ -227,6 +227,7 @@ feat_timestamping=1
 try_timestamping=0
 feat_ntp_signd=0
 ntp_era_split=""
+use_pthread=0
 default_user="root"
 default_hwclockfile=""
 default_pidfile="/var/run/chrony/chronyd.pid"
@@ -652,7 +653,7 @@ then
   add_def FEAT_ASYNCDNS
   add_def USE_PTHREAD_ASYNCDNS
   EXTRA_OBJECTS="$EXTRA_OBJECTS nameserv_async.o"
-  MYCFLAGS="$MYCFLAGS -pthread"
+  use_pthread=1
 fi

 if test_code 'arc4random_buf()' 'stdlib.h' '' ''
'arc4random_buf(NULL, 0);'; then
@@ -786,13 +787,14 @@ fi

 if [ $try_setsched = "1" ] && \
   test_code \
-'sched_setscheduler()' \
-'sched.h' '' '' '
+'pthread_setschedparam()' \
+'pthread.h sched.h' '-pthread' '' '
  struct sched_param sched;
  sched_get_priority_max(SCHED_FIFO);
- sched_setscheduler(0, SCHED_FIFO, );'
+ pthread_setschedparam(pthread_self(), SCHED_FIFO, );'
 then
-  add_def HAVE_SCHED_SETSCHEDULER
+  add_def HAVE_PTHREAD_SETSCHEDPARAM
+  use_pthread=1
 fi

 if [ $try_lockmem = "1" ] && \
@@ -896,6 +898,10 @@ if [ $feat_sechash = "1" ] && [ "x$HASH_LINK" =
"x" ] && [ $try_tomcrypt = "1" ]
   fi
 fi

+if [ $use_pthread = "1" ]; then
+  MYCFLAGS="$MYCFLAGS -pthread"
+fi
+
 SYSCONFDIR=/etc
 if [ "x$SETSYSCONFDIR" != "x" ]; then
   SYSCONFDIR=$SETSYSCONFDIR
diff --git a/sys.c b/sys.c
index 4d68b37..2c42db1 100644
--- a/sys.c
+++ b/sys.c
@@ -124,7 +124,7 @@ void SYS_EnableSystemCallFilter(int level)

 void SYS_SetScheduler(int SchedPriority)
 {
-#if defined(LINUX) && defined(HAVE_SCHED_SETSCHEDULER)
+#if defined(LINUX) && defined(HAVE_PTHREAD_SETSCHEDPARAM)
   SYS_Linux_SetScheduler(SchedPriority);
 #elif defined(MACOSX)
   SYS_MacOSX_SetScheduler(SchedPriority);
diff --git a/sys_linux.c b/sys_linux.c
index 6ae7c0d..9e4ab3f 100644
--- a/sys_linux.c
+++ b/sys_linux.c
@@ -33,7 +33,8 @@

 #include 

-#if defined(HAVE_SCHED_SETSCHEDULER)
+#if defined(HAVE_PTHREAD_SETSCHEDPARAM)
+#  include 
 #  include 
 #endif

@@ -632,7 +633,7 @@ add_failed:

 /* == */

-#if defined(HAVE_SCHED_SETSCHEDULER)
+#if defined(HAVE_PTHREAD_SETSCHEDPARAM)
   /* Install SCHED_FIFO real-time scheduler with specified priority */
 void SYS_Linux_SetScheduler(int SchedPriority)
 {
@@ -651,8 +652,8 @@ void SYS_Linux_SetScheduler(int SchedPriority)
 else if ( SchedPriority < pmin ) {
   sched.sched_priority = pmin;
 }
-if ( sched_setscheduler(0, SCHED_FIFO, ) == -1 ) {
-  LOG(LOGS_ERR, "sched_setscheduler() failed");
+if ( pthread_setschedparam(pthread_self(), SCHED_FIFO, ) == -1 ) {
+  LOG(LOGS_ERR, "pthread_setschedparam() failed");
 }
 else {
   DEBUG_LOG("Enabled SCHED_FIFO with priority %d",
@@ -660,7 +661,7 @@ void SYS_Linux_SetScheduler(int SchedPriority)
 }
   }
 }
-#endif /* HAVE_SCHED_SETSCHEDULER */
+#endif /* HAVE_PTHREAD_SETSCHEDPARAM  */

 #if defined(HAVE_MLOCKALL)
 /* Lock the process into RAM so that it will never be swapped out */
-- 
2.21.0

-- 
To unsubscribe email chrony-dev-requ...@chrony.tuxfamily.org with "unsubscribe" 
in the subject.
For help email chrony-dev-requ...@chrony.tuxfamily.org with "help" in the 
subject.
Trouble?  Email listmas...@chrony.tuxfamily.org.



[chrony-dev] Re: [PATCH] Use pthread_setschedparam instead of sched_setscheduler

2019-04-05 Thread Stefan R. Filipek
Addendum: Incremental patch so we only include '-pthread' once in the
compilation flags.

Regards,
Stefan

diff --git a/configure b/configure
index 565b888..49ba7bc 100755
--- a/configure
+++ b/configure
@@ -227,6 +227,7 @@ feat_timestamping=1
 try_timestamping=0
 feat_ntp_signd=0
 ntp_era_split=""
+use_pthread=0
 default_user="root"
 default_hwclockfile=""
 default_pidfile="/var/run/chrony/chronyd.pid"
@@ -652,7 +653,7 @@ then
   add_def FEAT_ASYNCDNS
   add_def USE_PTHREAD_ASYNCDNS
   EXTRA_OBJECTS="$EXTRA_OBJECTS nameserv_async.o"
-  MYCFLAGS="$MYCFLAGS -pthread"
+  use_pthread=1
 fi

 if test_code 'arc4random_buf()' 'stdlib.h' '' ''
'arc4random_buf(NULL, 0);'; then
@@ -793,7 +794,7 @@ if [ $try_setsched = "1" ] && \
  pthread_setschedparam(pthread_self(), SCHED_FIFO, );'
 then
   add_def HAVE_PTHREAD_SETSCHEDPARAM
-  MYCFLAGS="$MYCFLAGS -pthread"
+  use_pthread=1
 fi

 if [ $try_lockmem = "1" ] && \
@@ -897,6 +898,10 @@ if [ $feat_sechash = "1" ] && [ "x$HASH_LINK" =
"x" ] && [ $try_tomcrypt = "1" ]
   fi
 fi

+if [ $use_pthread = "1" ]; then
+  MYCFLAGS="$MYCFLAGS -pthread"
+fi
+
 SYSCONFDIR=/etc
 if [ "x$SETSYSCONFDIR" != "x" ]; then
   SYSCONFDIR=$SETSYSCONFDIR

-- 
To unsubscribe email chrony-dev-requ...@chrony.tuxfamily.org with "unsubscribe" 
in the subject.
For help email chrony-dev-requ...@chrony.tuxfamily.org with "help" in the 
subject.
Trouble?  Email listmas...@chrony.tuxfamily.org.



[chrony-dev] [PATCH] Use pthread_setschedparam instead of sched_setscheduler

2019-04-04 Thread Stefan R. Filipek
Hi,

I ran into an issue with musl libc on Linux where sched_setscheduler
isn't implemented. Overall, it seems that pthread_setschedparam is
more widely supported across different C libraries and OSs. For
chrony's purposes on Linux, it should make no difference which call is
used.

Below is the simplest diff I could make, but cleaning up the
dependency check for pthreads is probably in order. I could also work
on a more general patch that brings real-time scheduling to any posix
platform.

I tested on Arch x86_64 Linux with glibc and buildroot ARM Linux with musl libc.

Regards,
Stefan


diff --git a/configure b/configure
index 486b0bc..565b888 100755
--- a/configure
+++ b/configure
@@ -786,13 +786,14 @@ fi

 if [ $try_setsched = "1" ] && \
   test_code \
-'sched_setscheduler()' \
+'pthread_setschedparam()' \
 'sched.h' '' '' '
  struct sched_param sched;
  sched_get_priority_max(SCHED_FIFO);
- sched_setscheduler(0, SCHED_FIFO, );'
+ pthread_setschedparam(pthread_self(), SCHED_FIFO, );'
 then
-  add_def HAVE_SCHED_SETSCHEDULER
+  add_def HAVE_PTHREAD_SETSCHEDPARAM
+  MYCFLAGS="$MYCFLAGS -pthread"
 fi

 if [ $try_lockmem = "1" ] && \
diff --git a/sys.c b/sys.c
index 4d68b37..2c42db1 100644
--- a/sys.c
+++ b/sys.c
@@ -124,7 +124,7 @@ void SYS_EnableSystemCallFilter(int level)

 void SYS_SetScheduler(int SchedPriority)
 {
-#if defined(LINUX) && defined(HAVE_SCHED_SETSCHEDULER)
+#if defined(LINUX) && defined(HAVE_PTHREAD_SETSCHEDPARAM)
   SYS_Linux_SetScheduler(SchedPriority);
 #elif defined(MACOSX)
   SYS_MacOSX_SetScheduler(SchedPriority);
diff --git a/sys_linux.c b/sys_linux.c
index 6ae7c0d..c339f09 100644
--- a/sys_linux.c
+++ b/sys_linux.c
@@ -33,8 +33,8 @@

 #include 

-#if defined(HAVE_SCHED_SETSCHEDULER)
-#  include 
+#if defined(HAVE_PTHREAD_SETSCHEDPARAM)
+#  include 
 #endif

 #if defined(HAVE_MLOCKALL)
@@ -632,7 +632,7 @@ add_failed:

 /* == */

-#if defined(HAVE_SCHED_SETSCHEDULER)
+#if defined(HAVE_PTHREAD_SETSCHEDPARAM)
   /* Install SCHED_FIFO real-time scheduler with specified priority */
 void SYS_Linux_SetScheduler(int SchedPriority)
 {
@@ -651,8 +651,8 @@ void SYS_Linux_SetScheduler(int SchedPriority)
 else if ( SchedPriority < pmin ) {
   sched.sched_priority = pmin;
 }
-if ( sched_setscheduler(0, SCHED_FIFO, ) == -1 ) {
-  LOG(LOGS_ERR, "sched_setscheduler() failed");
+if ( pthread_setschedparam(pthread_self(), SCHED_FIFO, ) == -1 ) {
+  LOG(LOGS_ERR, "pthread_setschedparam() failed");
 }
 else {
   DEBUG_LOG("Enabled SCHED_FIFO with priority %d",
@@ -660,7 +660,7 @@ void SYS_Linux_SetScheduler(int SchedPriority)
 }
   }
 }
-#endif /* HAVE_SCHED_SETSCHEDULER */
+#endif /* HAVE_PTHREAD_SETSCHEDPARAM  */

 #if defined(HAVE_MLOCKALL)
 /* Lock the process into RAM so that it will never be swapped out */

-- 
To unsubscribe email chrony-dev-requ...@chrony.tuxfamily.org with "unsubscribe" 
in the subject.
For help email chrony-dev-requ...@chrony.tuxfamily.org with "help" in the 
subject.
Trouble?  Email listmas...@chrony.tuxfamily.org.