Skip to content

Commit

Permalink
utils: make setting/restoring from RT thread work on musl
Browse files Browse the repository at this point in the history
musl no-ops sched_setscheduler, pthread_setschedparam should work everywhere
  • Loading branch information
nekopsykose authored and misyltoad committed Jul 5, 2024
1 parent 7a000eb commit 9860a34
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Utils/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <sys/procctl.h>
#endif

#include <pthread.h>
#include <stdlib.h>
#include <dirent.h>
#include <unistd.h>
Expand Down Expand Up @@ -472,7 +473,7 @@ namespace gamescope::Process
struct sched_param newSched{};
sched_getparam( 0, &newSched );
newSched.sched_priority = sched_get_priority_min( SCHED_RR );
if ( sched_setscheduler( 0, SCHED_RR, &newSched ) )
if ( pthread_setschedparam( pthread_self(), SCHED_RR, &newSched ) )
{
s_ProcessLog.errorf_errno( "Failed to set realtime scheduling." );
return false;
Expand All @@ -491,7 +492,7 @@ namespace gamescope::Process
if ( !g_oOldSchedulerInfo )
return;

if ( sched_setscheduler( 0, g_oOldSchedulerInfo->nPolicy, &g_oOldSchedulerInfo->SchedParam ) )
if ( pthread_setschedparam( pthread_self(), g_oOldSchedulerInfo->nPolicy, &g_oOldSchedulerInfo->SchedParam ) )
{
s_ProcessLog.errorf_errno( "Failed to restore from realtime scheduling." );
return;
Expand All @@ -506,4 +507,4 @@ namespace gamescope::Process
return __progname;
}

}
}

0 comments on commit 9860a34

Please sign in to comment.