30 #ifndef SC_RUNNABLE_INT_H
31 #define SC_RUNNABLE_INT_H
38 #ifndef _SYSC_PRINT_VERBOSE_MESSAGE_ENV_VAR
39 #define _SYSC_PRINT_VERBOSE_MESSAGE_ENV_VAR "SYSC_PRINT_VERBOSE_MESSAGE"
50 # define DEBUG_NAME ""
51 # define DEBUG_MSG(NAME,P,MSG) \
53 if ( P && ( (strlen(NAME)==0) || !strcmp(NAME,P->name())) ) \
54 std::cout << "**** " << sc_time_stamp() << " (" \
55 << sc_get_current_process_name() << "): " << MSG \
56 << " - " << P->name() << std::endl; \
59 # define DEBUG_MSG(NAME,P,MSG)
72 #define SC_NO_METHODS ((sc_method_handle)0xdb)
73 #define SC_NO_THREADS ((sc_thread_handle)0xdb)
85 std::cout <<
"thread pop queue: " << std::endl;
87 p = p->next_runnable() )
89 std::cout <<
" " << p << std::endl;
92 std::cout <<
"thread push queue: " << std::endl;
96 std::cout <<
" " << p << std::endl;
109 DEBUG_MSG(DEBUG_NAME,method_h,
"pushing this method to execute next");
110 method_h->set_next_runnable( m_methods_pop );
111 m_methods_pop = method_h;
123 DEBUG_MSG(DEBUG_NAME,thread_h,
"pushing this thread to execute next");
124 thread_h->set_next_runnable( m_threads_pop );
125 m_threads_pop = thread_h;
138 if ( !m_methods_push_head )
142 m_methods_push_head->dont_initialize(
true);
143 m_methods_push_head->detach();
145 m_methods_push_tail = m_methods_push_head;
149 if ( !m_threads_push_head )
153 m_threads_push_head->dont_initialize(
true);
154 m_threads_push_head->detach();
157 m_threads_push_tail = m_threads_push_head;
168 return m_methods_push_head->next_runnable() ==
SC_NO_METHODS &&
182 return m_methods_push_head && m_threads_push_head;
196 method_h->m_process_state=1;
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 thread_h->m_process_state=1;
221 DEBUG_MSG(DEBUG_NAME,thread_h,
"pushing back thread");
223 m_threads_push_tail->set_next_runnable(thread_h);
224 m_threads_push_tail = thread_h;
239 method_h->m_process_state=1;
243 DEBUG_MSG(DEBUG_NAME,method_h,
"pushing front method");
244 method_h->set_next_runnable(m_methods_push_head->next_runnable());
245 if ( m_methods_push_tail == m_methods_push_head )
247 m_methods_push_tail->set_next_runnable(method_h);
248 m_methods_push_tail = method_h;
252 m_methods_push_head->set_next_runnable(method_h);
268 thread_h->m_process_state=1;
272 DEBUG_MSG(DEBUG_NAME,thread_h,
"pushing front thread");
273 thread_h->set_next_runnable(m_threads_push_head->next_runnable());
274 if ( m_threads_push_tail == m_threads_push_head )
276 m_threads_push_tail->set_next_runnable(thread_h);
277 m_threads_push_tail = thread_h;
281 m_threads_push_head->set_next_runnable(thread_h);
295 result_p = m_methods_pop;
298 m_methods_pop = result_p->next_runnable();
299 result_p->set_next_runnable(0);
305 DEBUG_MSG(DEBUG_NAME,result_p,
"popping method");
320 result_p = m_threads_pop;
323 m_threads_pop = result_p->next_runnable();
324 result_p->set_next_runnable(0);
330 DEBUG_MSG(DEBUG_NAME,result_p,
"popping thread for execution");
354 prior_p = m_methods_push_head;
356 now_p = now_p->next_runnable() )
358 if ( remove_p == now_p )
360 prior_p->set_next_runnable( now_p->next_runnable() );
361 if (now_p == m_methods_push_tail) {
362 m_methods_push_tail = prior_p;
364 now_p->set_next_runnable(0);
365 DEBUG_MSG(DEBUG_NAME,now_p,
"removing method from push queue");
375 now_p = now_p->next_runnable() )
377 if ( remove_p == now_p )
380 prior_p->set_next_runnable( now_p->next_runnable() );
382 m_methods_pop = now_p->next_runnable();
383 now_p->set_next_runnable(0);
384 DEBUG_MSG(DEBUG_NAME,now_p,
"removing method from pop queue");
411 prior_p = m_threads_push_head;
413 now_p = now_p->next_runnable() )
415 if ( remove_p == now_p )
417 prior_p->set_next_runnable( now_p->next_runnable() );
418 if (now_p == m_threads_push_tail) {
419 m_threads_push_tail = prior_p;
421 now_p->set_next_runnable(0);
422 DEBUG_MSG(DEBUG_NAME,now_p,
"removing thread from push queue");
432 now_p = now_p->next_runnable() )
434 if ( remove_p == now_p )
437 prior_p->set_next_runnable( now_p->next_runnable() );
439 m_threads_pop = now_p->next_runnable();
440 now_p->set_next_runnable(0);
441 DEBUG_MSG(DEBUG_NAME,now_p,
"removing thread from pop queue");
454 m_methods_push_head(0), m_methods_push_tail(0), m_methods_pop(
SC_NO_METHODS),
455 m_threads_push_head(0), m_threads_push_tail(0), m_threads_pop(
SC_NO_THREADS)
465 delete m_methods_push_head;
466 delete m_threads_push_head;
480 m_methods_pop = m_methods_push_head->next_runnable();
482 m_methods_push_tail = m_methods_push_head;
497 m_threads_pop = m_threads_push_head->next_runnable();
499 m_threads_push_tail = m_threads_push_head;
511 return m_methods_push_head->next_runnable();
534 return m_methods_pop;
557 return m_threads_push_head->next_runnable();
580 return m_threads_pop;
681 #endif // SC_RUNNABLE_INT_H
#define DEBUG_MSG(NAME, P, MSG)
void push_back_thread(sc_thread_handle)
bool is_threads_pop_end(sc_thread_handle)
Check whether it is the end of threads pop queue.
sc_thread_handle pop_thread()
sc_thread_handle get_threads_push_first()
Return the first thread of threads push queue.
bool is_methods_push_end(sc_method_handle)
Check whether it is the end of methods push queue.
void push_back_method(sc_method_handle)
void(sc_process_host::* SC_ENTRY_FUNC)()
void execute_method_next(sc_method_handle)
sc_method_handle get_methods_pop_first()
Return the first method of methods pop queue.
class sc_method_process * sc_method_handle
User initiated dynamic process support.
void remove_method(sc_method_handle)
bool is_initialized() const
void push_front_thread(sc_thread_handle)
void push_front_method(sc_method_handle)
class sc_thread_process * sc_thread_handle
sc_thread_handle get_threads_pop_first()
Return the first thread of threads pop queue.
sc_method_handle pop_method()
void remove_thread(sc_thread_handle)
sc_method_handle get_methods_push_first()
Return the first method of methods push queue.
void execute_thread_next(sc_thread_handle)
bool is_threads_push_end(sc_thread_handle)
Check whether it is the end of threads push queue.
sc_simcontext * sc_get_curr_simcontext()
bool is_methods_pop_end(sc_method_handle)
Check whether it is the end of methods pop queue.