core: don't use pthread functions

Don't use pthread_{set,get}schedparam, which requires -lpthread. Use
sched_setscheduler/sched_getparam instead, which is provided by libc.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2023-06-24 02:59:04 +01:00
parent 9295f7e4c7
commit e0c14f63c6
No known key found for this signature in database
GPG Key ID: D3A4405BE6CC17F4
1 changed files with 3 additions and 3 deletions

View File

@ -16,6 +16,7 @@
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <sched.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
@ -2579,18 +2580,17 @@ err:
void set_rr_scheduling(void) {
int priority = sched_get_priority_min(SCHED_RR);
int old_policy;
int ret;
struct sched_param param;
ret = pthread_getschedparam(pthread_self(), &old_policy, &param);
ret = sched_getparam(0, &param);
if (ret != 0) {
log_debug("Failed to get old scheduling priority");
return;
}
param.sched_priority = priority;
ret = pthread_setschedparam(pthread_self(), SCHED_RR, &param);
ret = sched_setscheduler(0, SCHED_RR, &param);
if (ret != 0) {
log_info("Failed to set real-time scheduling priority to %d. Consider "
"giving picom the CAP_SYS_NICE capability",