1/* 2 * Copyright (c) 2000-2005 The Regents of The University of Michigan 3 * Copyright (c) 2008 The Hewlett-Packard Development Company 4 * Copyright (c) 2013 Advanced Micro Devices, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are
--- 269 unchanged lines hidden (view full) ---
278 flags.clear(Squashed | Scheduled); 279 } else { 280 DPRINTF(Checkpoint, "Event '%s' need to be scheduled @%d\n", 281 name(), _when); 282 } 283} 284 285void
|
286EventQueue::serialize(CheckpointOut &cp) const
287{
288 std::list<Event *> eventPtrs;
289
290 int numEvents = 0;
291 Event *nextBin = head;
292 while (nextBin) {
293 Event *nextInBin = nextBin;
294
295 while (nextInBin) {
296 if (nextInBin->flags.isSet(Event::AutoSerialize)) {
297 eventPtrs.push_back(nextInBin);
298 paramOut(cp, csprintf("event%d", numEvents++),
299 nextInBin->name());
300 }
301 nextInBin = nextInBin->nextInBin;
302 }
303
304 nextBin = nextBin->nextBin;
305 }
306
307 SERIALIZE_SCALAR(numEvents);
308
309 for (Event *ev : eventPtrs)
310 ev->serializeSection(cp, ev->name());
311}
312
313void
314EventQueue::unserialize(CheckpointIn &cp)
315{
316 int numEvents;
317 UNSERIALIZE_SCALAR(numEvents);
318
319 std::string eventName;
320 for (int i = 0; i < numEvents; i++) {
321 // get the pointer value associated with the event
322 paramIn(cp, csprintf("event%d", i), eventName);
323
324 // create the event based on its pointer value
325 Serializable *obj(Serializable::create(cp, eventName));
326 Event *event(dynamic_cast<Event *>(obj));
327 fatal_if(!event,
328 "Event queue unserialized something that wasn't an event.\n");
329
330 checkpointReschedule(event);
331 }
332}
333
334void
|
286EventQueue::checkpointReschedule(Event *event) 287{ 288 // It's safe to call insert() directly here since this method 289 // should only be called when restoring from a checkpoint (which 290 // happens before thread creation). 291 if (event->flags.isSet(Event::Scheduled)) 292 insert(event); 293}
--- 149 unchanged lines hidden --- |