trick/trick_source/sim_services/Executive/Executive_isThreadReadyToRun.cpp
Alex Lin fa4664c4ea Move the loop that waits for scheduled threads to finish out of advance_sim_time #292
2 problems found.  Syncing scheduled threads was not happening at all because the job
was not being rescheduled.  Did not want to deal with changing job call times so I
called the new scheuduled_thread_sync routine from advance_sim_time.  That's where
it started, it'll be fine.

Also found that I was resetting job complete flags too aggressively.  The check to
test if the thread is ready to run was missing.  Added that check back in.
2016-08-30 10:56:18 -05:00

37 lines
1.2 KiB
C++

#include "trick/Executive.hh"
/*
-# Switch on the type of thread
-# Scheduled threads are always ready to run
-# AMF thredas are ready to run if their previous frame just finished
-# ASYNC threads are ready to run if their complete flag is set and either they have
no cycle time or their previous frame just finished.
*/
bool Trick::Executive::isThreadReadyToRun( Trick::Threads * curr_thread , long long time_tics) {
bool ret = false ;
switch ( curr_thread->process_type ) {
case Trick::PROCESS_TYPE_SCHEDULED:
ret = true ;
break ;
case Trick::PROCESS_TYPE_AMF_CHILD:
if ( curr_thread->amf_next_tics == time_tics ) {
ret = true ;
}
break ;
case Trick::PROCESS_TYPE_ASYNC_CHILD:
if ( curr_thread->child_complete == true ) {
if (curr_thread->amf_cycle_tics == 0 ) {
ret = true ;
} else {
if ( curr_thread->amf_next_tics == time_tics ) {
ret = true ;
}
}
}
break ;
}
return ret ;
}