1
0
mirror of https://github.com/RPCS3/rpcs3 synced 2024-07-03 08:08:42 +00:00
This commit is contained in:
hoholee12 2024-06-28 17:20:58 +03:00 committed by GitHub
commit a27667f234
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -49,6 +49,8 @@ DYNAMIC_IMPORT_RENAME("Kernel32.dll", SetThreadDescriptionImport, "SetThreadDesc
#include <sys/syscall.h>
#include <sys/timerfd.h>
#include <unistd.h>
#include <sys/syscall.h>
#define gettid() syscall(SYS_gettid)
#endif
#if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
@ -3027,6 +3029,24 @@ void thread_ctrl::set_native_priority(int priority)
{
sig_log.error("SetThreadPriority() failed: %s", fmt::win_error{GetLastError(), nullptr});
}
#elif defined(__linux__)
// available niceness for root: -20~19
id_t threadpid = gettid();
uid_t euid = geteuid();
if (euid == 0)
{
int linuxprio = 0;
if (priority > 0)
linuxprio = -6;
else if (priority < 0)
linuxprio = 6;
if (int err = setpriority(PRIO_PROCESS, threadpid, linuxprio))
{
sig_log.error("setpriority(%d, %d) failed: %d", threadpid, linuxprio, err);
}
}
#else
int policy;
struct sched_param param;