unintended performance issue with integ_loop at end of scheduled job classes #243

Previous commit did not update the job complete flags correctly.  Brought the fix
back from 17 to 15.
This commit is contained in:
Alex Lin 2016-08-30 13:08:01 -05:00
parent 0b91b1b163
commit 122033701b
4 changed files with 55 additions and 40 deletions

View File

@ -282,6 +282,12 @@ namespace Trick {
*/ */
void reset_job_call_times() ; void reset_job_call_times() ;
/**
Internal call to test if thread is ready to run
@return bool
*/
bool isThreadReadyToRun( Trick::Threads * curr_thread , long long time_tics) ;
public: public:
Executive() ; Executive() ;

View File

@ -0,0 +1,36 @@
#include "sim_services/Executive/include/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 ;
}

View File

@ -8,32 +8,6 @@
#include "sim_services/Executive/include/exec_proto.h" #include "sim_services/Executive/include/exec_proto.h"
#include "sim_services/include/release.h" #include "sim_services/include/release.h"
static bool 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 ;
}
/** /**
@details @details
-# Wait for all synchronous threads to finish initializing before entering infinite loop -# Wait for all synchronous threads to finish initializing before entering infinite loop
@ -55,9 +29,9 @@ static bool isThreadReadyToRun( Trick::Threads * curr_thread , long long time_ti
calling Trick::ScheduledJobQueue::test_next_job_call_time(Trick::JobData *, long long) calling Trick::ScheduledJobQueue::test_next_job_call_time(Trick::JobData *, long long)
-# If the exec_command equals ExitCmd -# If the exec_command equals ExitCmd
-# Call Trick::Executive::exec_terminate_with_return(int, char *, int, char *) -# Call Trick::Executive::exec_terminate_with_return(int, char *, int, char *)
-# If the elapsed time has reached the termination time -# If the elapsed time has reached the termination time
-# Call Trick::Executive::exec_terminate_with_return(int, char *, int, char *) -# Call Trick::Executive::exec_terminate_with_return(int, char *, int, char *)
-# If the elapsed time equals the next software frame time -# If the elapsed time equals the next software frame time
-# Call the end_of_frame jobs. Requirement [@ref r_exec_periodic_2] -# Call the end_of_frame jobs. Requirement [@ref r_exec_periodic_2]
-# Set the end of frame execution time to the current time + software_frame -# Set the end of frame execution time to the current time + software_frame
*/ */

View File

@ -32,10 +32,6 @@ int Trick::Executive::thread_sync() {
RELEASE(); RELEASE();
} }
} }
curr_thread->job_queue.reset_curr_index();
while ( (curr_job = curr_thread->job_queue.find_job(time_tics)) != NULL ) {
curr_job->complete = false;
}
} }
else if ( curr_thread->process_type == PROCESS_TYPE_ASYNC_CHILD ) { else if ( curr_thread->process_type == PROCESS_TYPE_ASYNC_CHILD ) {
if ( curr_thread->child_complete == true ) { if ( curr_thread->child_complete == true ) {
@ -45,18 +41,21 @@ int Trick::Executive::thread_sync() {
curr_thread->amf_next_tics += curr_thread->amf_cycle_tics ; curr_thread->amf_next_tics += curr_thread->amf_cycle_tics ;
} }
} }
curr_thread->job_queue.reset_curr_index();
while ( (curr_job = curr_thread->job_queue.find_job(time_tics)) != NULL ) {
curr_job->complete = false;
}
} }
} }
} }
/* reset the job complete flags on thread 0 (master thread) */ /* Go through all of the job queues and mark all jobs that are to run this time step to not complete. */
threads[0]->job_queue.reset_curr_index(); for (ii = 0; ii < threads.size() ; ii++) {
while ( (curr_job = threads[0]->job_queue.find_job(time_tics)) != NULL ) { Threads * curr_thread = threads[ii] ;
curr_job->complete = false; /* For all threads that are waiting to start the next cycle (child_complete == true)
reset job completion flags */
if ( isThreadReadyToRun(curr_thread, time_tics) ) {
curr_thread->job_queue.reset_curr_index();
while ( (curr_job = curr_thread->job_queue.find_job(time_tics)) != NULL ) {
curr_job->complete = false;
}
}
} }
return(0) ; return(0) ;