From c309099e79a23ef02ee7d24d0d214d5b0a269efe Mon Sep 17 00:00:00 2001 From: Themaister Date: Tue, 18 Sep 2012 21:51:50 +0200 Subject: [PATCH] Attempt to use SCHED_FIFO in KMS. This is mostly for testing purposes, to see how much scheduling affects performance. --- gfx/context/drm_egl_ctx.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gfx/context/drm_egl_ctx.c b/gfx/context/drm_egl_ctx.c index 07e160f5f1..fbf5289ea9 100644 --- a/gfx/context/drm_egl_ctx.c +++ b/gfx/context/drm_egl_ctx.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -236,6 +238,37 @@ void gfx_ctx_get_video_size(unsigned *width, unsigned *height) *height = g_fb_height; } +static void reschedule_process(void) +{ + struct sched_param param = {0}; + + // All-out real-time. Why not? :D + param.sched_priority = sched_get_priority_max(SCHED_FIFO); + if (sched_setscheduler(0, SCHED_FIFO, ¶m) < 0) + RARCH_ERR("[KMS/EGL]: Failed to set SCHED_FIFO priority.\n"); + + int sched = sched_getscheduler(getpid()); + + const char *scheduler; + switch (sched) + { + case SCHED_OTHER: + scheduler = "SCHED_OTHER"; + break; + + case SCHED_FIFO: + scheduler = "SCHED_FIFO"; + break; + + default: + scheduler = "Unrelated"; + } + + RARCH_LOG("[KMS/EGL]: Current scheduler: %s\n", scheduler); + if (sched == SCHED_FIFO) + RARCH_LOG("[KMS/EGL]: SCHED_FIFO prio: %d\n", param.sched_priority); +} + bool gfx_ctx_init(void) { if (g_inited) @@ -244,6 +277,8 @@ bool gfx_ctx_init(void) return false; } + reschedule_process(); + static const char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx", "omapdrm", "exynos", NULL };