mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[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:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user