eventq.cc (5768:ba6f2477d870) eventq.cc (5769:e53bdd0e4bf1)
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;
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);
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()) {
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
203 assert(!event->flags.isSet(Event::AutoDelete)); // would be silly
204 return event;
205 }
206 } else {
204 return event;
205 }
206 } else {
207 event->clearFlags(Event::Squashed);
207 event->flags.clear(Event::Squashed);
208 }
209
208 }
209
210 if (event->getFlags(Event::AutoDelete) && !event->scheduled())
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);
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);
221 short _flags = flags;
222 SERIALIZE_SCALAR(_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)
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)
236 UNSERIALIZE_ENUM(_flags);
237 bool wasScheduled = (_flags & Scheduled) && !(_flags & Squashed);
238 _flags &= ~(Squashed | Scheduled);
237 short _flags;
238 UNSERIALIZE_SCALAR(_flags);
239 flags = _flags;
239
240
241 bool wasScheduled = flags.isSet(Scheduled) && !flags.isSet(Squashed);
242 flags.clear(Squashed | Scheduled);
243
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) {
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) {
257 if (nextInBin->getFlags(Event::AutoSerialize)) {
261 if (nextInBin->flags.isSet(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());
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());
392 cprintf("Flags: %#x\n", _flags);
396 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}
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}