クラス sc_core::sc_thread_process

#include <sc_thread_process.h>

sc_core::sc_thread_processに対する継承グラフ

Inheritance graph
[凡例]

すべてのメンバ一覧

Public メソッド

 sc_thread_process (const char *name_p, bool free_host, SC_ENTRY_FUNC method_p, sc_process_host *host_p, const sc_spawn_options *opt_p)
virtual ~sc_thread_process ()
virtual const char * kind () const

Protected メソッド

virtual void kill_process ()
sc_thread_handle next_exist ()
sc_thread_handle next_runnable ()
virtual void prepare_for_simulation ()
bool ready_to_run ()
void set_next_exist (sc_thread_handle next_p)
void set_next_runnable (sc_thread_handle next_p)
void set_stack_size (std::size_t size)
void suspend_me ()
bool trigger_dynamic (sc_event *)
void wait (const sc_event &)
void wait (sc_event_or_list &)
void wait (sc_event_and_list &)
void wait (const sc_time &)
void wait (const sc_time &, const sc_event &)
void wait (const sc_time &, sc_event_or_list &)
void wait (const sc_time &, sc_event_and_list &)
void wait_cycles (int n=1)
void add_monitor (sc_process_monitor *monitor_p)
void remove_monitor (sc_process_monitor *monitor_p)
void signal_monitors (int type=0)

Protected 変数

sc_corm_cor_p
std::vector< sc_process_monitor * > m_monitor_q
std::size_t m_stack_size
int m_wait_cycle_n

Static Protected 変数

static sc_corm_dead_cor_p

Private メソッド

 sc_thread_process (const sc_thread_process &)
const sc_thread_processoperator= (const sc_thread_process &)

フレンド

class sc_event
class sc_join
class sc_module
class sc_process_handle
class sc_process_table
class sc_simcontext
class sc_runnable
void sc_thread_cor_fn (void *)
void sc_cthread_cor_fn (void *)
void sc_set_stack_size (sc_thread_handle, std::size_t)
sc_corget_cor_pointer (sc_process_b *process_p)
void wait (sc_simcontext *)
void wait (const sc_event &, sc_simcontext *)
void wait (sc_event_or_list &, sc_simcontext *)
void wait (sc_event_and_list &, sc_simcontext *)
void wait (const sc_time &, sc_simcontext *)
void wait (const sc_time &, const sc_event &, sc_simcontext *)
void wait (const sc_time &, sc_event_or_list &, sc_simcontext *)
void wait (const sc_time &, sc_event_and_list &, sc_simcontext *)


説明

sc_thread_process.h108 行で定義されています。


コンストラクタとデストラクタ

sc_core::sc_thread_process::sc_thread_process ( const char *  name_p,
bool  free_host,
SC_ENTRY_FUNC  method_p,
sc_process_host host_p,
const sc_spawn_options opt_p 
)

sc_thread_process.cpp173 行で定義されています。

00176  :
00177     sc_process_b(
00178         name_p && name_p[0] ? name_p : sc_gen_unique_name("thread_p"), 
00179         free_host, method_p, host_p, opt_p),
00180         m_cor_p(0), m_stack_size(SC_DEFAULT_STACK_SIZE), 
00181         m_wait_cycle_n(0)
00182 {
00183 
00184     // CHECK IF THIS IS AN sc_module-BASED PROCESS AND SIMUALTION HAS STARTED:
00185 
00186     if ( DCAST<sc_module*>(host_p) != 0 && sc_is_running() )
00187     {
00188         SC_REPORT_ERROR( SC_ID_MODULE_THREAD_AFTER_START_, "" );
00189     }
00190 
00191     // INITIALIZE VALUES:
00192     //
00193     // If there are spawn options use them.
00194 
00195     m_process_kind = SC_THREAD_PROC_;
00196 
00197     if (opt_p) {
00198         m_dont_init = opt_p->m_dont_initialize;
00199         if ( opt_p->m_stack_size ) m_stack_size = opt_p->m_stack_size;
00200 
00201         // traverse event sensitivity list
00202         for (unsigned int i = 0; i < opt_p->m_sensitive_events.size(); i++) {
00203             sc_sensitive::make_static_sensitivity(
00204                 this, *opt_p->m_sensitive_events[i]);
00205         }
00206 
00207         // traverse port base sensitivity list
00208         for ( unsigned int i = 0; i < opt_p->m_sensitive_port_bases.size(); i++)
00209         {
00210             sc_sensitive::make_static_sensitivity(
00211                 this, *opt_p->m_sensitive_port_bases[i]);
00212         }
00213 
00214         // traverse interface sensitivity list
00215         for ( unsigned int i = 0; i < opt_p->m_sensitive_interfaces.size(); i++)
00216         {
00217             sc_sensitive::make_static_sensitivity(
00218                 this, *opt_p->m_sensitive_interfaces[i]);
00219         }
00220 
00221         // traverse event finder sensitivity list
00222         for ( unsigned int i = 0; i < opt_p->m_sensitive_event_finders.size();
00223             i++)
00224         {
00225             sc_sensitive::make_static_sensitivity(
00226                 this, *opt_p->m_sensitive_event_finders[i]);
00227         }
00228     }
00229 
00230     else
00231     {
00232         m_dont_init = false;
00233     }
00234 
00235 }

