Deleted Added
sdiff udiff text old ( 12985:ec84697e4e63 ) new ( 12987:97fbdee919d8 )
full compact
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

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

210
211 // Tell the scheduler than an event fired for bookkeeping purposes.
212 void
213 eventHappened()
214 {
215 auto it = pendingTicks.begin();
216 if (--it->second == 0)
217 pendingTicks.erase(it);
218
219 if (starved() && !runToTime)
220 scheduleStarvationEvent();
221 }
222
223 // Pending activity ignores gem5 activity, much like how a systemc
224 // simulation wouldn't know about asynchronous external events (socket IO
225 // for instance) that might happen before time advances in a pure
226 // systemc simulation. Also the spec lists what specific types of pending
227 // activity needs to be counted, which obviously doesn't include gem5
228 // events.

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

275
276 private:
277 typedef const EventBase::Priority Priority;
278 static Priority DefaultPriority = EventBase::Default_Pri;
279
280 static Priority StopPriority = DefaultPriority - 1;
281 static Priority PausePriority = DefaultPriority + 1;
282 static Priority ReadyPriority = DefaultPriority + 2;
283 static Priority StarvationPriority = ReadyPriority;
284 static Priority MaxTickPriority = DefaultPriority + 3;
285
286 EventQueue *eq;
287 std::map<Tick, int> pendingTicks;
288
289 void runReady();
290 EventWrapper<Scheduler, &Scheduler::runReady> readyEvent;
291 void scheduleReadyEvent();
292
293 void pause();
294 void stop();
295 EventWrapper<Scheduler, &Scheduler::pause> pauseEvent;
296 EventWrapper<Scheduler, &Scheduler::stop> stopEvent;
297 Fiber *scMain;
298
299 bool
300 starved()
301 {
302 return (readyList.empty() && updateList.empty() &&
303 (pendingTicks.empty() ||
304 pendingTicks.begin()->first > maxTick) &&
305 initList.empty());
306 }
307 EventWrapper<Scheduler, &Scheduler::pause> starvationEvent;
308 void scheduleStarvationEvent();
309
310 bool _started;
311 bool _paused;
312 bool _stopped;
313
314 Tick maxTick;
315 EventWrapper<Scheduler, &Scheduler::pause> maxTickEvent;
316
317 uint64_t _numCycles;
318
319 Process *_current;
320
321 bool initReady;
322 bool runToTime;
323
324 ProcessList initList;
325 ProcessList toFinalize;
326 ProcessList readyList;
327
328 ChannelList updateList;
329
330 std::map<::Event *, Tick> eventsToSchedule;
331};
332
333extern Scheduler scheduler;
334
335} // namespace sc_gem5
336
337#endif // __SYSTEMC_CORE_SCHEDULER_H__