36 #ifndef SC_RUNNABLE_INT_H 37 #define SC_RUNNABLE_INT_H 54 # define DEBUG_NAME "" 55 # define DEBUG_MSG(NAME,P,MSG) \ 57 if ( P && ( (std::strlen(NAME)==0) || !std::strcmp(NAME,P->name())) ) \ 58 std::cout << "**** " << sc_time_stamp() << " (" \ 59 << sc_get_current_process_name("** NONE **") << "): " << MSG \ 60 << " - " << P->name() << std::endl; \ 63 # define DEBUG_MSG(NAME,P,MSG) 76 #define SC_NO_METHODS ((sc_method_handle)0xdb) 77 #define SC_NO_THREADS ((sc_thread_handle)0xdb) 89 std::cout <<
"thread pop queue: " << std::endl;
91 p = p->next_runnable() )
93 std::cout <<
" " << p << std::endl;
96 std::cout <<
"thread push queue: " << std::endl;
100 std::cout <<
" " << p << std::endl;
113 DEBUG_MSG(DEBUG_NAME,method_h,
"pushing this method to execute next");
114 method_h->set_next_runnable( m_methods_pop );
115 m_methods_pop = method_h;
127 DEBUG_MSG(DEBUG_NAME,thread_h,
"pushing this thread to execute next");
128 thread_h->set_next_runnable( m_threads_pop );
129 m_threads_pop = thread_h;
142 if ( !m_methods_push_head )
146 m_methods_push_head->dont_initialize(
true);
147 m_methods_push_head->detach();
149 m_methods_push_tail = m_methods_push_head;
153 if ( !m_threads_push_head )
157 m_threads_push_head->dont_initialize(
true);
158 m_threads_push_head->detach();
161 m_threads_push_tail = m_threads_push_head;
172 return m_methods_push_head->next_runnable() ==
SC_NO_METHODS &&
186 return m_methods_push_head && m_threads_push_head;
200 DEBUG_MSG(DEBUG_NAME,method_h,
"pushing back method");
202 m_methods_push_tail->set_next_runnable(method_h);
203 m_methods_push_tail = method_h;
217 DEBUG_MSG(DEBUG_NAME,thread_h,
"pushing back thread");
219 m_threads_push_tail->set_next_runnable(thread_h);
220 m_threads_push_tail = thread_h;
235 DEBUG_MSG(DEBUG_NAME,method_h,
"pushing front method");
236 method_h->set_next_runnable(m_methods_push_head->next_runnable());
237 if ( m_methods_push_tail == m_methods_push_head )
239 m_methods_push_tail->set_next_runnable(method_h);
240 m_methods_push_tail = method_h;
244 m_methods_push_head->set_next_runnable(method_h);
260 DEBUG_MSG(DEBUG_NAME,thread_h,
"pushing front thread");
261 thread_h->set_next_runnable(m_threads_push_head->next_runnable());
262 if ( m_threads_push_tail == m_threads_push_head )
264 m_threads_push_tail->set_next_runnable(thread_h);
265 m_threads_push_tail = thread_h;
269 m_threads_push_head->set_next_runnable(thread_h);
283 result_p = m_methods_pop;
286 m_methods_pop = result_p->next_runnable();
287 result_p->set_next_runnable(0);
293 DEBUG_MSG(DEBUG_NAME,result_p,
"popping method");
308 result_p = m_threads_pop;
311 m_threads_pop = result_p->next_runnable();
312 result_p->set_next_runnable(0);
318 DEBUG_MSG(DEBUG_NAME,result_p,
"popping thread for execution");
342 prior_p = m_methods_push_head;
344 now_p = now_p->next_runnable() )
346 if ( remove_p == now_p )
348 prior_p->set_next_runnable( now_p->next_runnable() );
349 if (now_p == m_methods_push_tail) {
350 m_methods_push_tail = prior_p;
352 now_p->set_next_runnable(0);
353 DEBUG_MSG(DEBUG_NAME,now_p,
"removing method from push queue");
363 now_p = now_p->next_runnable() )
365 if ( remove_p == now_p )
368 prior_p->set_next_runnable( now_p->next_runnable() );
370 m_methods_pop = now_p->next_runnable();
371 now_p->set_next_runnable(0);
372 DEBUG_MSG(DEBUG_NAME,now_p,
"removing method from pop queue");
399 prior_p = m_threads_push_head;
401 now_p = now_p->next_runnable() )
403 if ( remove_p == now_p )
405 prior_p->set_next_runnable( now_p->next_runnable() );
406 if (now_p == m_threads_push_tail) {
407 m_threads_push_tail = prior_p;
409 now_p->set_next_runnable(0);
410 DEBUG_MSG(DEBUG_NAME,now_p,
"removing thread from push queue");
420 now_p = now_p->next_runnable() )
422 if ( remove_p == now_p )
425 prior_p->set_next_runnable( now_p->next_runnable() );
427 m_threads_pop = now_p->next_runnable();
428 now_p->set_next_runnable(0);
429 DEBUG_MSG(DEBUG_NAME,now_p,
"removing thread from pop queue");
442 m_methods_push_head(0), m_methods_push_tail(0), m_methods_pop(
SC_NO_METHODS),
443 m_threads_push_head(0), m_threads_push_tail(0), m_threads_pop(
SC_NO_THREADS)
453 delete m_methods_push_head;
454 delete m_threads_push_head;
468 m_methods_pop = m_methods_push_head->next_runnable();
470 m_methods_push_tail = m_methods_push_head;
485 m_threads_pop = m_threads_push_head->next_runnable();
487 m_threads_push_tail = m_threads_push_head;
577 #endif // SC_RUNNABLE_INT_H
void execute_method_next(sc_method_handle)
void push_front_thread(sc_thread_handle)
#define DEBUG_MSG(NAME, P, MSG)
bool is_initialized() const
sc_thread_handle pop_thread()
void remove_method(sc_method_handle)
void remove_thread(sc_thread_handle)
Thread process declarations.
void push_back_method(sc_method_handle)
void(sc_process_host::* SC_ENTRY_FUNC)()
void push_back_thread(sc_thread_handle)
void push_front_method(sc_method_handle)
Method process declarations.
class sc_thread_process * sc_thread_handle
class sc_method_process * sc_method_handle
void execute_thread_next(sc_thread_handle)
sc_method_handle pop_method()
Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21.