mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +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:
@@ -20,6 +20,7 @@
|
||||
#include "WPILibVersion.h"
|
||||
#include "frc/DriverStation.h"
|
||||
#include "frc/Errors.h"
|
||||
#include "frc/Notifier.h"
|
||||
#include "frc/RobotState.h"
|
||||
#include "frc/livewindow/LiveWindow.h"
|
||||
#include "frc/smartdashboard/SmartDashboard.h"
|
||||
@@ -35,6 +36,12 @@ int frc::RunHALInitialization() {
|
||||
}
|
||||
HAL_Report(HALUsageReporting::kResourceType_Language,
|
||||
HALUsageReporting::kLanguage_CPlusPlus, 0, GetWPILibVersion());
|
||||
|
||||
if (!frc::Notifier::SetHALThreadPriority(true, 40)) {
|
||||
FRC_ReportError(warn::Warning, "{}",
|
||||
"Setting HAL Notifier RT priority to 40 failed\n");
|
||||
}
|
||||
|
||||
std::puts("\n********** Robot program starting **********");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user