mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[hal] Refactor threads API (#8701)
Since sched_setscheduler() requires non-RT priorities to be 0, we can use that as a sentinel value for disabling RT and condense the Java API to just two functions with fewer parameters. The thread priority setter is deprecated since only experts should use it. The HAL Notifier thread priority setter was replaced with setting the priority in the thread itself. The C++ Notifier non-RT and RT constructors were deduplicated. The real-time scheduler was changed from SCHED_FIFO to SCHED_RR, which is SCHED_FIFO with threads allowed to run for a maximum time quantum before yielding (100 ms by default).
This commit is contained in:
@@ -4,22 +4,28 @@
|
||||
|
||||
#include "wpi/hal/Threads.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "wpi/hal/Types.h"
|
||||
|
||||
namespace wpi::hal::init {
|
||||
void InitializeThreads() {}
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
int32_t HAL_GetThreadPriority(NativeThreadHandle handle, HAL_Bool* isRealTime,
|
||||
int32_t* status) {
|
||||
HAL_Status HAL_GetThreadPriority(NativeThreadHandle handle, int32_t* priority) {
|
||||
*priority = 0;
|
||||
return 0;
|
||||
}
|
||||
int32_t HAL_GetCurrentThreadPriority(HAL_Bool* isRealTime, int32_t* status) {
|
||||
|
||||
HAL_Status HAL_GetCurrentThreadPriority(int32_t* priority) {
|
||||
*priority = 0;
|
||||
return 0;
|
||||
}
|
||||
HAL_Bool HAL_SetThreadPriority(NativeThreadHandle handle, HAL_Bool realTime,
|
||||
int32_t priority, int32_t* status) {
|
||||
return true;
|
||||
|
||||
HAL_Status HAL_SetThreadPriority(NativeThreadHandle handle, int32_t priority) {
|
||||
return 0;
|
||||
}
|
||||
HAL_Bool HAL_SetCurrentThreadPriority(HAL_Bool realTime, int32_t priority,
|
||||
int32_t* status) {
|
||||
return true;
|
||||
|
||||
HAL_Status HAL_SetCurrentThreadPriority(int32_t priority) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user