[hal] Set HAL Notifier thread as RT by default (#3482)

This PR gives the Notifier HAL thread RT priority 40 in RobotBase after
HAL initialization and before the user code is run. This drastically
improves scheduling jitter for TimedRobot's AddPeriodic() functions (in
3512's experience).

It's too risky to set user code as RT because badly behaved code
will lock up the Rio (potentially requiring safe mode to recover).

This needs the user program to be setuid admin to succeed.
This commit is contained in:
Tyler Veness
2021-08-14 11:42:35 -07:00
committed by GitHub
parent 192d251ee8
commit 5d9ae3cdb4
8 changed files with 182 additions and 14 deletions

View File

@@ -26,7 +26,7 @@ Java_edu_wpi_first_hal_ThreadsJNI_getCurrentThreadPriority
HAL_Bool isRT = false;
auto ret = HAL_GetCurrentThreadPriority(&isRT, &status);
CheckStatus(env, status);
return (jint)ret;
return static_cast<jint>(ret);
}
/*
@@ -42,7 +42,7 @@ Java_edu_wpi_first_hal_ThreadsJNI_getCurrentThreadIsRealTime
HAL_Bool isRT = false;
HAL_GetCurrentThreadPriority(&isRT, &status);
CheckStatus(env, status);
return (jboolean)isRT;
return static_cast<jboolean>(isRT);
}
/*
@@ -56,9 +56,9 @@ Java_edu_wpi_first_hal_ThreadsJNI_setCurrentThreadPriority
{
int32_t status = 0;
auto ret = HAL_SetCurrentThreadPriority(
(HAL_Bool)realTime, static_cast<int32_t>(priority), &status);
CheckStatus(env, status);
return (jboolean)ret;
static_cast<HAL_Bool>(realTime), static_cast<int32_t>(priority), &status);
CheckStatus(env, status, false);
return static_cast<jboolean>(ret);
}
} // extern "C"