sc_core::sc_thread_process::~sc_thread_process (  )  [virtual]

sc_thread_process.cpp242 行で定義されています。

00243 {
00244 
00245     // DESTROY THE COROUTINE FOR THIS THREAD:
00246 
00247     if( m_cor_p != 0 ) {
00248         m_cor_p->stack_protect( false );
00249         delete m_cor_p;
00250         m_cor_p = 0;
00251     }
00252 }

sc_core::sc_thread_process::sc_thread_process ( const sc_thread_process  )  [private]


関数

virtual const char* sc_core::sc_thread_process::kind (  )  const [inline, virtual]

sc_core::sc_objectを再定義しています。

sc_core::sc_cthread_processで再定義されています。

sc_thread_process.h143 行で定義されています。

00144         { return "sc_thread_process"; }

void sc_core::sc_thread_process::kill_process (  )  [protected, virtual]

sc_core::sc_process_bを再定義しています。

sc_thread_process.cpp114 行で定義されています。

00115 {
00116     // SIGNAL ANY MONITORS WAITING FOR THIS THREAD TO EXIT:
00117 
00118     int mon_n = m_monitor_q.size();
00119     if ( mon_n )
00120     {   
00121         for ( int mon_i = 0; mon_i < mon_n; mon_i++ )
00122             m_monitor_q[mon_i]->signal( this, sc_process_monitor::spm_exit);
00123     }
00124 
00125     // CLEAN UP THE LOW LEVEL STUFF ASSOCIATED WITH THIS DATA STRUCTURE:
00126 
00127     sc_process_b::kill_process();
00128 
00129 
00130     // IF THIS IS THE ACTIVE PROCESS THEN ABORT IT AND SWITCH TO A NEW ONE:
00131     //
00132     // Note we do not use an sc_process_handle, by making a call to
00133     // sc_get_current_process_handle(), since we don't want to increment the 
00134     // usage count in case it is already zero. (We are being deleted, and this
00135     // call to kill_process() may have been the result of the usage count going
00136     // to zero.) So we get a raw sc_process_b pointer instead.
00137  
00138     sc_process_b* active_p = sc_get_current_process_b();
00139     sc_simcontext*    simc_p = simcontext();
00140     if ( active_p == (sc_process_b*)this )
00141     {
00142         simc_p->cor_pkg()->abort( simc_p->next_cor() );
00143     }
00144 
00145     // IF THIS WAS NOT THE ACTIVE PROCESS REMOVE IT FROM ANY RUN QUEUES:
00146 
00147     else
00148     {
00149         simc_p->remove_runnable_thread( this );
00150     }
00151 }

sc_thread_handle sc_core::sc_thread_process::next_exist (  )  [inline, protected]

sc_core::sc_cthread_processで再定義されています。

sc_thread_process.h366 行で定義されています。

00367 {
00368     return (sc_thread_handle)m_exist_p;
00369 }

sc_thread_handle sc_core::sc_thread_process::next_runnable (  )  [inline, protected]

sc_thread_process.h378 行で定義されています。

00379 {
00380     return (sc_thread_handle)m_runnable_p;
00381 }

void sc_core::sc_thread_process::prepare_for_simulation (  )  [protected, virtual]

sc_core::sc_cthread_processで再定義されています。

sc_thread_process.cpp160 行で定義されています。

