init: Fix for issue #2797 (#2799)

* Fix for issue #2797

* Fix for issue #2797

* Fix for issue #2797
This commit is contained in:
ferrreo 2023-07-24 17:26:24 +01:00 committed by GitHub
parent 76c6e09e39
commit f6b340cc19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -6,7 +6,15 @@ bool Init::isSudo() {
void Init::gainRealTime() {
const int minPrio = sched_get_priority_min(SCHED_RR);
const struct sched_param param = {.sched_priority = minPrio};
int old_policy;
struct sched_param param;
if (pthread_getschedparam(pthread_self(), &old_policy, &param)) {
Debug::log(WARN, "Failed to get old pthread scheduling priority");
return;
}
param.sched_priority = minPrio;
if (pthread_setschedparam(pthread_self(), SCHED_RR, &param)) {
Debug::log(WARN, "Failed to change process scheduling strategy");