Merge pull request #11319 from SteveCEvans/relax_determinism
Add scheduler_relax_rx and scheduler_relax_osd variables
This commit is contained in:
commit
f2559fbfd8
|
@ -101,6 +101,7 @@
|
||||||
#include "pg/vcd.h"
|
#include "pg/vcd.h"
|
||||||
#include "pg/vtx_io.h"
|
#include "pg/vtx_io.h"
|
||||||
#include "pg/usb.h"
|
#include "pg/usb.h"
|
||||||
|
#include "pg/scheduler.h"
|
||||||
#include "pg/sdio.h"
|
#include "pg/sdio.h"
|
||||||
#include "pg/rcdevice.h"
|
#include "pg/rcdevice.h"
|
||||||
#include "pg/stats.h"
|
#include "pg/stats.h"
|
||||||
|
@ -1682,6 +1683,9 @@ const clivalue_t valueTable[] = {
|
||||||
{ "expresslrs_model_id", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, UINT8_MAX }, PG_RX_EXPRESSLRS_SPI_CONFIG, offsetof(rxExpressLrsSpiConfig_t, modelId) },
|
{ "expresslrs_model_id", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, UINT8_MAX }, PG_RX_EXPRESSLRS_SPI_CONFIG, offsetof(rxExpressLrsSpiConfig_t, modelId) },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
{ "scheduler_relax_rx", VAR_UINT16 | HARDWARE_VALUE, .config.minmaxUnsigned = { 0, 500 }, PG_SCHEDULER_CONFIG, PG_ARRAY_ELEMENT_OFFSET(schedulerConfig_t, 0, rxRelaxDeterminism) },
|
||||||
|
{ "scheduler_relax_osd", VAR_UINT16 | HARDWARE_VALUE, .config.minmaxUnsigned = { 0, 500 }, PG_SCHEDULER_CONFIG, PG_ARRAY_ELEMENT_OFFSET(schedulerConfig_t, 0, osdRelaxDeterminism) },
|
||||||
|
|
||||||
// PG_TIMECONFIG
|
// PG_TIMECONFIG
|
||||||
#ifdef USE_RTC_TIME
|
#ifdef USE_RTC_TIME
|
||||||
{ "timezone_offset_minutes", VAR_INT16 | MASTER_VALUE, .config.minmax = { TIMEZONE_OFFSET_MINUTES_MIN, TIMEZONE_OFFSET_MINUTES_MAX }, PG_TIME_CONFIG, offsetof(timeConfig_t, tz_offsetMinutes) },
|
{ "timezone_offset_minutes", VAR_INT16 | MASTER_VALUE, .config.minmax = { TIMEZONE_OFFSET_MINUTES_MIN, TIMEZONE_OFFSET_MINUTES_MAX }, PG_TIME_CONFIG, offsetof(timeConfig_t, tz_offsetMinutes) },
|
||||||
|
|
|
@ -152,7 +152,8 @@
|
||||||
#define PG_MODE_ACTIVATION_CONFIG 553
|
#define PG_MODE_ACTIVATION_CONFIG 553
|
||||||
#define PG_DYN_NOTCH_CONFIG 554
|
#define PG_DYN_NOTCH_CONFIG 554
|
||||||
#define PG_RX_EXPRESSLRS_SPI_CONFIG 555
|
#define PG_RX_EXPRESSLRS_SPI_CONFIG 555
|
||||||
#define PG_BETAFLIGHT_END 555
|
#define PG_SCHEDULER_CONFIG 556
|
||||||
|
#define PG_BETAFLIGHT_END 556
|
||||||
|
|
||||||
|
|
||||||
// OSD configuration (subject to change)
|
// OSD configuration (subject to change)
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight and Betaflight.
|
||||||
|
*
|
||||||
|
* Cleanflight and Betaflight are free software. You can redistribute
|
||||||
|
* this software and/or modify this software under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Cleanflight and Betaflight are distributed in the hope that they
|
||||||
|
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this software.
|
||||||
|
*
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#include "pg/pg_ids.h"
|
||||||
|
#include "pg/scheduler.h"
|
||||||
|
|
||||||
|
PG_REGISTER_WITH_RESET_TEMPLATE(schedulerConfig_t, schedulerConfig, PG_SCHEDULER_CONFIG, 0);
|
||||||
|
|
||||||
|
PG_RESET_TEMPLATE(schedulerConfig_t, schedulerConfig,
|
||||||
|
.rxRelaxDeterminism = SCHEDULER_RELAX_RX,
|
||||||
|
.osdRelaxDeterminism = SCHEDULER_RELAX_OSD,
|
||||||
|
);
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight and Betaflight.
|
||||||
|
*
|
||||||
|
* Cleanflight and Betaflight are free software. You can redistribute
|
||||||
|
* this software and/or modify this software under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Cleanflight and Betaflight are distributed in the hope that they
|
||||||
|
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this software.
|
||||||
|
*
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "pg/pg.h"
|
||||||
|
|
||||||
|
#ifdef STM32F411xE
|
||||||
|
// Allow RX and OSD tasks to be scheduled at the second attempt on F411 processors
|
||||||
|
#define SCHEDULER_RELAX_RX 1
|
||||||
|
#define SCHEDULER_RELAX_OSD 1
|
||||||
|
#else
|
||||||
|
#define SCHEDULER_RELAX_RX 25
|
||||||
|
#define SCHEDULER_RELAX_OSD 25
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct schedulerConfig_s {
|
||||||
|
uint16_t rxRelaxDeterminism;
|
||||||
|
uint16_t osdRelaxDeterminism;
|
||||||
|
} schedulerConfig_t;
|
||||||
|
|
||||||
|
PG_DECLARE(schedulerConfig_t, schedulerConfig);
|
||||||
|
|
|
@ -659,9 +659,9 @@ FAST_CODE void scheduler(void)
|
||||||
#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
|
#ifdef USE_OSD
|
||||||
(((selectedTask - tasks) == TASK_OSD) && (++skippedOSDAttempts > TASK_AGE_EXPEDITE_OSD)) ||
|
(((selectedTask - tasks) == TASK_OSD) && (TASK_AGE_EXPEDITE_OSD != 0) && (++skippedOSDAttempts > TASK_AGE_EXPEDITE_OSD)) ||
|
||||||
#endif
|
#endif
|
||||||
(((selectedTask - tasks) == TASK_RX) && (++skippedRxAttempts > TASK_AGE_EXPEDITE_RX))) {
|
(((selectedTask - tasks) == TASK_RX) && (TASK_AGE_EXPEDITE_RX != 0) && (++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
|
||||||
selectedTask->anticipatedExecutionTime *= TASK_AGE_EXPEDITE_SCALE;
|
selectedTask->anticipatedExecutionTime *= TASK_AGE_EXPEDITE_SCALE;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include "common/time.h"
|
#include "common/time.h"
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
|
#include "pg/scheduler.h"
|
||||||
|
|
||||||
#define TASK_PERIOD_HZ(hz) (1000000 / (hz))
|
#define TASK_PERIOD_HZ(hz) (1000000 / (hz))
|
||||||
#define TASK_PERIOD_MS(ms) ((ms) * 1000)
|
#define TASK_PERIOD_MS(ms) ((ms) * 1000)
|
||||||
|
@ -47,8 +48,8 @@
|
||||||
// Decay the estimated max task duration by 1/(1 << TASK_EXEC_TIME_SHIFT) on every invocation
|
// Decay the estimated max task duration by 1/(1 << TASK_EXEC_TIME_SHIFT) on every invocation
|
||||||
#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 schedulerConfig()->rxRelaxDeterminism // 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_OSD schedulerConfig()->osdRelaxDeterminism // 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
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,17 @@
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
#include "pg/pg.h"
|
||||||
|
#include "pg/pg_ids.h"
|
||||||
|
#include "pg/scheduler.h"
|
||||||
#include "scheduler/scheduler.h"
|
#include "scheduler/scheduler.h"
|
||||||
|
|
||||||
|
PG_REGISTER_WITH_RESET_TEMPLATE(schedulerConfig_t, schedulerConfig, PG_SCHEDULER_CONFIG, 0);
|
||||||
|
|
||||||
|
PG_RESET_TEMPLATE(schedulerConfig_t, schedulerConfig,
|
||||||
|
.rxRelaxDeterminism = 25,
|
||||||
|
.osdRelaxDeterminism = 25,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "unittest_macros.h"
|
#include "unittest_macros.h"
|
||||||
|
|
Loading…
Reference in New Issue