Minor scheduler tidy

This commit is contained in:
Martin Budden 2017-03-12 16:25:46 +00:00
parent 207bfd43e3
commit 463ee8af2d
3 changed files with 12 additions and 18 deletions

View File

@ -25,18 +25,12 @@
#include "scheduler/scheduler.h"
void main_step(void)
{
scheduler();
processLoopback();
}
#ifndef NOMAIN
int main(void)
{
init();
while (true) {
main_step();
scheduler();
processLoopback();
}
return 0;
}
#endif

View File

@ -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) {
return currentTask->taskLatestDeltaTime;

View File

@ -39,12 +39,12 @@ typedef struct {
const char * taskName;
const char * subTaskName;
bool isEnabled;
timeUs_t desiredPeriod;
uint8_t staticPriority;
timeDelta_t desiredPeriod;
timeDelta_t latestDeltaTime;
timeUs_t maxExecutionTime;
timeUs_t totalExecutionTime;
timeUs_t averageExecutionTime;
timeUs_t latestDeltaTime;
} cfTaskInfo_t;
typedef enum {
@ -118,23 +118,23 @@ typedef enum {
} cfTaskId_e;
typedef struct {
/* Configuration */
// Configuration
const char * taskName;
const char * subTaskName;
bool (*checkFunc)(timeUs_t currentTimeUs, timeDelta_t currentDeltaTimeUs);
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
/* Scheduling */
// Scheduling
uint16_t dynamicPriority; // measurement of how old task was last executed, used to avoid task starvation
uint16_t taskAgeCycles;
timeDelta_t taskLatestDeltaTime;
timeUs_t lastExecutedAt; // last time of invocation
timeUs_t lastSignaledAt; // time of invocation event for event-driven tasks
uint32_t taskLatestDeltaTime;
#ifndef SKIP_TASK_STATISTICS
/* Statistics */
// Statistics
timeUs_t movingSumExecutionTime; // moving sum over 32 samples
timeUs_t maxExecutionTime;
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 rescheduleTask(cfTaskId_e taskId, uint32_t newPeriodMicros);
void setTaskEnabled(cfTaskId_e taskId, bool newEnabledState);
uint32_t getTaskDeltaTime(cfTaskId_e taskId);
timeDelta_t getTaskDeltaTime(cfTaskId_e taskId);
void schedulerSetCalulateTaskStatistics(bool calculateTaskStatistics);
void schedulerResetTaskStatistics(cfTaskId_e taskId);