|
|
@ -47,6 +47,9 @@ void SetCurrentThreadPriority(ThreadPriority new_priority) {
|
|
|
|
case ThreadPriority::VeryHigh:
|
|
|
|
case ThreadPriority::VeryHigh:
|
|
|
|
windows_priority = THREAD_PRIORITY_HIGHEST;
|
|
|
|
windows_priority = THREAD_PRIORITY_HIGHEST;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ThreadPriority::Critical:
|
|
|
|
|
|
|
|
windows_priority = THREAD_PRIORITY_TIME_CRITICAL;
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
windows_priority = THREAD_PRIORITY_NORMAL;
|
|
|
|
windows_priority = THREAD_PRIORITY_NORMAL;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -59,9 +62,11 @@ void SetCurrentThreadPriority(ThreadPriority new_priority) {
|
|
|
|
void SetCurrentThreadPriority(ThreadPriority new_priority) {
|
|
|
|
void SetCurrentThreadPriority(ThreadPriority new_priority) {
|
|
|
|
pthread_t this_thread = pthread_self();
|
|
|
|
pthread_t this_thread = pthread_self();
|
|
|
|
|
|
|
|
|
|
|
|
s32 max_prio = sched_get_priority_max(SCHED_OTHER);
|
|
|
|
const auto scheduling_type =
|
|
|
|
s32 min_prio = sched_get_priority_min(SCHED_OTHER);
|
|
|
|
new_priority != ThreadPriority::Critical ? SCHED_OTHER : SCHED_FIFO;
|
|
|
|
u32 level = static_cast<u32>(new_priority) + 1;
|
|
|
|
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;
|
|
|
|
struct sched_param params;
|
|
|
|
if (max_prio > min_prio) {
|
|
|
|
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;
|
|
|
|
params.sched_priority = min_prio - ((min_prio - max_prio) * level) / 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pthread_setschedparam(this_thread, SCHED_OTHER, ¶ms);
|
|
|
|
pthread_setschedparam(this_thread, scheduling_type, ¶ms);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|