some tweaks for busy handling #500

Merged
muellerr merged 28 commits from tweak_papb_busy_polling into develop 2023-03-24 14:15:01 +01:00
7 changed files with 30 additions and 19 deletions
Showing only changes of commit beb80e7a0b - Show all commits

View File

@ -186,19 +186,19 @@ void scheduling::initTasks() {
scheduling::printAddObjectError("LIVE_TM", objects::LIVE_TM_TASK); scheduling::printAddObjectError("LIVE_TM", objects::LIVE_TM_TASK);
} }
PeriodicTaskIF* logTmTask = factory->createPeriodicTask( 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); result = logTmTask->addComponent(objects::LOG_STORE_AND_TM_TASK);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
scheduling::printAddObjectError("LOG_STORE_AND_TM", objects::LOG_STORE_AND_TM_TASK); scheduling::printAddObjectError("LOG_STORE_AND_TM", objects::LOG_STORE_AND_TM_TASK);
} }
PeriodicTaskIF* hkTmTask = factory->createPeriodicTask( 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); result = hkTmTask->addComponent(objects::HK_STORE_AND_TM_TASK);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
scheduling::printAddObjectError("HK_STORE_AND_TM", objects::HK_STORE_AND_TM_TASK); scheduling::printAddObjectError("HK_STORE_AND_TM", objects::HK_STORE_AND_TM_TASK);
} }
PeriodicTaskIF* cfdpTmTask = factory->createPeriodicTask( 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); result = cfdpTmTask->addComponent(objects::CFDP_STORE_AND_TM_TASK);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
scheduling::printAddObjectError("CFDP_STORE_AND_TM", objects::CFDP_STORE_AND_TM_TASK); 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 #if OBSW_ADD_PLOC_SUPERVISOR == 1
PeriodicTaskIF* supvHelperTask = factory->createPeriodicTask( 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); result = supvHelperTask->addComponent(objects::PLOC_SUPERVISOR_HELPER);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
scheduling::printAddObjectError("PLOC_SUPV_HELPER", objects::PLOC_SUPERVISOR_HELPER); 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) {} miscStoreContext(persTmStore::DUMP_MISC_STORE_DONE) {}
ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) { ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) {
bool someonesBusy = false;
auto stateHandlingForStore = [&](bool storeIsBusy) {
if (storeIsBusy) {
someonesBusy = true;
}
if (fileHasSwapped) {
someFileWasSwapped = fileHasSwapped;
}
};
while (true) { while (true) {
if (not cyclicStoreCheck()) { if (not cyclicStoreCheck()) {
continue; continue;
} }
bool someonesBusy = false; someFileWasSwapped = false;
bool busy = false; bool busy = handleOneStore(stores.okStore, okStoreContext);
busy = handleOneStore(stores.okStore, okStoreContext); stateHandlingForStore(busy);
if (busy) { stateHandlingForStore(handleOneStore(stores.notOkStore, notOkStoreContext));
someonesBusy = true; stateHandlingForStore(handleOneStore(stores.miscStore, miscStoreContext));
}
busy = handleOneStore(stores.notOkStore, notOkStoreContext);
if (busy) {
someonesBusy = true;
}
busy = handleOneStore(stores.miscStore, miscStoreContext);
if (busy) {
someonesBusy = true;
}
if (not someonesBusy) { if (not someonesBusy) {
TaskFactory::delayTask(40); 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 notOkStoreContext;
DumpContext miscStoreContext; DumpContext miscStoreContext;
Countdown tcHandlingCd = Countdown(400); Countdown tcHandlingCd = Countdown(400);
Countdown graceDelayDuringDumping = Countdown(200);
bool someFileWasSwapped = false;
bool initStoresIfPossible(); bool initStoresIfPossible();
}; };

View File

@ -18,6 +18,11 @@ ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) {
bool busy = handleOneStore(storeWithQueue, dumpContext); bool busy = handleOneStore(storeWithQueue, dumpContext);
if (not busy) { if (not busy) {
TaskFactory::delayTask(40); 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; PersistentTmStoreWithTmQueue& storeWithQueue;
DumpContext dumpContext; DumpContext dumpContext;
Countdown tcHandlingCd = Countdown(400); Countdown tcHandlingCd = Countdown(400);
Countdown graceDelayDuringDumping = Countdown(100);
bool initStoresIfPossible(); bool initStoresIfPossible();
}; };

View File

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

View File

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