Deleted Added
sdiff udiff text old ( 5768:ba6f2477d870 ) new ( 5769:e53bdd0e4bf1 )
full compact
1/*
2 * Copyright (c) 2000-2005 The Regents of The University of Michigan
3 * Copyright (c) 2008 The Hewlett-Packard Development Company
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright

--- 168 unchanged lines hidden (view full) ---

177 prev->nextBin = Event::removeItem(event, curr);
178}
179
180Event *
181EventQueue::serviceOne()
182{
183 Event *event = head;
184 Event *next = head->nextInBin;
185 event->flags.clear(Event::Scheduled);
186
187 if (next) {
188 // update the next bin pointer since it could be stale
189 next->nextBin = head->nextBin;
190
191 // pop the stack
192 head = next;
193 } else {
194 // this was the only element on the 'in bin' list, so get rid of
195 // the 'in bin' list and point to the next bin list
196 head = head->nextBin;
197 }
198
199 // handle action
200 if (!event->squashed()) {
201 event->process();
202 if (event->isExitEvent()) {
203 assert(!event->flags.isSet(Event::AutoDelete)); // would be silly
204 return event;
205 }
206 } else {
207 event->flags.clear(Event::Squashed);
208 }
209
210 if (event->flags.isSet(Event::AutoDelete) && !event->scheduled())
211 delete event;
212
213 return NULL;
214}
215
216void
217Event::serialize(std::ostream &os)
218{
219 SERIALIZE_SCALAR(_when);
220 SERIALIZE_SCALAR(_priority);
221 short _flags = flags;
222 SERIALIZE_SCALAR(_flags);
223}
224
225void
226Event::unserialize(Checkpoint *cp, const string &section)
227{
228 if (scheduled())
229 mainEventQueue.deschedule(this);
230
231 UNSERIALIZE_SCALAR(_when);
232 UNSERIALIZE_SCALAR(_priority);
233
234 // need to see if original event was in a scheduled, unsquashed
235 // state, but don't want to restore those flags in the current
236 // object itself (since they aren't immediately true)
237 short _flags;
238 UNSERIALIZE_SCALAR(_flags);
239 flags = _flags;
240
241 bool wasScheduled = flags.isSet(Scheduled) && !flags.isSet(Squashed);
242 flags.clear(Squashed | Scheduled);
243
244 if (wasScheduled) {
245 DPRINTF(Config, "rescheduling at %d\n", _when);
246 mainEventQueue.schedule(this, _when);
247 }
248}
249
250void
251EventQueue::serialize(ostream &os)
252{
253 std::list<Event *> eventPtrs;
254
255 int numEvents = 0;
256 Event *nextBin = head;
257 while (nextBin) {
258 Event *nextInBin = nextBin;
259
260 while (nextInBin) {
261 if (nextInBin->flags.isSet(Event::AutoSerialize)) {
262 eventPtrs.push_back(nextInBin);
263 paramOut(os, csprintf("event%d", numEvents++),
264 nextInBin->name());
265 }
266 nextInBin = nextInBin->nextInBin;
267 }
268
269 nextBin = nextBin->nextBin;

--- 118 unchanged lines hidden (view full) ---

388 // needs to be printed.
389 DPRINTFN("%s event %s @ %d\n", description(), action, when());
390}
391
392void
393Event::dump() const
394{
395 cprintf("Event %s (%s)\n", name(), description());
396 cprintf("Flags: %#x\n", flags);
397#ifdef EVENTQ_DEBUG
398 cprintf("Created: %d\n", whenCreated);
399#endif
400 if (scheduled()) {
401#ifdef EVENTQ_DEBUG
402 cprintf("Scheduled at %d\n", whenScheduled);
403#endif
404 cprintf("Scheduled for %d, priority %d\n", when(), _priority);
405 } else {
406 cprintf("Not Scheduled\n");
407 }
408}