00161 {
00162     m_cor_p = simcontext()->cor_pkg()->create( m_stack_size,
00163                          sc_thread_cor_fn, this );
00164     m_cor_p->stack_protect( true );
00165 }

bool sc_core::sc_thread_process::ready_to_run (  )  [inline, protected]

sc_thread_process.h192 行で定義されています。

00193 {
00194     if ( (m_throw_type == THROW_NONE) && ( m_wait_cycle_n > 0 ) )
00195     {
00196         --m_wait_cycle_n;
00197         return false;
00198     }
00199     return true;
00200 }

void sc_core::sc_thread_process::set_next_exist ( sc_thread_handle  next_p  )  [inline, protected]

sc_thread_process.h360 行で定義されています。

00361 {
00362     m_exist_p = next_p;
00363 }

void sc_core::sc_thread_process::set_next_runnable ( sc_thread_handle  next_p  )  [inline, protected]

sc_thread_process.h372 行で定義されています。

00373 {
00374     m_runnable_p = next_p;
00375 }

void sc_core::sc_thread_process::set_stack_size ( std::size_t  size  )  [inline, protected]

sc_thread_process.h207 行で定義されています。

00208 {
00209     assert( size );
00210     m_stack_size = size;
00211 }

void sc_core::sc_thread_process::suspend_me (  )  [inline, protected]

sc_thread_process.h219 行で定義されています。

00220 {
00221     sc_simcontext* simc_p = simcontext();
00222     simc_p->cor_pkg()->yield( simc_p->next_cor() );
00223 
00224     switch ( m_throw_type )
00225     {
00226       case THROW_NONE:
00227         break;
00228       case THROW_RESET:
00229         throw sc_user();
00230       default:
00231         break;
00232     }
00233 }

bool sc_core::sc_thread_process::trigger_dynamic ( sc_event e  )  [protected]

sc_thread_process.cpp274 行で定義されています。

00275 {
00276     if( is_runnable() ) {
00277         return false;
00278     }
00279     m_timed_out = false;
00280     switch( m_trigger_type ) {
00281     case EVENT: {
00282         m_trigger_type = STATIC;
00283         return true;
00284     }
00285     case OR_LIST: {
00286         m_event_list_p->remove_dynamic( this, e );
00287         m_event_list_p->auto_delete();
00288         m_event_list_p = 0;
00289         m_trigger_type = STATIC;
00290         return true;
00291     }
00292     case AND_LIST: {
00293         if( -- m_event_count == 0 ) {
00294             // no need to remove_dynamic
00295             m_event_list_p->auto_delete();
00296             m_event_list_p = 0;
00297             m_trigger_type = STATIC;
00298             return true;
00299         }
00300         return false;
00301     }
00302     case TIMEOUT: {
00303         m_trigger_type = STATIC;
00304         return true;
00305     }
00306     case EVENT_TIMEOUT: {
00307         if( e == m_event_p ) {
00308             m_timeout_event_p->cancel();
00309             m_timeout_event_p->reset();
00310         } else {
00311             m_timed_out = true;
00312             m_event_p->remove_dynamic( this );
00313         }
00314         m_event_p = 0;
00315         m_trigger_type = STATIC;
00316         return true;
00317     }
00318     case OR_LIST_TIMEOUT: {
00319         if( e != m_timeout_event_p ) {
00320             m_timeout_event_p->cancel();
00321             m_timeout_event_p->reset();
00322         } else {
00323             m_timed_out = true;
00324         }
00325         m_event_list_p->remove_dynamic( this, e );
00326         m_event_list_p->auto_delete();
00327         m_event_list_p = 0;
00328         m_trigger_type = STATIC;
00329         return true;
00330     }
00331     case AND_LIST_TIMEOUT: {
00332         if( e == m_timeout_event_p ) {
00333             m_timed_out = true;
00334             m_event_list_p->remove_dynamic( this, e );
00335             m_event_list_p->auto_delete();
00336             m_event_list_p = 0;
00337             m_trigger_type = STATIC;
00338             return true;
00339         } else if( -- m_event_count == 0 ) {
00340             m_timeout_event_p->cancel();
00341             m_timeout_event_p->reset();
00342             // no need to remove_dynamic
00343             m_event_list_p->auto_delete();
00344             m_event_list_p = 0;
00345             m_trigger_type = STATIC;
00346             return true;
00347         }
00348         return false;
00349     }
00350     case STATIC: {
00351         // we should never get here
00352         assert( false );
00353     }
00354     }
00355     return false;
00356 }

