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

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

191 if (starved() && !runToTime)
192 scheduleStarvationEvent();
193
194 // The delta phase.
195 for (auto &e: deltas)
196 e->run();
197 deltas.clear();
198
199 if (runOnce) {
200 eq->reschedule(&maxTickEvent, eq->getCurTick());
201 runOnce = false;
202 }
199 if (runOnce)
200 schedulePause();
201}
202
203void
204Scheduler::update()
205{
206 Channel *channel = updateList.getNext();
207 while (channel) {
208 channel->popListNode();

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

213
214void
215Scheduler::pause()
216{
217 _paused = true;
218 kernel->status(::sc_core::SC_PAUSED);
219 runOnce = false;
220 scMain->run();
223
224 // If the ready event is supposed to run now, run it inline so that it
225 // preempts any delta notifications which were scheduled while we were
226 // paused.
227 if (readyEvent.scheduled()) {
228 eq->deschedule(&readyEvent);
229 runReady();
230 }
221}
222
223void
224Scheduler::stop()
225{
226 _stopped = true;
227 kernel->stop();
228 runOnce = false;

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

283void
284Scheduler::scheduleStop(bool finish_delta)
285{
286 if (stopEvent.scheduled())
287 return;
288
289 if (!finish_delta) {
290 // If we're not supposed to finish the delta cycle, flush the list
301 // of ready processes and scheduled updates.
291 // of ready processes, scheduled updates, and delta notifications.
292 Process *p;
293 while ((p = readyList.getNext()))
294 p->popListNode();
295 Channel *c;
296 while ((c = updateList.getNext()))
297 c->popListNode();
298 for (auto &e: deltas)
299 e->deschedule();
300 deltas.clear();
301 }
302 eq->schedule(&stopEvent, eq->getCurTick());
303}
304
305Scheduler scheduler;
306
307} // namespace sc_gem5