From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Thu, 2 May 2024 15:13:56 +0000 (+0100) Subject: Set a FIFO scheduling policy and a priority of -6 so tat the timinig accuracy stays... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b59628b2dcdc87b1a5a1175ea1e80501b3b01a1b;p=thirdparty%2Fnqptp.git Set a FIFO scheduling policy and a priority of -6 so tat the timinig accuracy stays high under load. --- diff --git a/nqptp.c b/nqptp.c index 73b0d66..34a72da 100644 --- a/nqptp.c +++ b/nqptp.c @@ -185,7 +185,16 @@ int main(int argc, char **argv) { // debug(1, "size of a clock entry is %u bytes.", sizeof(clock_source_private_data)); atexit(goodbye); - + + + // try to set a real time scheduling policy with a priority of -6 + int policy = SCHED_FIFO; + struct sched_param param; + param.sched_priority = 5; + int s = pthread_setschedparam(pthread_self(), policy, ¶m); + if (s != 0) + debug(1, "pthread_setschedparam failed: %d -- \"%s\".", s, strerror(s)); + sockets_open_stuff.sockets_open = 0; // open PTP sockets diff --git a/nqptp.service.in b/nqptp.service.in index 56891d7..34e59f9 100644 --- a/nqptp.service.in +++ b/nqptp.service.in @@ -7,6 +7,7 @@ Before=shairport-sync.service [Service] ExecStart=@prefix@/bin/nqptp DynamicUser=yes +LimitRTPRIO=6 AmbientCapabilities=CAP_NET_BIND_SERVICE [Install]