X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fsim%2Fsystem.hh;h=aa89866bd591d5e0d836502818481432cf3635d9;hb=931405da2f8828c23463d83f0b77b551d633565c;hp=197d9027b01ed8b8c15397bbdb2d6b83e4a32146;hpb=f0fef8f850b0c5aa73337ca11b26169163b2b2e1;p=gem5.git diff --git a/src/sim/system.hh b/src/sim/system.hh index 197d9027b..aa89866bd 100644 --- a/src/sim/system.hh +++ b/src/sim/system.hh @@ -87,16 +87,23 @@ class System : public SimObject PCEventQueue pcEventQueue; std::vector threadContexts; - int numcpus; + int _numContexts; - int getNumCPUs() + ThreadContext *getThreadContext(ThreadID tid) { - if (numcpus != threadContexts.size()) - panic("cpu array not fully populated!"); + return threadContexts[tid]; + } - return numcpus; + int numContexts() + { + assert(_numContexts == (int)threadContexts.size()); + return _numContexts; } + /** Return number of running (non-halted) thread contexts in + * system. These threads could be Active or Suspended. */ + int numRunningContexts(); + #if FULL_SYSTEM Platform *platform; uint64_t init_param; @@ -125,6 +132,21 @@ class System : public SimObject int page_ptr; + protected: + uint64_t next_PID; + + public: + uint64_t allocatePID() + { + return next_PID++; + } + + /** Amount of physical memory that is still free */ + Addr freeMemSize(); + + /** Amount of physical memory that exists */ + Addr memSize(); + #endif // FULL_SYSTEM @@ -210,8 +232,8 @@ class System : public SimObject #endif // FULL_SYSTEM - int registerThreadContext(ThreadContext *tc, int tcIndex); - void replaceThreadContext(ThreadContext *tc, int tcIndex); + int registerThreadContext(ThreadContext *tc, int assigned=-1); + void replaceThreadContext(ThreadContext *tc, int context_id); void serialize(std::ostream &os); void unserialize(Checkpoint *cp, const std::string §ion);