Skip to content

Commit

Permalink
core: don't use pthread functions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
yshui committed Jun 24, 2023
1 parent 9295f7e commit e0c14f6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/picom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -2579,18 +2580,17 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
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",
Expand Down

0 comments on commit e0c14f6

Please sign in to comment.