scheduler.hh (13154:f86c71dac456) scheduler.hh (13176:76f52e8d8c6a)
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

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

192
193 // Schedule an update for a given channel.
194 void requestUpdate(Channel *c);
195
196 // Run the given process immediately, preempting whatever may be running.
197 void
198 runNow(Process *p)
199 {
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

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

192
193 // Schedule an update for a given channel.
194 void requestUpdate(Channel *c);
195
196 // Run the given process immediately, preempting whatever may be running.
197 void
198 runNow(Process *p)
199 {
200 // This function may put a process on the wrong list, ie a method on
201 // the process list or vice versa. That's fine since that's just a
202 // performance optimization, and the important thing here is how the
203 // processes are ordered.
204
200 // If a process is running, schedule it/us to run again.
201 if (_current)
205 // If a process is running, schedule it/us to run again.
206 if (_current)
202 readyList.pushFirst(_current);
207 readyList->pushFirst(_current);
203 // Schedule p to run first.
208 // Schedule p to run first.
204 readyList.pushFirst(p);
209 readyList->pushFirst(p);
205 yield();
206 }
207
208 // Set an event queue for scheduling events.
209 void setEventQueue(EventQueue *_eq) { eq = _eq; }
210
211 // Get the current time according to gem5.
212 Tick getCurTick() { return eq ? eq->getCurTick() : 0; }

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

285 // systemc simulation. Also the spec lists what specific types of pending
286 // activity needs to be counted, which obviously doesn't include gem5
287 // events.
288
289 // Return whether there's pending systemc activity at this time.
290 bool
291 pendingCurr()
292 {
210 yield();
211 }
212
213 // Set an event queue for scheduling events.
214 void setEventQueue(EventQueue *_eq) { eq = _eq; }
215
216 // Get the current time according to gem5.
217 Tick getCurTick() { return eq ? eq->getCurTick() : 0; }

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

290 // systemc simulation. Also the spec lists what specific types of pending
291 // activity needs to be counted, which obviously doesn't include gem5
292 // events.
293
294 // Return whether there's pending systemc activity at this time.
295 bool
296 pendingCurr()
297 {
293 return !readyList.empty() || !updateList.empty() || !deltas.empty();
298 return !readyListMethods.empty() || !readyListThreads.empty() ||
299 !updateList.empty() || !deltas.empty();
294 }
295
296 // Return whether there are pending timed notifications or timeouts.
297 bool
298 pendingFuture()
299 {
300 return !timeSlots.empty();
301 }

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

371 void stop();
372 EventWrapper<Scheduler, &Scheduler::pause> pauseEvent;
373 EventWrapper<Scheduler, &Scheduler::stop> stopEvent;
374 Fiber *scMain;
375
376 bool
377 starved()
378 {
300 }
301
302 // Return whether there are pending timed notifications or timeouts.
303 bool
304 pendingFuture()
305 {
306 return !timeSlots.empty();
307 }

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

377 void stop();
378 EventWrapper<Scheduler, &Scheduler::pause> pauseEvent;
379 EventWrapper<Scheduler, &Scheduler::stop> stopEvent;
380 Fiber *scMain;
381
382 bool
383 starved()
384 {
379 return (readyList.empty() && updateList.empty() && deltas.empty() &&
385 return (readyListMethods.empty() && readyListThreads.empty() &&
386 updateList.empty() && deltas.empty() &&
380 (timeSlots.empty() || timeSlots.begin()->first > maxTick) &&
381 initList.empty());
382 }
383 EventWrapper<Scheduler, &Scheduler::pause> starvationEvent;
384 void scheduleStarvationEvent();
385
386 bool _started;
387 bool _paused;

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

405 Process *_current;
406
407 bool initDone;
408 bool runToTime;
409 bool runOnce;
410
411 ProcessList initList;
412 ProcessList toFinalize;
387 (timeSlots.empty() || timeSlots.begin()->first > maxTick) &&
388 initList.empty());
389 }
390 EventWrapper<Scheduler, &Scheduler::pause> starvationEvent;
391 void scheduleStarvationEvent();
392
393 bool _started;
394 bool _paused;

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

412 Process *_current;
413
414 bool initDone;
415 bool runToTime;
416 bool runOnce;
417
418 ProcessList initList;
419 ProcessList toFinalize;
413 ProcessList readyList;
414
420
421 ProcessList *readyList;
422 ProcessList readyListMethods;
423 ProcessList readyListThreads;
424
415 ChannelList updateList;
416
417 std::map<::Event *, Tick> eventsToSchedule;
418};
419
420extern Scheduler scheduler;
421
422inline void
423Scheduler::TimeSlot::process()
424{
425 while (!events.empty())
426 events.front()->run();
427 scheduler.completeTimeSlot(this);
428}
429
430} // namespace sc_gem5
431
432#endif // __SYSTEMC_CORE_SCHEDULER_H__
425 ChannelList updateList;
426
427 std::map<::Event *, Tick> eventsToSchedule;
428};
429
430extern Scheduler scheduler;
431
432inline void
433Scheduler::TimeSlot::process()
434{
435 while (!events.empty())
436 events.front()->run();
437 scheduler.completeTimeSlot(this);
438}
439
440} // namespace sc_gem5
441
442#endif // __SYSTEMC_CORE_SCHEDULER_H__