src/Sim/Thread/Thread.cpp

説明を見る。
00001 // 
00002 // Copyright (c) 2005-2008 Kenichi Watanabe.
00003 // Copyright (c) 2005-2008 Yasuhiro Watari.
00004 // Copyright (c) 2005-2008 Hironori Ichibayashi.
00005 // Copyright (c) 2008-2009 Kazuo Horio.
00006 // Copyright (c) 2009-2013 Naruki Kurata.
00007 // Copyright (c) 2005-2013 Ryota Shioya.
00008 // Copyright (c) 2005-2013 Masahiro Goshima.
00009 // 
00010 // This software is provided 'as-is', without any express or implied
00011 // warranty. In no event will the authors be held liable for any damages
00012 // arising from the use of this software.
00013 // 
00014 // Permission is granted to anyone to use this software for any purpose,
00015 // including commercial applications, and to alter it and redistribute it
00016 // freely, subject to the following restrictions:
00017 // 
00018 // 1. The origin of this software must not be misrepresented; you must not
00019 // claim that you wrote the original software. If you use this software
00020 // in a product, an acknowledgment in the product documentation would be
00021 // appreciated but is not required.
00022 // 
00023 // 2. Altered source versions must be plainly marked as such, and must not be
00024 // misrepresented as being the original software.
00025 // 
00026 // 3. This notice may not be removed or altered from any source
00027 // distribution.
00028 // 
00029 // 
00030 
00031 
00032 #include <pch.h>
00033 
00034 #include "Sim/Thread/Thread.h"
00035 
00036 #include "Utility/RuntimeError.h"
00037 #include "Sim/Op/Op.h"
00038 
00039 
00040 using namespace std;
00041 using namespace Onikiri;
00042 
00043 Thread::Thread()
00044 {
00045     m_emulator = 0;
00046     m_core = 0;
00047     m_inorderList = 0;
00048     m_checkpointMaster = 0;
00049     m_memOrderManager = 0;
00050     m_regDepPred = 0;
00051     m_memDepPred = 0;
00052     
00053     m_localTID = TID_INVALID;
00054     m_active = false;
00055     m_serialOpID = 0;
00056 }
00057 
00058 Thread::~Thread()
00059 {
00060     ReleaseParam();
00061 }
00062 
00063 void Thread::Initialize(InitPhase phase)
00064 {
00065     if(phase == INIT_PRE_CONNECTION){
00066         LoadParam();
00067     }
00068     else if(phase == INIT_POST_CONNECTION){
00069 
00070         CheckNodeInitialized( "checkpointMaster",   m_checkpointMaster );
00071         CheckNodeInitialized( "emulator",           m_emulator );
00072         CheckNodeInitialized( "inorderList",        m_inorderList );
00073         CheckNodeInitialized( "memOrderManager",    m_memOrderManager );
00074         CheckNodeInitialized( "checkpointMaster",   m_checkpointMaster );
00075         CheckNodeInitialized( "regDepPred",         m_regDepPred );
00076         CheckNodeInitialized( "memDepPred",         m_memDepPred );
00077         CheckNodeInitialized( "core",               m_core );
00078         CheckNodeInitialized( "recoverer",          m_recoverer );
00079 
00080         // CheckpointedData 
00081         m_fetchPC.Initialize(
00082             m_checkpointMaster, 
00083             CheckpointMaster::SLOT_FETCH
00084         );
00085 
00086         m_retiredOpID.Initialize(
00087             m_checkpointMaster, 
00088             CheckpointMaster::SLOT_FETCH
00089         );
00090         m_retiredOpID.GetCurrent() = 0;
00091     }
00092 }
00093 
00094 bool Thread::IsActive()
00095 {
00096     return m_active;
00097 }
00098 
00099 void Thread::InitializeContext(PC pc)
00100 {
00101     int pcTID = pc.tid;
00102     if( pcTID != GetTID(0) ){
00103         THROW_RUNTIME_ERROR( 
00104             "The TID of 'pc' (%d) and the TID of this 'Thread' (%d) are different", 
00105             pcTID,
00106             GetTID(0)
00107         );
00108     }
00109 
00110     SetFetchPC( pc );
00111 }
00112 
00113 int Thread::GetTID()
00114 {
00115     return GetTID(0);
00116 }
00117 
00118 int Thread::GetTID( const int index )
00119 {
00120     return PhysicalResourceNode::GetTID( index );
00121 }
00122 
00123 void Thread::SetLocalThreadID(int localTID)
00124 {
00125     m_localTID = localTID;
00126 }
00127 
00128 int  Thread::GetLocalThreadID() const
00129 {
00130     return m_localTID;
00131 }
00132 
00133 void Thread::Activate( bool active )
00134 {
00135     m_active = active;
00136 }
00137 
00138 void Thread::SetFetchPC(const PC& pc)
00139 {
00140     ASSERT(
00141         pc.tid == GetTID(0),
00142         "The passed pc has invalid tid."
00143     );
00144     *m_fetchPC = pc;
00145 }
00146 
00147 PC   Thread::GetFetchPC() const
00148 {
00149     return *m_fetchPC;
00150 }
00151 
00152 u64  Thread::GetOpRetiredID()
00153 {
00154     return *m_retiredOpID;
00155 }
00156 
00157 u64  Thread::GetOpSerialID()
00158 {
00159     return m_serialOpID;
00160 }
00161 
00162 void Thread::AddOpRetiredID(u64 num)
00163 {
00164     *m_retiredOpID = *m_retiredOpID + num;
00165 }
00166 
00167 void Thread::AddOpSerialID(u64 num)
00168 {
00169     m_serialOpID += num;
00170 }
00171 
00172 void Thread::SetThreadCount(const int count)
00173 {
00174     if( count != 1 ){
00175         THROW_RUNTIME_ERROR( "The tid count of the 'Thread' class must be 1" );
00176     }
00177     PhysicalResourceNode::SetThreadCount( count );
00178 }
00179 

Onikiri2に対してTue Jun 18 14:34:26 2013に生成されました。  doxygen 1.4.7