Don't start or wait for disabled threads in the executive #549

Added check to see if thread is enabled when starting it and waiting
for it to finish.  If it is disabled, skip it.
This commit is contained in:
Alex Lin 2018-01-23 09:35:06 -06:00
parent 6039669647
commit c4b872c26e
3 changed files with 28 additions and 24 deletions

View File

@ -42,14 +42,16 @@ int Trick::Executive::advance_sim_time() {
/* Adjust time_tics if one of the threads has a job or async cycle time less than the main thread's next job */ /* Adjust time_tics if one of the threads has a job or async cycle time less than the main thread's next job */
for (ii = 1; ii < threads.size() ; ii++) { for (ii = 1; ii < threads.size() ; ii++) {
Threads * curr_thread = threads[ii] ; Threads * curr_thread = threads[ii] ;
if ( (curr_thread->process_type == PROCESS_TYPE_SCHEDULED) && if ( curr_thread->enabled ) {
(curr_thread->job_queue.get_next_job_call_time() < time_tics) ) { if ( (curr_thread->process_type == PROCESS_TYPE_SCHEDULED) &&
time_tics = curr_thread->job_queue.get_next_job_call_time() ; (curr_thread->job_queue.get_next_job_call_time() < time_tics) ) {
} time_tics = curr_thread->job_queue.get_next_job_call_time() ;
if ( (curr_thread->process_type == PROCESS_TYPE_AMF_CHILD ) && }
(curr_thread->amf_cycle_tics > 0 ) && if ( (curr_thread->process_type == PROCESS_TYPE_AMF_CHILD ) &&
(curr_thread->amf_next_tics < time_tics) ) { (curr_thread->amf_cycle_tics > 0 ) &&
time_tics = curr_thread->amf_next_tics ; (curr_thread->amf_next_tics < time_tics) ) {
time_tics = curr_thread->amf_next_tics ;
}
} }
} }

View File

@ -10,26 +10,28 @@
*/ */
bool Trick::Executive::isThreadReadyToRun( Trick::Threads * curr_thread , long long time_ticks) { bool Trick::Executive::isThreadReadyToRun( Trick::Threads * curr_thread , long long time_ticks) {
bool ret = false ; bool ret = false ;
switch ( curr_thread->process_type ) { if ( curr_thread->enabled ) {
case Trick::PROCESS_TYPE_SCHEDULED: switch ( curr_thread->process_type ) {
ret = true ; case Trick::PROCESS_TYPE_SCHEDULED:
break ;
case Trick::PROCESS_TYPE_AMF_CHILD:
if ( curr_thread->amf_next_tics == time_ticks ) {
ret = true ; ret = true ;
} break ;
break ; case Trick::PROCESS_TYPE_AMF_CHILD:
case Trick::PROCESS_TYPE_ASYNC_CHILD: if ( curr_thread->amf_next_tics == time_ticks ) {
if ( curr_thread->child_complete == true ) {
if (curr_thread->amf_cycle_tics == 0 ) {
ret = true ; ret = true ;
} else { }
if ( curr_thread->amf_next_tics == time_ticks ) { break ;
case Trick::PROCESS_TYPE_ASYNC_CHILD:
if ( curr_thread->child_complete == true ) {
if (curr_thread->amf_cycle_tics == 0 ) {
ret = true ; ret = true ;
} else {
if ( curr_thread->amf_next_tics == time_ticks ) {
ret = true ;
}
} }
} }
} break ;
break ; }
} }
return ret ; return ret ;
} }

View File

@ -16,7 +16,7 @@ int Trick::Executive::scheduled_thread_sync() {
/* Wait for synchronous threads to finish before testing for adjusting time_tics */ /* Wait for synchronous threads to finish before testing for adjusting time_tics */
for (ii = 1; ii < threads.size() ; ii++) { for (ii = 1; ii < threads.size() ; ii++) {
Threads * curr_thread = threads[ii] ; Threads * curr_thread = threads[ii] ;
if ( curr_thread->process_type == PROCESS_TYPE_SCHEDULED) { if ( curr_thread->enabled and curr_thread->process_type == PROCESS_TYPE_SCHEDULED) {
while (curr_thread->child_complete == false ) { while (curr_thread->child_complete == false ) {
if (rt_nap == true) { if (rt_nap == true) {
RELEASE(); RELEASE();