[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

@@ -20,7 +20,7 @@ namespace frc {
int GetThreadPriority(std::thread& thread, bool* isRealTime);
/**
* Get the thread priority for the current thread
* Get the thread priority for the current thread.
*
* @param isRealTime Set to true if thread is real-time, otherwise false.
* @return The current thread priority. For real-time, this is 1-99
@@ -30,7 +30,7 @@ int GetThreadPriority(std::thread& thread, bool* isRealTime);
int GetCurrentThreadPriority(bool* isRealTime);
/**
* Sets the thread priority for the specified thread
* Sets the thread priority for the specified thread.
*
* @param thread Reference to the thread to set the priority of.
* @param realTime Set to true to set a real-time priority, false for standard
@@ -43,7 +43,7 @@ int GetCurrentThreadPriority(bool* isRealTime);
bool SetThreadPriority(std::thread& thread, bool realTime, int priority);
/**
* Sets the thread priority for the current thread
* Sets the thread priority for the current thread.
*
* @param realTime Set to true to set a real-time priority, false for standard
* priority.