MCPcopy Create free account
hub / github.com/dmtcp/dmtcp / postRestart

Method postRestart

src/plugin/timer/timerlist.cpp:188–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188void
189TimerList::postRestart()
190{
191 // Refresh clockids
192 map<clockid_t, pid_t>::iterator it1;
193 for (it1 = _clockPidList.begin(); it1 != _clockPidList.end(); it1++) {
194 pid_t pid = it1->second;
195 clockid_t virtId = it1->first;
196 clockid_t realId;
197 JASSERT(_real_clock_getcpuclockid(pid, &realId) == 0) (pid) (JASSERT_ERRNO);
198 _clockVirtIdTable.updateMapping(virtId, realId);
199 }
200
201 map<clockid_t, pthread_t>::iterator it2;
202 for (it2 = _clockPthreadList.begin(); it2 != _clockPthreadList.end(); it2++) {
203 pthread_t pth = it2->second;
204 clockid_t virtId = it2->first;
205 clockid_t realId;
206 JASSERT(_real_pthread_getcpuclockid(pth, &realId) == 0) (pth)
207 (JASSERT_ERRNO);
208 _clockVirtIdTable.updateMapping(virtId, realId);
209 }
210
211 // Refresh timers
212 for (_iter = _timerInfo.begin(); _iter != _timerInfo.end(); _iter++) {
213 timer_t realId;
214 timer_t virtId = _iter->first;
215 struct sigevent *sevp = NULL;
216 TimerInfo &tinfo = _iter->second;
217 clockid_t clockid = VIRTUAL_TO_REAL_CLOCK_ID(tinfo.clockid);
218 if (!tinfo.sevp_null) {
219 sevp = &tinfo.sevp;
220 }
221 JASSERT(_real_timer_create(clockid, sevp, &realId) == 0)
222 (virtId) (JASSERT_ERRNO);
223 _timerVirtIdTable.updateMapping(virtId, realId);
224 if (tinfo.curr_timerspec.it_value.tv_sec != 0 ||
225 tinfo.curr_timerspec.it_value.tv_nsec != 0) {
226 struct itimerspec tspec;
227 if (tinfo.flags & TIMER_ABSTIME) {
228 // The timer should expire when the clock time equals the time
229 // specified in initial_timerspec.
230 // FIXME: For clocks measugin CPU time for processes and threads, such
231 // as CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID, we need to
232 // adjust the value of initial_timerspec to allow
233 // the changes on the time on these clocks after restart.
234 tspec = tinfo.initial_timerspec;
235 } else {
236 tspec = tinfo.curr_timerspec;
237 }
238 JASSERT(_real_timer_settime(realId, tinfo.flags, &tspec, NULL) == 0)
239 (virtId) (JASSERT_ERRNO);
240 JTRACE("Restoring timer") (realId) (virtId);
241 }
242 }
243}
244
245int

Callers 1

postRestartFunction · 0.45

Calls 5

_real_timer_createFunction · 0.85
beginMethod · 0.80
endMethod · 0.80
updateMappingMethod · 0.45

Tested by

no test coverage detected