void ConnectedModules::pulseShift(const coredata::dmcp::PulseMessage &pm, const uint32_t &shift) { Lock l(m_modulesMutex); map<string, ConnectedModule*>::iterator iter; uint32_t connectedModulesCounter = 0; coredata::dmcp::PulseMessage pm_shifted = pm; const core::data::TimeStamp pm_org_ts = pm.getRealTimeFromSupercomponent(); for (iter = m_modules.begin(); iter != m_modules.end(); ++iter) { core::data::TimeStamp ts(0, shift * connectedModulesCounter); core::data::TimeStamp shiftedTime = pm_org_ts + ts; pm_shifted.setRealTimeFromSupercomponent(shiftedTime); iter->second->getConnection().pulse(pm_shifted); connectedModulesCounter++; } }
void ManagedClientModule::reached_ManagedLevel_Pulse() { if (m_firstCallToBreakpoint_ManagedLevel_Pulse) { // Align the further execution of a module's body until this realtime clock matches with supercomponent's realtime clock for the required waiting slice. setBreakpoint(NULL); m_firstCallToBreakpoint_ManagedLevel_Pulse = false; // Align the component ten times. uint32_t aligner = 10; while (aligner-- > 0) { const coredata::dmcp::PulseMessage pm = getDMCPClient()->getPulseMessage(); const long ONE_SECOND_IN_MICROSECONDS = 1000 * 1000 * 1; const long ADJUSTMENT_TIME_TO_VIRTUAL_ONE_SECOND = (ONE_SECOND_IN_MICROSECONDS - pm.getCumulatedTimeSlice()); const TimeStamp module_now; const long ADJUSTMENT_TIME_TO_ALIGN_REALTIME = (module_now.toMicroseconds() - pm.getRealTimeFromSupercomponent().toMicroseconds()); const long ADJUSTMENT_TIME = ADJUSTMENT_TIME_TO_VIRTUAL_ONE_SECOND - ADJUSTMENT_TIME_TO_ALIGN_REALTIME; if (ADJUSTMENT_TIME > 0) { Thread::usleepFor(ADJUSTMENT_TIME); CLOG2 << "(ManagedClientModule) Adjust execution to next timeslice that is aligned with supercomponent: " << ADJUSTMENT_TIME << " microseconds." << endl; } } } }