mirror of
https://github.com/nasa/trick.git
synced 2025-02-20 17:22:52 +00:00
Move the loop that waits for scheduled threads to finish out of advance_sim_time #292
Created a new executive job that waits for the scheduled threads to finish. We run this right before advancing time.
This commit is contained in:
parent
858602fe01
commit
7c57c1d02d
@ -924,6 +924,12 @@ namespace Trick {
|
||||
*/
|
||||
virtual int thread_sync() ;
|
||||
|
||||
/**
|
||||
* Job to synchronize SCHEDULED threads to the master.
|
||||
* @return always 0
|
||||
*/
|
||||
virtual int scheduled_thread_sync() ;
|
||||
|
||||
/**
|
||||
* @brief freeze_init job that initialized the freeze_scheduled loop
|
||||
* @return always 0
|
||||
|
@ -158,8 +158,11 @@ class SysSimObject : public Trick::SimObject {
|
||||
|
||||
("freeze_init") sched.init_freeze_scheduled() ;
|
||||
|
||||
// sync all scheduled threads before advancing time
|
||||
{TRK} ("system_advance_sim_time") sched.scheduled_thread_sync() ;
|
||||
// required job to advance sim time
|
||||
{TRK} ("system_advance_sim_time") sched.advance_sim_time() ;
|
||||
|
||||
{TRK} ("system_thread_sync") sched.thread_sync() ;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "trick/Executive.hh"
|
||||
#include "trick/release.h"
|
||||
|
||||
/**
|
||||
@design
|
||||
@ -37,18 +36,6 @@ int Trick::Executive::advance_sim_time() {
|
||||
time_tics = next_job_call_time ;
|
||||
}
|
||||
|
||||
/* Wait for synchronous threads to finish before testing for adjusting time_tics */
|
||||
for (ii = 1; ii < threads.size() ; ii++) {
|
||||
Threads * curr_thread = threads[ii] ;
|
||||
if ( curr_thread->process_type == PROCESS_TYPE_SCHEDULED) {
|
||||
while (curr_thread->child_complete == false ) {
|
||||
if (rt_nap == true) {
|
||||
RELEASE();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 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++) {
|
||||
Threads * curr_thread = threads[ii] ;
|
||||
@ -56,13 +43,14 @@ int Trick::Executive::advance_sim_time() {
|
||||
(curr_thread->job_queue.get_next_job_call_time() < time_tics) ) {
|
||||
time_tics = curr_thread->job_queue.get_next_job_call_time() ;
|
||||
}
|
||||
//TODO: need to make sure cycle time is not 0 for ASYNC.
|
||||
if ( (curr_thread->process_type == PROCESS_TYPE_AMF_CHILD ) &&
|
||||
(curr_thread->amf_cycle_tics > 0 ) &&
|
||||
(curr_thread->amf_next_tics < time_tics) ) {
|
||||
time_tics = curr_thread->amf_next_tics ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Adjust time_tics to the terminate time if terminate is the next event */
|
||||
if ( terminate_time < time_tics ) {
|
||||
time_tics = terminate_time ;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user