[Git][NTPsec/ntpsec][master] Use pthreads API to set SCHED_IDLE scheduling policy

James Browning gitlab at mg.gitlab.com
Mon Aug 24 17:05:28 UTC 2020



James Browning pushed to branch master at NTPsec / ntpsec


Commits:
46af561a by William Cody Ardoin at 2020-08-24T17:05:17+00:00
Use pthreads API to set SCHED_IDLE scheduling policy

Previously we were using the GLIBC sched_setscheduler() function.
This is Linux-only.  We now use the pthread_setschedparam() function
from pthreads, which is portable beyond Linux and works with
musl libc as well as GLIBC.

While the documentation for sched_setscheduler() claims that it affects
the whole process, in fact it only affects the calling thread - see
https://www.openwall.com/lists/musl/2016/03/01/5 for details

- - - - -


1 changed file:

- ntpd/ntpd.c


Changes:

=====================================
ntpd/ntpd.c
=====================================
@@ -450,8 +450,8 @@ set_process_priority(void)
 			else
 				sched.sched_priority = config_priority;
 		}
-		if ( sched_setscheduler(0, SCHED_FIFO, &sched) == -1 )
-			msyslog(LOG_ERR, "INIT: sched_setscheduler(): %s", strerror(errno));
+		if ( pthread_setschedparam(pthread_self(), SCHED_FIFO, &sched) != 0 )
+			msyslog(LOG_ERR, "INIT: pthread_setschedparam(): %s", strerror(errno));
 		else
 			need_priority = false;
 	}



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/46af561a8cfc1b58d3cbfb0cb34c570f8d5f2820

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/46af561a8cfc1b58d3cbfb0cb34c570f8d5f2820
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20200824/5c46ceaa/attachment.htm>


More information about the vc mailing list