void sc_core::sc_thread_process::wait ( const sc_event e  )  [inline, protected]

sc_thread_process.h241 行で定義されています。

00242 {
00243     e.add_dynamic( this );
00244     m_trigger_type = EVENT;
00245     suspend_me();
00246 }

void sc_core::sc_thread_process::wait ( sc_event_or_list el  )  [inline, protected]

sc_thread_process.h250 行で定義されています。

00251 {
00252     el.add_dynamic( this );
00253     m_event_list_p = &el;
00254     m_trigger_type = OR_LIST;
00255     suspend_me();
00256 }

void sc_core::sc_thread_process::wait ( sc_event_and_list el  )  [inline, protected]

sc_thread_process.h260 行で定義されています。

00261 {
00262     el.add_dynamic( this );
00263     m_event_list_p = &el;
00264     m_event_count = el.size();
00265     m_trigger_type = AND_LIST;
00266     suspend_me();
00267 }

void sc_core::sc_thread_process::wait ( const sc_time t  )  [inline, protected]

sc_thread_process.h271 行で定義されています。

00272 {
00273     m_timeout_event_p->notify_internal( t );
00274     m_timeout_event_p->add_dynamic( this );
00275     m_trigger_type = TIMEOUT;
00276     suspend_me();
00277 }

void sc_core::sc_thread_process::wait ( const sc_time t,
const sc_event e 
) [inline, protected]

sc_thread_process.h281 行で定義されています。

00282 {
00283     m_timeout_event_p->notify_internal( t );
00284     m_timeout_event_p->add_dynamic( this );
00285     e.add_dynamic( this );
00286     m_event_p = &e;
00287     m_trigger_type = EVENT_TIMEOUT;
00288     suspend_me();
00289 }

void sc_core::sc_thread_process::wait ( const sc_time t,
sc_event_or_list el 
) [inline, protected]

sc_thread_process.h293 行で定義されています。

00294 {
00295     m_timeout_event_p->notify_internal( t );
00296     m_timeout_event_p->add_dynamic( this );
00297     el.add_dynamic( this );
00298     m_event_list_p = &el;
00299     m_trigger_type = OR_LIST_TIMEOUT;
00300     suspend_me();
00301 }

void sc_core::sc_thread_process::wait ( const sc_time t,
sc_event_and_list el 
) [inline, protected]

sc_thread_process.h305 行で定義されています。

00306 {
00307     m_timeout_event_p->notify_internal( t );
00308     m_timeout_event_p->add_dynamic( this );
00309     el.add_dynamic( this );
00310     m_event_list_p = &el;
00311     m_event_count = el.size();
00312     m_trigger_type = AND_LIST_TIMEOUT;
00313     suspend_me();
00314 }

void sc_core::sc_thread_process::wait_cycles ( int  n = 1  )  [inline, protected]

sc_thread_process.h327 行で定義されています。

00328 {
00329     m_wait_cycle_n = n-1;
00330     suspend_me();
00331 }

void sc_core::sc_thread_process::add_monitor ( sc_process_monitor monitor_p  )  [inline, protected]

sc_thread_process.h338 行で定義されています。

00339 {
00340     m_monitor_q.push_back(monitor_p);
00341 }

void sc_core::sc_thread_process::remove_monitor ( sc_process_monitor monitor_p  )  [inline, protected]

sc_thread_process.h345 行で定義されています。

00346 {
00347     int mon_n = m_monitor_q.size();
00348 
00349     for ( int mon_i = 0; mon_i < mon_n; mon_i++ )
00350     {
00351     if  ( m_monitor_q[mon_i] == monitor_p )
00352         {
00353             m_monitor_q[mon_i] = m_monitor_q[mon_n-1];
00354             m_monitor_q.resize(mon_n-1);
00355         }
00356     }
00357 }

void sc_core::sc_thread_process::signal_monitors ( int  type = 0  )  [protected]

sc_thread_process.cpp260 行で定義されています。

00261 {       
00262     int mon_n;  // # of monitors present.
00263         
00264     mon_n = m_monitor_q.size();
00265     for ( int mon_i = 0; mon_i < mon_n; mon_i++ )
00266         m_monitor_q[mon_i]->signal(this, type);
00267 }   

