diff options
Diffstat (limited to 'src/cpu/minor/cpu.hh')
-rw-r--r-- | src/cpu/minor/cpu.hh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/cpu/minor/cpu.hh b/src/cpu/minor/cpu.hh index dad015e89..4e4762390 100644 --- a/src/cpu/minor/cpu.hh +++ b/src/cpu/minor/cpu.hh @@ -50,6 +50,7 @@ #include "cpu/minor/stats.hh" #include "cpu/base.hh" #include "cpu/simple_thread.hh" +#include "enums/ThreadPolicy.hh" #include "params/MinorCPU.hh" namespace Minor @@ -109,6 +110,8 @@ class MinorCPU : public BaseCPU }; + /** Thread Scheduling Policy (RoundRobin, Random, etc) */ + Enums::ThreadPolicy threadPolicy; protected: /** Return a reference to the data port. */ MasterPort &getDataPort() override; @@ -162,6 +165,26 @@ class MinorCPU : public BaseCPU void activateContext(ThreadID thread_id) override; void suspendContext(ThreadID thread_id) override; + /** Thread scheduling utility functions */ + std::vector<ThreadID> roundRobinPriority(ThreadID priority) + { + std::vector<ThreadID> prio_list; + for (ThreadID i = 1; i <= numThreads; i++) { + prio_list.push_back((priority + i) % numThreads); + } + return prio_list; + } + + std::vector<ThreadID> randomPriority() + { + std::vector<ThreadID> prio_list; + for (ThreadID i = 0; i < numThreads; i++) { + prio_list.push_back(i); + } + std::random_shuffle(prio_list.begin(), prio_list.end()); + return prio_list; + } + /** Interface for stages to signal that they have become active after * a callback or eventq event where the pipeline itself may have * already been idled. The stage argument should be from the |