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

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

37
38namespace sc_gem5
39{
40
41Scheduler::Scheduler() :
42 eq(nullptr), readyEvent(this, false, ReadyPriority),
43 pauseEvent(this, false, PausePriority),
44 stopEvent(this, false, StopPriority),
45 scMain(nullptr), _started(false), _paused(false), _stopped(false),
46 maxTickEvent(this, false, MaxTickPriority),
47 _numCycles(0), _current(nullptr), initReady(false)
48{}
49
50void
51Scheduler::prepareForInit()
52{
53 for (Process *p = toFinalize.getNext(); p; p = toFinalize.getNext()) {

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

138
139void
140Scheduler::scheduleReadyEvent()
141{
142 // Schedule the evaluate and update phases.
143 if (!readyEvent.scheduled()) {
144 panic_if(!eq, "Need to schedule ready, but no event manager.\n");
145 eq->schedule(&readyEvent, eq->getCurTick());
146 }
147}
148
149void
150Scheduler::runReady()
151{
152 bool empty = readyList.empty();
153
154 // The evaluation phase.
155 do {
156 yield();
157 } while (!readyList.empty());
158
159 if (!empty)
160 _numCycles++;
161
162 // The update phase.
163 update();
164
165 // The delta phase will happen naturally through the event queue.
166}
167
168void
169Scheduler::update()
170{
171 Channel *channel = updateList.getNext();
172 while (channel) {

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

197{
198 // We should be running from sc_main. Keep track of that Fiber to return
199 // to later.
200 scMain = Fiber::currentFiber();
201
202 _started = true;
203 _paused = false;
204 _stopped = false;
205
206 maxTick = max_tick;
207
208 if (initReady) {
209 kernel->status(::sc_core::SC_RUNNING);
210 eq->schedule(&maxTickEvent, maxTick);
211 }
212
213 // Return to gem5 to let it run events, etc.
214 Fiber::primaryFiber()->run();
215
216 if (pauseEvent.scheduled())
217 eq->deschedule(&pauseEvent);
218 if (stopEvent.scheduled())
219 eq->deschedule(&stopEvent);
220 if (maxTickEvent.scheduled())
221 eq->deschedule(&maxTickEvent);
222}
223
224void
225Scheduler::schedulePause()
226{
227 if (pauseEvent.scheduled())
228 return;
229

--- 25 unchanged lines hidden ---