const sc_thread_process& sc_core::sc_thread_process::operator= ( const sc_thread_process  )  [private]


フレンドと関連する関数

friend class sc_event [friend]

sc_thread_process.h112 行で定義されています。

friend class sc_join [friend]

sc_thread_process.h113 行で定義されています。

friend class sc_module [friend]

sc_core::sc_process_bを再定義しています。

sc_core::sc_cthread_processで再定義されています。

sc_thread_process.h114 行で定義されています。

friend class sc_process_handle [friend]

sc_core::sc_process_bを再定義しています。

sc_core::sc_cthread_processで再定義されています。

sc_thread_process.h115 行で定義されています。

friend class sc_process_table [friend]

sc_core::sc_cthread_processで再定義されています。

sc_thread_process.h116 行で定義されています。

friend class sc_simcontext [friend]

sc_core::sc_process_bを再定義しています。

sc_core::sc_cthread_processで再定義されています。

sc_thread_process.h117 行で定義されています。

friend class sc_runnable [friend]

sc_core::sc_process_bを再定義しています。

sc_thread_process.h118 行で定義されています。

void sc_thread_cor_fn ( void *   )  [friend]

sc_core::sc_process_bを再定義しています。

void sc_cthread_cor_fn ( void *   )  [friend]

sc_core::sc_process_bを再定義しています。

sc_core::sc_cthread_processで再定義されています。

sc_cthread_process.cpp63 行で定義されています。

00064 {
00065     sc_cthread_handle cthread_h = RCAST<sc_cthread_handle>( arg );
00066 
00067     // EXECUTE THE CTHREAD AND PROCESS ANY EXCEPTIONS THAT ARE THROWN:
00068     //
00069     // We set the wait state to unknown before invoking the semantics
00070     // in case we are reset, since the wait state will not be cleared, 
00071     // since that happens only if we are not reset.
00072 
00073     while( true ) {
00074 
00075         try {
00076             cthread_h->semantics();
00077         }
00078         catch( sc_user ) {
00079             continue;
00080         }
00081         catch( sc_halt ) {
00082             ::std::cout << "Terminating process "
00083                       << cthread_h->name() << ::std::endl;
00084         }
00085         catch( const sc_report& ex ) {
00086             ::std::cout << "\n" << ex.what() << ::std::endl;
00087             cthread_h->simcontext()->set_error();
00088         }
00089 
00090         break;
00091     }
00092 
00093     // SCHEDULE THREAD FOR DESTRUCTION:
00094     //
00095     // If control reaches this point the process semantics have returned
00096     // so the process should die.
00097 
00098     cthread_h->kill_process();
00099 
00100 }

void sc_set_stack_size ( sc_thread_handle  ,
std::size_t   
) [friend]

sc_cor* get_cor_pointer ( sc_process_b process_p  )  [friend]

void wait ( sc_simcontext  )  [friend]

sc_core::sc_cthread_processで再定義されています。

void wait ( const sc_event ,
sc_simcontext  
) [friend]

sc_core::sc_cthread_processで再定義されています。

void wait ( sc_event_or_list ,
sc_simcontext  
) [friend]

sc_core::sc_cthread_processで再定義されています。

void wait ( sc_event_and_list ,
sc_simcontext  
) [friend]

sc_core::sc_cthread_processで再定義されています。

void wait ( const sc_time ,
sc_simcontext  
) [friend]

sc_core::sc_cthread_processで再定義されています。

void wait ( const sc_time ,
const sc_event ,
sc_simcontext  
) [friend]

sc_core::sc_cthread_processで再定義されています。

void wait ( const sc_time ,
sc_event_or_list ,
sc_simcontext  
) [friend]

sc_core::sc_cthread_processで再定義されています。

void wait ( const sc_time ,
sc_event_and_list ,
sc_simcontext  
) [friend]

sc_core::sc_cthread_processで再定義されています。


変数

sc_thread_process.h175 行で定義されています。

sc_thread_process.h176 行で定義されています。

sc_thread_process.h177 行で定義されています。

sc_thread_process.h178 行で定義されています。

sc_thread_process.h179 行で定義されています。


このクラスの説明は次のファイルから生成されました:

SystemCに対してFri Jun 6 20:12:04 2008に生成されました。  doxygen 1.5.6