scheduler.cc (13064:e06421881cec) scheduler.cc (13067:3d6ef32002ef)
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) ---

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),
48 maxTickEvent(this, false, MaxTickPriority),
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) ---

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),
48 maxTickEvent(this, false, MaxTickPriority),
49 _numCycles(0), _current(nullptr), initReady(false),
49 _numCycles(0), _current(nullptr), initDone(false),
50 runOnce(false)
51{}
52
53void
50 runOnce(false)
51{}
52
53void
54Scheduler::prepareForInit()
54Scheduler::initPhase()
55{
56 for (Process *p = toFinalize.getNext(); p; p = toFinalize.getNext()) {
57 p->finalize();
58 p->popListNode();
59 }
60
61 for (Process *p = initList.getNext(); p; p = initList.getNext()) {
62 p->finalize();
63 p->popListNode();
64 p->ready();
65 }
66
55{
56 for (Process *p = toFinalize.getNext(); p; p = toFinalize.getNext()) {
57 p->finalize();
58 p->popListNode();
59 }
60
61 for (Process *p = initList.getNext(); p; p = initList.getNext()) {
62 p->finalize();
63 p->popListNode();
64 p->ready();
65 }
66
67 update();
68
69 for (auto &e: deltas)
70 e->run();
71 deltas.clear();
72
67 for (auto ets: eventsToSchedule)
68 eq->schedule(ets.first, ets.second);
69 eventsToSchedule.clear();
70
71 if (_started)
72 eq->schedule(&maxTickEvent, maxTick);
73
73 for (auto ets: eventsToSchedule)
74 eq->schedule(ets.first, ets.second);
75 eventsToSchedule.clear();
76
77 if (_started)
78 eq->schedule(&maxTickEvent, maxTick);
79
74 initReady = true;
80 initDone = true;
75}
76
77void
78Scheduler::reg(Process *p)
79{
81}
82
83void
84Scheduler::reg(Process *p)
85{
80 if (initReady) {
86 if (initDone) {
81 // If we're past initialization, finalize static sensitivity.
82 p->finalize();
83 // Mark the process as ready.
84 p->ready();
85 } else {
86 // Otherwise, record that this process should be initialized once we
87 // get there.
88 initList.pushLast(p);
89 }
90}
91
92void
93Scheduler::dontInitialize(Process *p)
94{
87 // If we're past initialization, finalize static sensitivity.
88 p->finalize();
89 // Mark the process as ready.
90 p->ready();
91 } else {
92 // Otherwise, record that this process should be initialized once we
93 // get there.
94 initList.pushLast(p);
95 }
96}
97
98void
99Scheduler::dontInitialize(Process *p)
100{
95 if (initReady) {
101 if (initDone) {
96 // Pop this process off of the ready list.
97 p->popListNode();
98 } else {
99 // Push this process onto the list of processes which still need
100 // their static sensitivity to be finalized. That implicitly pops it
101 // off the list of processes to be initialized/marked ready.
102 toFinalize.pushLast(p);
103 }

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

241 _stopped = false;
242 runToTime = run_to_time;
243
244 maxTick = max_tick;
245
246 if (starved() && !runToTime)
247 return;
248
102 // Pop this process off of the ready list.
103 p->popListNode();
104 } else {
105 // Push this process onto the list of processes which still need
106 // their static sensitivity to be finalized. That implicitly pops it
107 // off the list of processes to be initialized/marked ready.
108 toFinalize.pushLast(p);
109 }

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

247 _stopped = false;
248 runToTime = run_to_time;
249
250 maxTick = max_tick;
251
252 if (starved() && !runToTime)
253 return;
254
249 if (initReady) {
255 if (initDone) {
250 kernel->status(::sc_core::SC_RUNNING);
251 eq->schedule(&maxTickEvent, maxTick);
252 }
253
254 // Return to gem5 to let it run events, etc.
255 Fiber::primaryFiber()->run();
256
257 if (pauseEvent.scheduled())

--- 50 unchanged lines hidden ---
256 kernel->status(::sc_core::SC_RUNNING);
257 eq->schedule(&maxTickEvent, maxTick);
258 }
259
260 // Return to gem5 to let it run events, etc.
261 Fiber::primaryFiber()->run();
262
263 if (pauseEvent.scheduled())

--- 50 unchanged lines hidden ---