transform tm stores into quasi background threads

This commit is contained in:
Robin Müller 2023-03-21 14:09:59 +01:00
parent 9c22e4cab2
commit beb80e7a0b
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
7 changed files with 30 additions and 19 deletions

View File

@ -186,19 +186,19 @@ void scheduling::initTasks() {
scheduling::printAddObjectError("LIVE_TM", objects::LIVE_TM_TASK);
}
PeriodicTaskIF* logTmTask = factory->createPeriodicTask(
"LOG_STORE_AND_TM", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
"LOG_STORE_AND_TM", 15, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
result = logTmTask->addComponent(objects::LOG_STORE_AND_TM_TASK);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("LOG_STORE_AND_TM", objects::LOG_STORE_AND_TM_TASK);
}
PeriodicTaskIF* hkTmTask = factory->createPeriodicTask(
"HK_STORE_AND_TM", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
"HK_STORE_AND_TM", 15, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
result = hkTmTask->addComponent(objects::HK_STORE_AND_TM_TASK);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("HK_STORE_AND_TM", objects::HK_STORE_AND_TM_TASK);
}
PeriodicTaskIF* cfdpTmTask = factory->createPeriodicTask(
"CFDP_STORE_AND_TM", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
"CFDP_STORE_AND_TM", 15, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
result = cfdpTmTask->addComponent(objects::CFDP_STORE_AND_TM_TASK);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("CFDP_STORE_AND_TM", objects::CFDP_STORE_AND_TM_TASK);
@ -326,7 +326,7 @@ void scheduling::initTasks() {
#if OBSW_ADD_PLOC_SUPERVISOR == 1
PeriodicTaskIF* supvHelperTask = factory->createPeriodicTask(
"PLOC_SUPV_HELPER", 10, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc);
"PLOC_SUPV_HELPER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc);
result = supvHelperTask->addComponent(objects::PLOC_SUPERVISOR_HELPER);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("PLOC_SUPV_HELPER", objects::PLOC_SUPERVISOR_HELPER);

View File

@ -13,26 +13,29 @@ PersistentLogTmStoreTask::PersistentLogTmStoreTask(object_id_t objectId, Storage
miscStoreContext(persTmStore::DUMP_MISC_STORE_DONE) {}
ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) {
bool someonesBusy = false;
auto stateHandlingForStore = [&](bool storeIsBusy) {
if (storeIsBusy) {
someonesBusy = true;
}
if (fileHasSwapped) {
someFileWasSwapped = fileHasSwapped;
}
};
while (true) {
if (not cyclicStoreCheck()) {
continue;
}
bool someonesBusy = false;
bool busy = false;
busy = handleOneStore(stores.okStore, okStoreContext);
if (busy) {
someonesBusy = true;
}
busy = handleOneStore(stores.notOkStore, notOkStoreContext);
if (busy) {
someonesBusy = true;
}
busy = handleOneStore(stores.miscStore, miscStoreContext);
if (busy) {
someonesBusy = true;
}
someFileWasSwapped = false;
bool busy = handleOneStore(stores.okStore, okStoreContext);
stateHandlingForStore(busy);
stateHandlingForStore(handleOneStore(stores.notOkStore, notOkStoreContext));
stateHandlingForStore(handleOneStore(stores.miscStore, miscStoreContext));
if (not someonesBusy) {
TaskFactory::delayTask(40);
} else if (someFileWasSwapped and graceDelayDuringDumping.hasTimedOut()) {
TaskFactory::delayTask(2);
graceDelayDuringDumping.resetTimer();
}
}
}

View File

@ -32,6 +32,8 @@ class PersistentLogTmStoreTask : public TmStoreTaskBase, public ExecutableObject
DumpContext notOkStoreContext;
DumpContext miscStoreContext;
Countdown tcHandlingCd = Countdown(400);
Countdown graceDelayDuringDumping = Countdown(200);
bool someFileWasSwapped = false;
bool initStoresIfPossible();
};

View File

@ -18,6 +18,11 @@ ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) {
bool busy = handleOneStore(storeWithQueue, dumpContext);
if (not busy) {
TaskFactory::delayTask(40);
} else {
if (fileHasSwapped and graceDelayDuringDumping.hasTimedOut()) {
TaskFactory::delayTask(2);
graceDelayDuringDumping.resetTimer();
}
}
}
}

View File

@ -19,6 +19,7 @@ class PersistentSingleTmStoreTask : public TmStoreTaskBase, public ExecutableObj
PersistentTmStoreWithTmQueue& storeWithQueue;
DumpContext dumpContext;
Countdown tcHandlingCd = Countdown(400);
Countdown graceDelayDuringDumping = Countdown(100);
bool initStoresIfPossible();
};

View File

@ -25,7 +25,6 @@ bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store,
// Dump TMs when applicable
if (store.getState() == PersistentTmStore::State::DUMPING) {
size_t dumpedLen = 0;
bool fileHasSwapped;
// if (not channel.isBusy()) {
tmSinkBusyCd.resetTimer();
result = store.dumpNextPacket(channel, dumpedLen, fileHasSwapped);

View File

@ -45,6 +45,7 @@ class TmStoreTaskBase : public SystemObject {
Countdown tmSinkBusyCd = Countdown(60 * 1000);
VirtualChannel& channel;
bool storesInitialized = false;
bool fileHasSwapped = false;
SdCardMountedIF& sdcMan;
};