Actions
バグ #1608
closedPeriodicExecutionContextでのsleep時間の計算方法
Start date:
07/06/2010
Due date:
% Done:
100%
Estimated time:
Description
PeriodicExecutionContextでのsleep時間は、RTCの実行時間が考慮されていないので修正する。
実際のsleep時間は、(周期)-(全RTCの実行時間) にするべき。
Updated by n-ando over 13 years ago
- Status changed from 新規 to 終了
- Assignee set to n-ando
- % Done changed from 0 to 100
ECのsleep時間をRTCの実行時間を考慮して計算するように修正。
数百msオーダーでの正確さはあるが、それ以上(msオーダー)ではあまり意味がない。
+++ trunk/OpenRTM-aist/src/lib/rtm/PeriodicExecutionContext.cpp 2011-04-29 11:54:13 UTC (rev 2075) @@ -148,12 +148,24 @@ { m_worker.cond_.wait(); } + coil::TimeValue t0(coil::gettimeofday()); if (m_worker.running_) { std::for_each(m_comps.begin(), m_comps.end(), invoke_worker()); } m_worker.mutex_.unlock(); - if (!m_nowait) { coil::sleep(m_period); } + coil::TimeValue t1(coil::gettimeofday()); + RTC_PARANOID(("Period: %f [s]", (double)m_period)); + RTC_PARANOID(("Execution: %f [s]", (double)(t1 - t0))); + RTC_PARANOID(("Sleep: %f [s]", (double)(m_period - (t1 - t0)))); + coil::TimeValue t2(coil::gettimeofday()); + if (!m_nowait && m_period > (t1 - t0)) + { + RTC_PARANOID(("sleeping...")); + coil::sleep((coil::TimeValue)(m_period - (t1 - t0))); + } + coil::TimeValue t3(coil::gettimeofday()); + RTC_PARANOID(("Slept: %f [s]", (double)(t3 - t2))); } while (m_svc); return 0;
Actions