utils: Fix gaining realtime scheduling with musl

sched_setscheduler() is implemented as a stub in musl that does
nothing because Linux provides no way to set scheduling parameters
per process.

Use pthread_setschedparam() to change the scheduling parameters of
the threads instead.

BUG: 487996
This commit is contained in:
Vlad Zahorodnii 2024-07-16 15:20:57 +03:00
parent de9eb16527
commit 5921be95d3

View file

@ -8,6 +8,7 @@
#include "config-kwin.h"
#include <pthread.h>
#include <sched.h>
namespace KWin
@ -19,7 +20,7 @@ void gainRealTime()
const int minPriority = sched_get_priority_min(SCHED_RR);
sched_param sp;
sp.sched_priority = minPriority;
sched_setscheduler(0, SCHED_RR | SCHED_RESET_ON_FORK, &sp);
pthread_setschedparam(pthread_self(), SCHED_RR | SCHED_RESET_ON_FORK, &sp);
#endif
}