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->clearFlags(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->getFlags(Event::AutoDelete)); // would be silly
204 return event;
205 }
206 } else {
207 event->clearFlags(Event::Squashed);
208 }
209
210 if (event->getFlags(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 SERIALIZE_ENUM(_flags);
222}
223
224void
225Event::unserialize(Checkpoint *cp, const string &section)
226{
227 if (scheduled())
228 mainEventQueue.deschedule(this);
229
230 UNSERIALIZE_SCALAR(_when);
231 UNSERIALIZE_SCALAR(_priority);
232
233 // need to see if original event was in a scheduled, unsquashed
234 // state, but don't want to restore those flags in the current
235 // object itself (since they aren't immediately true)
236 UNSERIALIZE_ENUM(_flags);
237 bool wasScheduled = (_flags & Scheduled) && !(_flags & Squashed);
238 _flags &= ~(Squashed | Scheduled);
239
240 if (wasScheduled) {
241 DPRINTF(Config, "rescheduling at %d\n", _when);
242 mainEventQueue.schedule(this, _when);
243 }
244}
245
246void
247EventQueue::serialize(ostream &os)
248{
249 std::list<Event *> eventPtrs;
250
251 int numEvents = 0;
252 Event *nextBin = head;
253 while (nextBin) {
254 Event *nextInBin = nextBin;
255
256 while (nextInBin) {
257 if (nextInBin->getFlags(Event::AutoSerialize)) {
258 eventPtrs.push_back(nextInBin);
259 paramOut(os, csprintf("event%d", numEvents++),
260 nextInBin->name());
261 }
262 nextInBin = nextInBin->nextInBin;
263 }
264
265 nextBin = nextBin->nextBin;

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

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