diff --git a/src/debug/real-time-logger.cpp b/src/debug/real-time-logger.cpp index 9e625bf5867eb51fbe15cc06a78fc0959ece7d4f..97ad576cbf3da2f3098be5291df0a45247f8def2 100644 --- a/src/debug/real-time-logger.cpp +++ b/src/debug/real-time-logger.cpp @@ -94,6 +94,19 @@ namespace dynamicgraph void spin (RealTimeLogger* logger) { + // Change the thread's scheduler from real-time to normal and reduce its priority + int threadPolicy; + struct sched_param threadParam; + if (pthread_getschedparam (pthread_self(), &threadPolicy, &threadParam) == 0) + { + threadPolicy = SCHED_OTHER; + threadParam.sched_priority -= 5; + if (threadParam.sched_priority < sched_get_priority_min (threadPolicy)) + threadParam.sched_priority = sched_get_priority_min (threadPolicy); + + pthread_setschedparam (pthread_self(), threadPolicy, &threadParam); + } + while (!requestShutdown_ || !logger->empty()) { // If the logger did not write anything, it means the buffer is empty.