Skip to content

Commit

Permalink
sc_simcontext: cleanup stale zombie processes during clean()
Browse files Browse the repository at this point in the history
The process zombie collection in sc_simcontext::crunch might be
skipped due to errors or early exit from the simulation.

Make sure to clean the collected zombies when cleaning up the
simcontext's state as a whole.
  • Loading branch information
pah committed Apr 28, 2018
1 parent b1f5117 commit c81e0d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/sysc/kernel/sc_simcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ sc_simcontext::init()
void
sc_simcontext::clean()
{
// remove remaining zombie processes
do_collect_processes();

delete m_method_invoker_p;
delete m_error;
delete m_cor_pkg;
Expand Down Expand Up @@ -516,14 +519,8 @@ sc_simcontext::crunch( bool once )
}
}

// remove finally dead zombies:

while( ! m_collectable->empty() )
{
sc_process_b* del_p = m_collectable->front();
m_collectable->pop_front();
del_p->reference_decrement();
}
// remove finally dead zombies:
do_collect_processes();


// UPDATE PHASE
Expand Down Expand Up @@ -975,6 +972,15 @@ sc_simcontext::mark_to_collect_process( sc_process_b* zombie )
m_collectable->push_back( zombie );
}

void sc_simcontext::do_collect_processes()
{
while( ! m_collectable->empty() )
{
sc_process_b* del_p = m_collectable->front();
m_collectable->pop_front();
del_p->reference_decrement();
}
}

//------------------------------------------------------------------------------
//"sc_simcontext::stop"
Expand Down
1 change: 1 addition & 0 deletions src/sysc/kernel/sc_simcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ class SC_API sc_simcontext
void do_sc_stop_action();
void do_timestep( const sc_time& );
void mark_to_collect_process( sc_process_b* zombie_p );
void do_collect_processes();

sc_method_handle remove_process( sc_method_handle );
sc_thread_handle remove_process( sc_thread_handle );
Expand Down

0 comments on commit c81e0d9

Please sign in to comment.