gem5线程相关的类—SimpleThread类,ThreadState类(src/cpu/thread_state.*)

一、总体功能
1.ThreadState类:保存CPU模型中需要使用的线程状态;包括进程指针、内存对象指针、状态指针等;
2.SimpleThread:兼具ThreadState和ThreadContext类型接口功能,提供了functional simulation全系统模拟时,所有可能状态;

二、类
1.类ThreadState
(1)成员变量
  • Counter numInst:提交的指令数目;
  • Stats::Scalar numInsts :提交指令数的统计量;
  • Counter numOp:提交的操作数(包括微操作)
  • Stats::Scalar numOps:提交操作的统计量
  • Stats::Scalar numMemRefs:内存引用统计量
  • Counter numLoad:模拟的load操作;
  • Counter startNumLoad: 线程运行之前,已经模拟的load操作数;
  • ThreadContext::Status _status:线程状态;  
  • BaseCPU *baseCpu:指向CPU对象的指针;
  • int _contextId:system wide HW context id(CPU id)
  • ThreadID _threadId:Index of hardware thread context on the CPU that this represents,表示CPU硬件线程ID;
  • Tick lastActivate:该线程上一次active tick;
  • Tick lastSuspend:该线程上一次suspend tick;
  • FunctionProfile *profile:
  • ProfileNode *profileNode  
  • Addr profilePC  
  • EndQuiesceEvent *quiesceEvent   
  • TheISA::Kernel::Statistics *kernelStats   
  • Process *process:指向进程对象的指针;
  • PortProxy *physProxy:functional访问物理地址时,端口代理;
  • FSTranslatingPortProxy *virtProxy:翻译端口代理对象指针,访问虚拟地址时使用;
  • SETranslatingPortProxy *proxy:SE模式下,翻译端口代理;
  • Counter funcExeInst:已经执行的指令数;
  • unsigned storeCondFailures:Count failed store conditionals so we can warn of apparent application deadlock situations(记录存储conditionals失败的次数,从而在应用发生明显死锁的情况下给出警告)
  • typedef ThreadContext::Status Status:线程状态
(2)成员函数
成员函数比较简单,使用时,直接查看源文件即可^_^

2.类SimpleThread
(1)数据成员
  • typedef TheISA::MachInst MachInst
  • typedef TheISA::MiscReg MiscReg   
  • typedef TheISA::FloatReg FloatReg  
  • typedef TheISA::FloatRegBits FloatRegBits  
  • typedef TheISA::CCReg CCReg
  • typedef ThreadContext::Status Status:线程状态  
  • union floatRegs:浮点寄存器文件
    ① FloatReg f[TheISA::NumFloatRegs]:浮点寄存器文件
    ②FloatRegBits i[TheISA::NumFloatRegs]
  • TheISA::CCReg ccRegs[TheISA::NumCCRegs]:Conditionals Code Register   
  • TheISA::ISA *const isa:表明当前ISA  
  • TheISA::PCState _pcState:PC寄存器状态对象;   
  • bool predicate:指令已经被执行?或者断言错误?  
  • System *system:系统对象指针;
  • ProxyThreadContext<SimpleThread> *tc:ThreadContext类型对象代理,可调用SimpleThread对象接口;
  • TheISA::TLB *itb:指令页表缓存对象指针;
  • TheISA::TLB *dtb:数据页表缓存对象指针
  • TheISA::Decoder decoder:译码器对象指针;
(2)函数成员
  • 构造函数
    ①fs模式下:SimpleThread(BaseCPU *_cpu, int _thread_num, System *_system,TheISA::TLB *_itb, TheISA::TLB *_dtb, TheISA::ISA *_isa,bool use_kernel_stats = true)
    ②se模式下:SimpleThread(BaseCPU *_cpu, int _thread_num, System *_system,Process *_process, TheISA::TLB *_itb, TheISA::TLB *_dtb,TheISA::ISA *_isa)
  • virtual void takeOverFrom(ThreadContext *oldContext)  
  • void regStats(const std::string &name)   
  • void copyState(ThreadContext *oldContext)  
  • void serialize(std::ostream &os)  
  • void unserialize(Checkpoint *cp, const std::string &section)  
  • void startup() 
  • ThreadContext *getTC()  
  • void demapPage(Addr vaddr, uint64_t asn)  
  • void demapInstPage(Addr vaddr, uint64_t asn)  
  • void demapDataPage(Addr vaddr, uint64_t asn)   
  • void dumpFuncProfile()  
  • Fault hwrei()  
  • bool simPalCheck(int palFunc)  
  • bool simPalCheck(int palFunc)  
  • TheISA::TLB *getITBPtr()  
  • TheISA::TLB *getDTBPtr()  
  • CheckerCPU *getCheckerCpuPtr()  
  • TheISA::Decoder *getDecoderPtr()  
  • System *getSystemPtr()  
  • Status status()  
  • void setStatus(Status newStatus)  
  • void activate(Cycles delay = Cycles(1))   
  • void suspend()  
  • void halt()  
  • virtual bool misspeculating()  
  • void copyArchRegs(ThreadContext *tc)  
  • void clearArchRegs()  
  • uint64_t readIntReg(int reg_idx)    
  • FloatReg readFloatReg(int reg_idx)  
  • FloatRegBits readFloatRegBits(int reg_idx)   
  • CCReg readCCReg(int reg_idx)   
  • void setIntReg(int reg_idx, uint64_t val)  
  • void setFloatReg(int reg_idx, FloatReg val)   
  • void setFloatRegBits(int reg_idx, FloatRegBits val)  
  • void setCCReg(int reg_idx, CCReg val)  
  • TheISA::PCState  pcState()   
  • void pcState(const TheISA::PCState &val)  
  • void pcStateNoRecord(const TheISA::PCState &val)   
  • Addr instAddr()    
  • Addr nextInstAddr()   
  • MicroPC microPC()  
  • bool readPredicate()    
  • void setPredicate(bool val)  
  • MiscReg readMiscRegNoEffect(int misc_reg, ThreadID tid = 0)   
  • MiscReg readMiscReg(int misc_reg, ThreadID tid = 0)    
  • void setMiscRegNoEffect(int misc_reg, const MiscReg &val, ThreadID tid = 0)  
  • void setMiscReg(int misc_reg, const MiscReg &val, ThreadID tid = 0)  
  • int flattenIntIndex(int reg)  
  • int  flattenFloatIndex(int reg)   
  • int flattenCCIndex(int reg)  
  • int flattenMiscIndex(int reg)  
  • unsigned readStCondFailures() 
  • void setStCondFailures(unsigned sc_failures)    
  • void syscall(int64_t callnum)  
  • uint64_t readIntRegFlat(int idx)  
  • void setIntRegFlat(int idx, uint64_t val)     
  • FloatReg readFloatRegFlat(int idx)  
  • void setFloatRegFlat(int idx, FloatReg val)  
  • FloatRegBits readFloatRegBitsFlat(int idx)  
  • void setFloatRegBitsFlat(int idx, FloatRegBits val)   
  • CCReg readCCRegFlat(int idx)   
  • void setCCRegFlat(int idx, CCReg val)  
  • CCReg readCCRegFlat(int idx)  
  • void setCCRegFlat(int idx, CCReg val)
ThreadContext/simple thread/thread state/thread proxy等类之间的关系如下:


posted @ 2015-05-24 17:13  cyjseagull  阅读(875)  评论(0编辑  收藏  举报