added overflow checking

This commit is contained in:
Robin Müller 2020-06-22 20:39:36 +02:00
parent 2cada2df4a
commit 3c7ac60dbe

View File

@ -111,8 +111,15 @@ void FixedTimeslotTask::taskFunctionality() {
/* If all operations are finished and the difference of the /* If all operations are finished and the difference of the
* current time minus the last wake time is larger than the * current time minus the last wake time is larger than the
* expected wait period, a deadline was missed. */ * expected wait period, a deadline was missed.
if(xTaskGetTickCount() - xLastWakeTime >= interval) { * We also check whether an overflow has occured first.
* In this special case, we will ignore missed deadlines for now. */
const TickType_t constTickCount = xTaskGetTickCount();
if(constTickCount < xLastWakeTime or
constTickCount + interval < xLastWakeTime) {
// don't do anything for now.
}
else if(xTaskGetTickCount() - xLastWakeTime >= interval) {
#ifdef DEBUG #ifdef DEBUG
sif::warning << "FixedTimeslotTask: " << pcTaskGetName(NULL) << sif::warning << "FixedTimeslotTask: " << pcTaskGetName(NULL) <<
" missed deadline!\n" << std::flush; " missed deadline!\n" << std::flush;