mirror of
https://github.com/nasa/trick.git
synced 2025-01-05 12:54:10 +00:00
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:
parent
0b91b1b163
commit
122033701b
@ -282,6 +282,12 @@ namespace Trick {
|
||||
*/
|
||||
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:
|
||||
|
||||
Executive() ;
|
||||
|
@ -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 ;
|
||||
}
|
||||
|
@ -8,32 +8,6 @@
|
||||
#include "sim_services/Executive/include/exec_proto.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
|
||||
-# 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)
|
||||
-# If the exec_command equals ExitCmd
|
||||
-# 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 *)
|
||||
-# 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]
|
||||
-# Set the end of frame execution time to the current time + software_frame
|
||||
*/
|
||||
|
@ -32,10 +32,6 @@ int Trick::Executive::thread_sync() {
|
||||
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 ) {
|
||||
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->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) */
|
||||
threads[0]->job_queue.reset_curr_index();
|
||||
while ( (curr_job = threads[0]->job_queue.find_job(time_tics)) != NULL ) {
|
||||
curr_job->complete = false;
|
||||
/* Go through all of the job queues and mark all jobs that are to run this time step to not complete. */
|
||||
for (ii = 0; ii < threads.size() ; ii++) {
|
||||
Threads * curr_thread = threads[ii] ;
|
||||
/* 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) ;
|
||||
|
Loading…
Reference in New Issue
Block a user