Commit 8488e3fc by beagle-bottom2

fix 100% cpu use when a large timestep occurse (e.g. when updating system time)

parent 943b51c8
......@@ -199,12 +199,10 @@ int main(int argc, char** argv){
#endif
//Check if we need to skip some iterations because we are too late already
if (next_update < end) {
uint32_t i=0;
while (next_update < end) {
next_update = next_update + RT_PERIOD; //fast-forward and skip iterations
i++;
}
std::cout << "Info: Loop took too long! (" << usecs<<"us). Skipping control loop "<< i <<" times."<<std::endl;
std::cout << "Info: Loop took too long! (" << usecs<<"us). Skipping to next possible control loop timepoint."<<std::endl;
next_update = end;
next_update.nsecs = next_update.nsecs + (AirserverController::PERIOD_NS - next_update.nsecs % AirserverController::PERIOD_NS); //align to the next timepoint
next_update = next_update + RT_PERIOD; //fast-forward and skip one iteration
}
Sleep(next_update - end); //wait until the next loop iteration should start
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment