summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2021-11-27 20:31:46 +0100
committerFernando Sahmkow <fsahmkow27@gmail.com>2022-06-28 01:10:55 +0200
commita2d29412cbda3e0dc57c49c5d4c098e8ba73cbb5 (patch)
treebebb8e6b2842cf6789a287507966362a01979694 /src
parentCore: Reimplement Core Timing. (diff)
downloadyuzu-a2d29412cbda3e0dc57c49c5d4c098e8ba73cbb5.tar
yuzu-a2d29412cbda3e0dc57c49c5d4c098e8ba73cbb5.tar.gz
yuzu-a2d29412cbda3e0dc57c49c5d4c098e8ba73cbb5.tar.bz2
yuzu-a2d29412cbda3e0dc57c49c5d4c098e8ba73cbb5.tar.lz
yuzu-a2d29412cbda3e0dc57c49c5d4c098e8ba73cbb5.tar.xz
yuzu-a2d29412cbda3e0dc57c49c5d4c098e8ba73cbb5.tar.zst
yuzu-a2d29412cbda3e0dc57c49c5d4c098e8ba73cbb5.zip
Diffstat (limited to 'src')
-rw-r--r--src/common/thread.cpp13
-rw-r--r--src/common/thread.h1
-rw-r--r--src/core/core_timing.cpp2
3 files changed, 11 insertions, 5 deletions
diff --git a/src/common/thread.cpp b/src/common/thread.cpp
index f932a7290..924f0df1b 100644
--- a/src/common/thread.cpp
+++ b/src/common/thread.cpp
@@ -47,6 +47,9 @@ void SetCurrentThreadPriority(ThreadPriority new_priority) {
case ThreadPriority::VeryHigh:
windows_priority = THREAD_PRIORITY_HIGHEST;
break;
+ case ThreadPriority::Critical:
+ windows_priority = THREAD_PRIORITY_TIME_CRITICAL;
+ break;
default:
windows_priority = THREAD_PRIORITY_NORMAL;
break;
@@ -59,9 +62,11 @@ void SetCurrentThreadPriority(ThreadPriority new_priority) {
void SetCurrentThreadPriority(ThreadPriority new_priority) {
pthread_t this_thread = pthread_self();
- s32 max_prio = sched_get_priority_max(SCHED_OTHER);
- s32 min_prio = sched_get_priority_min(SCHED_OTHER);
- u32 level = static_cast<u32>(new_priority) + 1;
+ const auto scheduling_type =
+ new_priority != ThreadPriority::Critical ? SCHED_OTHER : SCHED_FIFO;
+ s32 max_prio = sched_get_priority_max(scheduling_type);
+ s32 min_prio = sched_get_priority_min(scheduling_type);
+ u32 level = std::max(static_cast<u32>(new_priority) + 1, 4U);
struct sched_param params;
if (max_prio > min_prio) {
@@ -70,7 +75,7 @@ void SetCurrentThreadPriority(ThreadPriority new_priority) {
params.sched_priority = min_prio - ((min_prio - max_prio) * level) / 4;
}
- pthread_setschedparam(this_thread, SCHED_OTHER, &params);
+ pthread_setschedparam(this_thread, scheduling_type, &params);
}
#endif
diff --git a/src/common/thread.h b/src/common/thread.h
index a63122516..1552f58e0 100644
--- a/src/common/thread.h
+++ b/src/common/thread.h
@@ -92,6 +92,7 @@ enum class ThreadPriority : u32 {
Normal = 1,
High = 2,
VeryHigh = 3,
+ Critical = 4,
};
void SetCurrentThreadPriority(ThreadPriority new_priority);
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index 918502929..b6c295ada 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -46,7 +46,7 @@ void CoreTiming::ThreadEntry(CoreTiming& instance) {
constexpr char name[] = "yuzu:HostTiming";
MicroProfileOnThreadCreate(name);
Common::SetCurrentThreadName(name);
- Common::SetCurrentThreadPriority(Common::ThreadPriority::VeryHigh);
+ Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical);
instance.on_thread_init();
instance.ThreadLoop();
MicroProfileOnThreadExit();