Deleted Added
sdiff udiff text old ( 13182:9e030f636a8c ) new ( 13186:1ebc6c729311 )
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

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

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 _started(false), _paused(false), _stopped(false), _stopNow(false),
50 maxTickEvent(this, false, MaxTickPriority),
51 _numCycles(0), _changeStamp(0), _current(nullptr), initDone(false),
52 runOnce(false), readyList(nullptr)
53{}
54
55Scheduler::~Scheduler()
56{
57 // Clear out everything that belongs to us to make sure nobody tries to

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

118 }
119
120 for (Process *p = initList.getNext(); p; p = initList.getNext()) {
121 p->finalize();
122 p->popListNode();
123 p->ready();
124 }
125
126 update();
127
128 while (!deltas.empty())
129 deltas.front()->run();
130
131 for (auto ets: eventsToSchedule)
132 eq->schedule(ets.first, ets.second);
133 eventsToSchedule.clear();
134
135 if (_started) {
136 if (!runToTime && starved())
137 scheduleStarvationEvent();
138 kernel->status(::sc_core::SC_RUNNING);
139 }
140
141 initDone = true;
142}
143
144void
145Scheduler::reg(Process *p)
146{
147 if (initDone) {
148 // If we're past initialization, finalize static sensitivity.
149 p->finalize();

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

306 if (!empty) {
307 _numCycles++;
308 _changeStamp++;
309 }
310
311 if (_stopNow)
312 return;
313
314 // The update phase.
315 update();
316
317 // The delta phase.
318 while (!deltas.empty())
319 deltas.front()->run();
320
321 if (!runToTime && starved())
322 scheduleStarvationEvent();
323
324 if (runOnce)
325 schedulePause();
326}
327
328void
329Scheduler::update()
330{
331 Channel *channel = updateList.getNext();
332 while (channel) {
333 channel->popListNode();
334 channel->update();
335 channel = updateList.getNext();
336 }
337}
338
339void
340Scheduler::pause()
341{
342 _paused = true;
343 kernel->status(::sc_core::SC_PAUSED);
344 runOnce = false;
345 if (scMain && !scMain->finished())
346 scMain->run();
347}
348
349void
350Scheduler::stop()
351{
352 _stopped = true;
353 kernel->stop();
354
355 clear();
356
357 runOnce = false;
358 if (scMain && !scMain->finished())
359 scMain->run();
360}
361
362void
363Scheduler::start(Tick max_tick, bool run_to_time)
364{
365 // We should be running from sc_main. Keep track of that Fiber to return
366 // to later.
367 scMain = Fiber::currentFiber();
368
369 _started = true;
370 _paused = false;
371 _stopped = false;
372 runToTime = run_to_time;
373
374 maxTick = max_tick;
375 lastReadyTick = getCurTick();
376
377 if (initDone) {
378 if (!runToTime && starved())
379 scheduleStarvationEvent();

--- 110 unchanged lines hidden ---