diff options
| author | 2021-11-27 20:31:46 +0100 | |
|---|---|---|
| committer | 2022-06-28 01:10:55 +0200 | |
| commit | a2d29412cbda3e0dc57c49c5d4c098e8ba73cbb5 (patch) | |
| tree | bebb8e6b2842cf6789a287507966362a01979694 /src/common/thread.cpp | |
| parent | Core: Reimplement Core Timing. (diff) | |
| download | yuzu-a2d29412cbda3e0dc57c49c5d4c098e8ba73cbb5.tar.gz yuzu-a2d29412cbda3e0dc57c49c5d4c098e8ba73cbb5.tar.xz yuzu-a2d29412cbda3e0dc57c49c5d4c098e8ba73cbb5.zip | |
Core/Common: Corrections to core timing and add critical priority.
Diffstat (limited to 'src/common/thread.cpp')
| -rw-r--r-- | src/common/thread.cpp | 13 |
1 files changed, 9 insertions, 4 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) { | |||
| 47 | case ThreadPriority::VeryHigh: | 47 | case ThreadPriority::VeryHigh: |
| 48 | windows_priority = THREAD_PRIORITY_HIGHEST; | 48 | windows_priority = THREAD_PRIORITY_HIGHEST; |
| 49 | break; | 49 | break; |
| 50 | case ThreadPriority::Critical: | ||
| 51 | windows_priority = THREAD_PRIORITY_TIME_CRITICAL; | ||
| 52 | break; | ||
| 50 | default: | 53 | default: |
| 51 | windows_priority = THREAD_PRIORITY_NORMAL; | 54 | windows_priority = THREAD_PRIORITY_NORMAL; |
| 52 | break; | 55 | break; |
| @@ -59,9 +62,11 @@ void SetCurrentThreadPriority(ThreadPriority new_priority) { | |||
| 59 | void SetCurrentThreadPriority(ThreadPriority new_priority) { | 62 | void SetCurrentThreadPriority(ThreadPriority new_priority) { |
| 60 | pthread_t this_thread = pthread_self(); | 63 | pthread_t this_thread = pthread_self(); |
| 61 | 64 | ||
| 62 | s32 max_prio = sched_get_priority_max(SCHED_OTHER); | 65 | const auto scheduling_type = |
| 63 | s32 min_prio = sched_get_priority_min(SCHED_OTHER); | 66 | new_priority != ThreadPriority::Critical ? SCHED_OTHER : SCHED_FIFO; |
| 64 | u32 level = static_cast<u32>(new_priority) + 1; | 67 | s32 max_prio = sched_get_priority_max(scheduling_type); |
| 68 | s32 min_prio = sched_get_priority_min(scheduling_type); | ||
| 69 | u32 level = std::max(static_cast<u32>(new_priority) + 1, 4U); | ||
| 65 | 70 | ||
| 66 | struct sched_param params; | 71 | struct sched_param params; |
| 67 | if (max_prio > min_prio) { | 72 | if (max_prio > min_prio) { |
| @@ -70,7 +75,7 @@ void SetCurrentThreadPriority(ThreadPriority new_priority) { | |||
| 70 | params.sched_priority = min_prio - ((min_prio - max_prio) * level) / 4; | 75 | params.sched_priority = min_prio - ((min_prio - max_prio) * level) / 4; |
| 71 | } | 76 | } |
| 72 | 77 | ||
| 73 | pthread_setschedparam(this_thread, SCHED_OTHER, ¶ms); | 78 | pthread_setschedparam(this_thread, scheduling_type, ¶ms); |
| 74 | } | 79 | } |
| 75 | 80 | ||
| 76 | #endif | 81 | #endif |