mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
Minor scheduler tidy
This commit is contained in:
parent
207bfd43e3
commit
463ee8af2d
3 changed files with 12 additions and 18 deletions
|
@ -25,18 +25,12 @@
|
||||||
#include "scheduler/scheduler.h"
|
#include "scheduler/scheduler.h"
|
||||||
|
|
||||||
|
|
||||||
void main_step(void)
|
|
||||||
{
|
|
||||||
scheduler();
|
|
||||||
processLoopback();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef NOMAIN
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
while (true) {
|
while (true) {
|
||||||
main_step();
|
scheduler();
|
||||||
|
processLoopback();
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ void setTaskEnabled(cfTaskId_e taskId, bool enabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getTaskDeltaTime(cfTaskId_e taskId)
|
timeDelta_t getTaskDeltaTime(cfTaskId_e taskId)
|
||||||
{
|
{
|
||||||
if (taskId == TASK_SELF) {
|
if (taskId == TASK_SELF) {
|
||||||
return currentTask->taskLatestDeltaTime;
|
return currentTask->taskLatestDeltaTime;
|
||||||
|
|
|
@ -39,12 +39,12 @@ typedef struct {
|
||||||
const char * taskName;
|
const char * taskName;
|
||||||
const char * subTaskName;
|
const char * subTaskName;
|
||||||
bool isEnabled;
|
bool isEnabled;
|
||||||
timeUs_t desiredPeriod;
|
|
||||||
uint8_t staticPriority;
|
uint8_t staticPriority;
|
||||||
|
timeDelta_t desiredPeriod;
|
||||||
|
timeDelta_t latestDeltaTime;
|
||||||
timeUs_t maxExecutionTime;
|
timeUs_t maxExecutionTime;
|
||||||
timeUs_t totalExecutionTime;
|
timeUs_t totalExecutionTime;
|
||||||
timeUs_t averageExecutionTime;
|
timeUs_t averageExecutionTime;
|
||||||
timeUs_t latestDeltaTime;
|
|
||||||
} cfTaskInfo_t;
|
} cfTaskInfo_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -118,23 +118,23 @@ typedef enum {
|
||||||
} cfTaskId_e;
|
} cfTaskId_e;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* Configuration */
|
// Configuration
|
||||||
const char * taskName;
|
const char * taskName;
|
||||||
const char * subTaskName;
|
const char * subTaskName;
|
||||||
bool (*checkFunc)(timeUs_t currentTimeUs, timeDelta_t currentDeltaTimeUs);
|
bool (*checkFunc)(timeUs_t currentTimeUs, timeDelta_t currentDeltaTimeUs);
|
||||||
void (*taskFunc)(timeUs_t currentTimeUs);
|
void (*taskFunc)(timeUs_t currentTimeUs);
|
||||||
uint32_t desiredPeriod; // target period of execution
|
timeDelta_t desiredPeriod; // target period of execution
|
||||||
const uint8_t staticPriority; // dynamicPriority grows in steps of this size, shouldn't be zero
|
const uint8_t staticPriority; // dynamicPriority grows in steps of this size, shouldn't be zero
|
||||||
|
|
||||||
/* Scheduling */
|
// Scheduling
|
||||||
uint16_t dynamicPriority; // measurement of how old task was last executed, used to avoid task starvation
|
uint16_t dynamicPriority; // measurement of how old task was last executed, used to avoid task starvation
|
||||||
uint16_t taskAgeCycles;
|
uint16_t taskAgeCycles;
|
||||||
|
timeDelta_t taskLatestDeltaTime;
|
||||||
timeUs_t lastExecutedAt; // last time of invocation
|
timeUs_t lastExecutedAt; // last time of invocation
|
||||||
timeUs_t lastSignaledAt; // time of invocation event for event-driven tasks
|
timeUs_t lastSignaledAt; // time of invocation event for event-driven tasks
|
||||||
uint32_t taskLatestDeltaTime;
|
|
||||||
|
|
||||||
#ifndef SKIP_TASK_STATISTICS
|
#ifndef SKIP_TASK_STATISTICS
|
||||||
/* Statistics */
|
// Statistics
|
||||||
timeUs_t movingSumExecutionTime; // moving sum over 32 samples
|
timeUs_t movingSumExecutionTime; // moving sum over 32 samples
|
||||||
timeUs_t maxExecutionTime;
|
timeUs_t maxExecutionTime;
|
||||||
timeUs_t totalExecutionTime; // total time consumed by task since boot
|
timeUs_t totalExecutionTime; // total time consumed by task since boot
|
||||||
|
@ -148,7 +148,7 @@ void getCheckFuncInfo(cfCheckFuncInfo_t *checkFuncInfo);
|
||||||
void getTaskInfo(cfTaskId_e taskId, cfTaskInfo_t *taskInfo);
|
void getTaskInfo(cfTaskId_e taskId, cfTaskInfo_t *taskInfo);
|
||||||
void rescheduleTask(cfTaskId_e taskId, uint32_t newPeriodMicros);
|
void rescheduleTask(cfTaskId_e taskId, uint32_t newPeriodMicros);
|
||||||
void setTaskEnabled(cfTaskId_e taskId, bool newEnabledState);
|
void setTaskEnabled(cfTaskId_e taskId, bool newEnabledState);
|
||||||
uint32_t getTaskDeltaTime(cfTaskId_e taskId);
|
timeDelta_t getTaskDeltaTime(cfTaskId_e taskId);
|
||||||
void schedulerSetCalulateTaskStatistics(bool calculateTaskStatistics);
|
void schedulerSetCalulateTaskStatistics(bool calculateTaskStatistics);
|
||||||
void schedulerResetTaskStatistics(cfTaskId_e taskId);
|
void schedulerResetTaskStatistics(cfTaskId_e taskId);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue