mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Add expediting of OSD task
This commit is contained in:
parent
e7b61a928f
commit
db904b4a75
6 changed files with 27 additions and 0 deletions
|
@ -93,6 +93,9 @@ static int32_t desiredPeriodCycles;
|
||||||
static uint32_t lastTargetCycles;
|
static uint32_t lastTargetCycles;
|
||||||
|
|
||||||
static uint8_t skippedRxAttempts = 0;
|
static uint8_t skippedRxAttempts = 0;
|
||||||
|
#ifdef USE_OSD
|
||||||
|
static uint8_t skippedOSDAttempts = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(USE_LATE_TASK_STATISTICS)
|
#if defined(USE_LATE_TASK_STATISTICS)
|
||||||
static int16_t lateTaskCount = 0;
|
static int16_t lateTaskCount = 0;
|
||||||
|
@ -638,6 +641,11 @@ FAST_CODE void scheduler(void)
|
||||||
if ((currentTask - tasks) == TASK_RX) {
|
if ((currentTask - tasks) == TASK_RX) {
|
||||||
skippedRxAttempts = 0;
|
skippedRxAttempts = 0;
|
||||||
}
|
}
|
||||||
|
#ifdef USE_OSD
|
||||||
|
else if ((currentTask - tasks) == TASK_OSD) {
|
||||||
|
skippedOSDAttempts = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((cyclesOverdue > 0) || (-cyclesOverdue < taskGuardMinCycles)) {
|
if ((cyclesOverdue > 0) || (-cyclesOverdue < taskGuardMinCycles)) {
|
||||||
if (taskGuardCycles < taskGuardMaxCycles) {
|
if (taskGuardCycles < taskGuardMaxCycles) {
|
||||||
|
@ -650,6 +658,9 @@ FAST_CODE void scheduler(void)
|
||||||
taskCount++;
|
taskCount++;
|
||||||
#endif // USE_LATE_TASK_STATISTICS
|
#endif // USE_LATE_TASK_STATISTICS
|
||||||
} else if ((selectedTask->taskAgePeriods > TASK_AGE_EXPEDITE_COUNT) ||
|
} else if ((selectedTask->taskAgePeriods > TASK_AGE_EXPEDITE_COUNT) ||
|
||||||
|
#ifdef USE_OSD
|
||||||
|
(((selectedTask - tasks) == TASK_OSD) && (++skippedOSDAttempts > TASK_AGE_EXPEDITE_OSD)) ||
|
||||||
|
#endif
|
||||||
(((selectedTask - tasks) == TASK_RX) && (++skippedRxAttempts > TASK_AGE_EXPEDITE_RX))) {
|
(((selectedTask - tasks) == TASK_RX) && (++skippedRxAttempts > TASK_AGE_EXPEDITE_RX))) {
|
||||||
// If a task has been unable to run, then reduce it's recorded estimated run time to ensure
|
// If a task has been unable to run, then reduce it's recorded estimated run time to ensure
|
||||||
// it's ultimate scheduling
|
// it's ultimate scheduling
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#define TASK_EXEC_TIME_SHIFT 7
|
#define TASK_EXEC_TIME_SHIFT 7
|
||||||
|
|
||||||
#define TASK_AGE_EXPEDITE_RX 25 // Make RX tasks more schedulable if it's failed to be scheduled this many times
|
#define TASK_AGE_EXPEDITE_RX 25 // Make RX tasks more schedulable if it's failed to be scheduled this many times
|
||||||
|
#define TASK_AGE_EXPEDITE_OSD 25 // Make OSD tasks more schedulable if it's failed to be scheduled this many times
|
||||||
#define TASK_AGE_EXPEDITE_COUNT 1 // Make aged tasks more schedulable
|
#define TASK_AGE_EXPEDITE_COUNT 1 // Make aged tasks more schedulable
|
||||||
#define TASK_AGE_EXPEDITE_SCALE 0.9 // By scaling their expected execution time
|
#define TASK_AGE_EXPEDITE_SCALE 0.9 // By scaling their expected execution time
|
||||||
|
|
||||||
|
|
|
@ -278,6 +278,8 @@ scheduler_unittest_SRC := \
|
||||||
$(USER_DIR)/common/crc.c \
|
$(USER_DIR)/common/crc.c \
|
||||||
$(USER_DIR)/common/streambuf.c
|
$(USER_DIR)/common/streambuf.c
|
||||||
|
|
||||||
|
scheduler_unittest_DEFINES := \
|
||||||
|
USE_OSD=
|
||||||
|
|
||||||
sensor_gyro_unittest_SRC := \
|
sensor_gyro_unittest_SRC := \
|
||||||
$(USER_DIR)/sensors/gyro.c \
|
$(USER_DIR)/sensors/gyro.c \
|
||||||
|
|
|
@ -512,6 +512,7 @@ extern "C" {
|
||||||
bool taskUpdateRxMainInProgress() { return true; }
|
bool taskUpdateRxMainInProgress() { return true; }
|
||||||
void schedulerIgnoreTaskStateTime(void) { }
|
void schedulerIgnoreTaskStateTime(void) { }
|
||||||
void schedulerIgnoreTaskExecRate(void) { }
|
void schedulerIgnoreTaskExecRate(void) { }
|
||||||
|
bool schedulerGetIgnoreTaskExecTime() { return false; }
|
||||||
void schedulerIgnoreTaskExecTime(void) { }
|
void schedulerIgnoreTaskExecTime(void) { }
|
||||||
void schedulerSetNextStateTime(timeDelta_t) {}
|
void schedulerSetNextStateTime(timeDelta_t) {}
|
||||||
|
|
||||||
|
|
|
@ -1377,5 +1377,6 @@ extern "C" {
|
||||||
void schedulerIgnoreTaskStateTime(void) { }
|
void schedulerIgnoreTaskStateTime(void) { }
|
||||||
void schedulerIgnoreTaskExecRate(void) { }
|
void schedulerIgnoreTaskExecRate(void) { }
|
||||||
void schedulerIgnoreTaskExecTime(void) { }
|
void schedulerIgnoreTaskExecTime(void) { }
|
||||||
|
bool schedulerGetIgnoreTaskExecTime() { return false; }
|
||||||
void schedulerSetNextStateTime(timeDelta_t) {}
|
void schedulerSetNextStateTime(timeDelta_t) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ const int TEST_UPDATE_RX_CHECK_TIME = 34;
|
||||||
const int TEST_UPDATE_RX_MAIN_TIME = 1;
|
const int TEST_UPDATE_RX_MAIN_TIME = 1;
|
||||||
const int TEST_IMU_UPDATE_TIME = 5;
|
const int TEST_IMU_UPDATE_TIME = 5;
|
||||||
const int TEST_DISPATCH_TIME = 1;
|
const int TEST_DISPATCH_TIME = 1;
|
||||||
|
const int TEST_UPDATE_OSD_CHECK_TIME = 5;
|
||||||
|
const int TEST_UPDATE_OSD_TIME = 30;
|
||||||
|
|
||||||
#define TASK_COUNT_UNITTEST (TASK_BATTERY_VOLTAGE + 1)
|
#define TASK_COUNT_UNITTEST (TASK_BATTERY_VOLTAGE + 1)
|
||||||
#define TASK_PERIOD_HZ(hz) (1000000 / (hz))
|
#define TASK_PERIOD_HZ(hz) (1000000 / (hz))
|
||||||
|
@ -76,6 +78,8 @@ extern "C" {
|
||||||
void taskUpdateRxMain(timeUs_t) { simulatedTime += TEST_UPDATE_RX_MAIN_TIME; }
|
void taskUpdateRxMain(timeUs_t) { simulatedTime += TEST_UPDATE_RX_MAIN_TIME; }
|
||||||
void imuUpdateAttitude(timeUs_t) { simulatedTime += TEST_IMU_UPDATE_TIME; }
|
void imuUpdateAttitude(timeUs_t) { simulatedTime += TEST_IMU_UPDATE_TIME; }
|
||||||
void dispatchProcess(timeUs_t) { simulatedTime += TEST_DISPATCH_TIME; }
|
void dispatchProcess(timeUs_t) { simulatedTime += TEST_DISPATCH_TIME; }
|
||||||
|
bool osdUpdateCheck(timeUs_t, timeDelta_t) { simulatedTime += TEST_UPDATE_OSD_CHECK_TIME; return false; }
|
||||||
|
void osdUpdate(timeUs_t) { simulatedTime += TEST_UPDATE_OSD_TIME; }
|
||||||
|
|
||||||
void resetGyroTaskTestFlags(void) {
|
void resetGyroTaskTestFlags(void) {
|
||||||
taskGyroRan = false;
|
taskGyroRan = false;
|
||||||
|
@ -156,6 +160,13 @@ extern "C" {
|
||||||
.taskFunc = taskUpdateBatteryVoltage,
|
.taskFunc = taskUpdateBatteryVoltage,
|
||||||
.desiredPeriodUs = TASK_PERIOD_HZ(50),
|
.desiredPeriodUs = TASK_PERIOD_HZ(50),
|
||||||
.staticPriority = TASK_PRIORITY_MEDIUM,
|
.staticPriority = TASK_PRIORITY_MEDIUM,
|
||||||
|
},
|
||||||
|
[TASK_OSD] = {
|
||||||
|
.taskName = "OSD",
|
||||||
|
.checkFunc = osdUpdateCheck,
|
||||||
|
.taskFunc = osdUpdate,
|
||||||
|
.desiredPeriodUs = TASK_PERIOD_HZ(12),
|
||||||
|
.staticPriority = TASK_PRIORITY_LOW,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue