Deleted Added
sdiff udiff text old ( 13180:79e680f62779 ) new ( 13182:9e030f636a8c )
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

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

29
30#include "systemc/core/scheduler.hh"
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
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),
46 starvationEvent(this, false, StarvationPriority),
47 _started(false), _paused(false), _stopped(false), _stopNow(false),
48 maxTickEvent(this, false, MaxTickPriority),
49 _numCycles(0), _changeStamp(0), _current(nullptr), initDone(false),
50 runOnce(false), readyList(nullptr)
51{}
52
53Scheduler::~Scheduler()

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

179 } else {
180 _current->popListNode();
181 // Switch to whatever Fiber is supposed to run this process. All
182 // Fibers which aren't running should be parked at this line.
183 _current->fiber()->run();
184 // If the current process needs to be manually started, start it.
185 if (_current && _current->needsStart()) {
186 _current->needsStart(false);
187 _current->run();
188 }
189 }
190 if (_current && _current->excWrapper) {
191 // Make sure this isn't a method process.
192 assert(!_current->needsStart());
193 auto ew = _current->excWrapper;
194 _current->excWrapper = nullptr;
195 ew->throw_it();

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

331}
332
333void
334Scheduler::pause()
335{
336 _paused = true;
337 kernel->status(::sc_core::SC_PAUSED);
338 runOnce = false;
339 scMain->run();
340}
341
342void
343Scheduler::stop()
344{
345 _stopped = true;
346 kernel->stop();
347
348 clear();
349
350 runOnce = false;
351 scMain->run();
352}
353
354void
355Scheduler::start(Tick max_tick, bool run_to_time)
356{
357 // We should be running from sc_main. Keep track of that Fiber to return
358 // to later.
359 scMain = Fiber::currentFiber();

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

380 if (pauseEvent.scheduled())
381 deschedule(&pauseEvent);
382 if (stopEvent.scheduled())
383 deschedule(&stopEvent);
384 if (maxTickEvent.scheduled())
385 deschedule(&maxTickEvent);
386 if (starvationEvent.scheduled())
387 deschedule(&starvationEvent);
388}
389
390void
391Scheduler::oneCycle()
392{
393 runOnce = true;
394 scheduleReadyEvent();
395 start(::MaxTick, false);

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

400{
401 if (pauseEvent.scheduled())
402 return;
403
404 schedule(&pauseEvent);
405}
406
407void
408Scheduler::scheduleStop(bool finish_delta)
409{
410 if (stopEvent.scheduled())
411 return;
412
413 if (!finish_delta) {
414 _stopNow = true;
415 // If we're not supposed to finish the delta cycle, flush all
416 // pending activity.
417 clear();
418 }
419 schedule(&stopEvent);
420}
421
422Scheduler scheduler;
423
424} // namespace sc_gem5