mirror of https://github.com/yshui/picom.git
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:
parent
9295f7e4c7
commit
e0c14f63c6
|
@ -16,6 +16,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <sched.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -2579,18 +2580,17 @@ err:
|
||||||
void set_rr_scheduling(void) {
|
void set_rr_scheduling(void) {
|
||||||
int priority = sched_get_priority_min(SCHED_RR);
|
int priority = sched_get_priority_min(SCHED_RR);
|
||||||
|
|
||||||
int old_policy;
|
|
||||||
int ret;
|
int ret;
|
||||||
struct sched_param param;
|
struct sched_param param;
|
||||||
|
|
||||||
ret = pthread_getschedparam(pthread_self(), &old_policy, ¶m);
|
ret = sched_getparam(0, ¶m);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
log_debug("Failed to get old scheduling priority");
|
log_debug("Failed to get old scheduling priority");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
param.sched_priority = priority;
|
param.sched_priority = priority;
|
||||||
ret = pthread_setschedparam(pthread_self(), SCHED_RR, ¶m);
|
ret = sched_setscheduler(0, SCHED_RR, ¶m);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
log_info("Failed to set real-time scheduling priority to %d. Consider "
|
log_info("Failed to set real-time scheduling priority to %d. Consider "
|
||||||
"giving picom the CAP_SYS_NICE capability",
|
"giving picom the CAP_SYS_NICE capability",
|
||||||
|
|
Loading…
Reference in New Issue