Skip to content

Commit

Permalink
core: use pthread_setschedparam across the board
Browse files Browse the repository at this point in the history
I think I was trying to avoid introducing pthread as a dependency, but
now we are using pthread for SGI_video_sync thread anyway. Let's remove
the ifdefs.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
  • Loading branch information
yshui committed Feb 10, 2024
1 parent 709f016 commit dff77aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
8 changes: 2 additions & 6 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ required_xcb_packages = [
# Some XCB packages are here because their versioning differs (see check below).
required_packages = [
'pixman-1', 'x11', 'x11-xcb', 'xcb-image', 'xcb-renderutil', 'xcb-util',
'xext'
'xext', 'threads',
]

foreach i : required_packages
Expand Down Expand Up @@ -59,7 +59,7 @@ endif

if get_option('opengl')
cflags += ['-DCONFIG_OPENGL', '-DGL_GLEXT_PROTOTYPES']
deps += [dependency('gl', required: true), dependency('egl', required: true), dependency('threads', required:true)]
deps += [dependency('gl', required: true), dependency('egl', required: true)]
srcs += [ 'opengl.c' ]
endif

Expand All @@ -86,10 +86,6 @@ elif (host_system == 'freebsd' or host_system == 'netbsd' or
cflags += ['-DHAS_KQUEUE']
endif

if host_system == 'openbsd'
deps += [dependency('threads', required: true)]
endif

subdir('backend')

picom = executable('picom', srcs, c_args: cflags,
Expand Down
16 changes: 2 additions & 14 deletions src/picom.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <fcntl.h>
#include <inttypes.h>
#include <math.h>
#include <pthread.h>
#include <sched.h>
#include <stddef.h>
#include <stdio.h>
Expand All @@ -35,9 +36,6 @@
#include <xcb/render.h>
#include <xcb/sync.h>
#include <xcb/xfixes.h>
#ifdef __OpenBSD__
#include <pthread.h>
#endif

#include <ev.h>
#include <test.h>
Expand Down Expand Up @@ -2590,34 +2588,24 @@ void set_rr_scheduling(void) {

int ret;
struct sched_param param;

#ifndef __OpenBSD__
ret = sched_getparam(0, &param);
#else
int old_policy;
ret = pthread_getschedparam(pthread_self(), &old_policy, &param);
#endif

if (ret != 0) {
log_debug("Failed to get old scheduling priority");
return;
}

param.sched_priority = priority;

#ifndef __OpenBSD__
ret = sched_setscheduler(0, SCHED_RR, &param);
#else
ret = pthread_setschedparam(pthread_self(), SCHED_RR, &param);
#endif

if (ret != 0) {
log_info("Failed to set real-time scheduling priority to %d. Consider "
"giving picom the CAP_SYS_NICE capability or equivalent "
"support.",
priority);
return;
}

log_info("Set real-time scheduling priority to %d", priority);
}

Expand Down

0 comments on commit dff77aa

Please sign in to comment.