Deleted Added
sdiff udiff text old ( 13244:deedec45898f ) new ( 13245:c666c5d4996b )
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

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

31
32#include "base/fiber.hh"
33#include "base/logging.hh"
34#include "sim/eventq.hh"
35#include "systemc/core/kernel.hh"
36#include "systemc/ext/core/sc_main.hh"
37#include "systemc/ext/utils/sc_report.hh"
38#include "systemc/ext/utils/sc_report_handler.hh"
39
40namespace sc_gem5
41{
42
43Scheduler::Scheduler() :
44 eq(nullptr), readyEvent(this, false, ReadyPriority),
45 pauseEvent(this, false, PausePriority),
46 stopEvent(this, false, StopPriority),
47 scMain(nullptr), _throwToScMain(nullptr),
48 starvationEvent(this, false, StarvationPriority),
49 _elaborationDone(false), _started(false), _stopNow(false),
50 _status(StatusOther), maxTickEvent(this, false, MaxTickPriority),
51 _numCycles(0), _changeStamp(0), _current(nullptr), initDone(false),
52 runOnce(false)
53{}
54
55Scheduler::~Scheduler()
56{
57 // Clear out everything that belongs to us to make sure nobody tries to
58 // clear themselves out after the scheduler goes away.
59 clear();
60}

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

81 if (pauseEvent.scheduled())
82 deschedule(&pauseEvent);
83 if (stopEvent.scheduled())
84 deschedule(&stopEvent);
85 if (starvationEvent.scheduled())
86 deschedule(&starvationEvent);
87 if (maxTickEvent.scheduled())
88 deschedule(&maxTickEvent);
89
90 Process *p;
91 while ((p = initList.getNext()))
92 p->popListNode();
93 while ((p = readyListMethods.getNext()))
94 p->popListNode();
95 while ((p = readyListThreads.getNext()))
96 p->popListNode();

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

129 if (!runToTime && starved())
130 scheduleStarvationEvent();
131 kernel->status(::sc_core::SC_RUNNING);
132 }
133
134 initDone = true;
135
136 status(StatusOther);
137}
138
139void
140Scheduler::reg(Process *p)
141{
142 if (initDone) {
143 // If not marked as dontInitialize, mark as ready.
144 if (!p->dontInitialize())

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

258 if (readyEvent.scheduled())
259 deschedule(&readyEvent);
260 }
261}
262
263void
264Scheduler::runReady()
265{
266 bool empty = readyListMethods.empty() && readyListThreads.empty();
267 lastReadyTick = getCurTick();
268
269 // The evaluation phase.
270 do {
271 yield();
272 } while (getNextReady());
273
274 if (!empty) {
275 _numCycles++;
276 _changeStamp++;
277 }
278
279 if (_stopNow) {
280 status(StatusOther);
281 return;
282 }
283
284 runUpdate();
285 runDelta();
286
287 if (!runToTime && starved())
288 scheduleStarvationEvent();
289
290 if (runOnce)
291 schedulePause();
292

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

362
363 if (initDone) {
364 if (!runToTime && starved())
365 scheduleStarvationEvent();
366 kernel->status(::sc_core::SC_RUNNING);
367 }
368
369 schedule(&maxTickEvent, maxTick);
370
371 // Return to gem5 to let it run events, etc.
372 Fiber::primaryFiber()->run();
373
374 if (pauseEvent.scheduled())
375 deschedule(&pauseEvent);
376 if (stopEvent.scheduled())
377 deschedule(&stopEvent);

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

424 _stopNow = true;
425 // If we're not supposed to finish the delta cycle, flush all
426 // pending activity.
427 clear();
428 }
429 schedule(&stopEvent);
430}
431
432Scheduler scheduler;
433
434namespace {
435
436void
437throwingReportHandler(const ::sc_core::sc_report &r,
438 const ::sc_core::sc_actions &)
439{

--- 37 unchanged lines hidden ---