📄 reconfig_scheduler_t.cpp
字号:
this->stability_flags_ |= SCHED_UTILIZATION_NOT_STABLE;
--dependency_count_;
}
// This method sets the enable state for a dependency between two RT_Infos.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
void
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
set_dependency_enable_state (RtecScheduler::handle_t handle,
RtecScheduler::handle_t dependency,
CORBA::Long number_of_calls,
RtecScheduler::Dependency_Type_t dependency_type,
RtecScheduler::Dependency_Enabled_Type_t enabled
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::SYNCHRONIZATION_FAILURE,
RtecScheduler::UNKNOWN_TASK))
{
#if defined (SCHEDULER_LOGGING)
ACE_DEBUG ((LM_TRACE,
" TAO_Reconfig_Scheduler::set_dependency_enable_state.\n"));
#endif /* SCHEDULER_LOGGING */
ACE_GUARD_THROW_EX (ACE_LOCK, ace_mon, this->mutex_,
RtecScheduler::SYNCHRONIZATION_FAILURE ());
ACE_CHECK;
// Delegate to the internal method.
set_dependency_enable_state_i (handle, dependency, number_of_calls,
dependency_type, enabled ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
}
// This method sets the enable state of a sequence of dependencies.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
void
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
set_dependency_enable_state_seq (const RtecScheduler::Dependency_Set & dependencies
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::SYNCHRONIZATION_FAILURE,
RtecScheduler::UNKNOWN_TASK))
{
#if defined (SCHEDULER_LOGGING)
ACE_DEBUG ((LM_TRACE,
" TAO_Reconfig_Scheduler::set_dependency_enable_state_seq.\n"));
#endif /* SCHEDULER_LOGGING */
ACE_GUARD_THROW_EX (ACE_LOCK, ace_mon, this->mutex_,
RtecScheduler::SYNCHRONIZATION_FAILURE ());
ACE_CHECK;
// Delegate to the internal method for each dependency in the sequence.
for (u_int i = 0; i < dependencies.length (); ++i)
{
set_dependency_enable_state_i (dependencies[i].rt_info,
dependencies[i].rt_info_depended_on,
dependencies[i].number_of_calls,
dependencies[i].dependency_type,
dependencies[i].enabled
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
}
}
// This method enables or disables an RT_Info.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
void
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
set_rt_info_enable_state (RtecScheduler::handle_t handle,
RtecScheduler::RT_Info_Enabled_Type_t enabled
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::SYNCHRONIZATION_FAILURE,
RtecScheduler::INTERNAL,
RtecScheduler::UNKNOWN_TASK))
{
#if defined (SCHEDULER_LOGGING)
ACE_DEBUG ((LM_TRACE,
" TAO_Reconfig_Scheduler::set_rt_info_enable_state.\n"));
#endif /* SCHEDULER_LOGGING */
ACE_GUARD_THROW_EX (ACE_LOCK, ace_mon, this->mutex_,
RtecScheduler::SYNCHRONIZATION_FAILURE ());
ACE_CHECK;
// Look up the RT_Info by its handle, throw an exception if it's not there.
TAO_RT_Info_Ex *rt_info_ptr = 0;
if (rt_info_map_.find (handle, rt_info_ptr) != 0)
{
ACE_THROW (RtecScheduler::UNKNOWN_TASK ());
}
if (rt_info_ptr == 0)
{
ACE_THROW (RtecScheduler::INTERNAL ());
}
// Enable the RT_Info.
rt_info_ptr->enabled_state (enabled);
}
// This method enables or disables a sequence of RT_Infos.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
void
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
set_rt_info_enable_state_seq (const RtecScheduler::RT_Info_Enable_State_Pair_Set & pair_set
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::SYNCHRONIZATION_FAILURE,
RtecScheduler::INTERNAL,
RtecScheduler::UNKNOWN_TASK))
{
#if defined (SCHEDULER_LOGGING)
ACE_DEBUG ((LM_TRACE,
" TAO_Reconfig_Scheduler::set_rt_info_enable_state_seq.\n"));
#endif /* SCHEDULER_LOGGING */
ACE_GUARD_THROW_EX (ACE_LOCK, ace_mon, this->mutex_,
RtecScheduler::SYNCHRONIZATION_FAILURE ());
ACE_CHECK;
for (u_int i = 0; i < pair_set.length (); ++i)
{
// Look up the RT_Info by its handle, throw an exception if it's not there.
TAO_RT_Info_Ex *rt_info_ptr = 0;
if (rt_info_map_.find (pair_set[i].handle, rt_info_ptr) != 0)
{
ACE_THROW (RtecScheduler::UNKNOWN_TASK ());
}
if (rt_info_ptr == 0)
{
ACE_THROW (RtecScheduler::INTERNAL ());
}
// Enable the RT_Info.
rt_info_ptr->enabled_state (pair_set[i].enabled);
}
}
// If information has been added or changed since the last stable
// schedule was computed, this method causes scheduling information
// to be computed for all registered RT_Infos. If the schedule is
// already stable, this is a no-op
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
void
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
compute_scheduling (CORBA::Long minimum_priority,
CORBA::Long maximum_priority,
RtecScheduler::RT_Info_Set_out infos,
RtecScheduler::Dependency_Set_out dependencies,
RtecScheduler::Config_Info_Set_out configs,
RtecScheduler::Scheduling_Anomaly_Set_out anomalies
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::UTILIZATION_BOUND_EXCEEDED,
RtecScheduler::SYNCHRONIZATION_FAILURE,
RtecScheduler::INSUFFICIENT_THREAD_PRIORITY_LEVELS,
RtecScheduler::TASK_COUNT_MISMATCH,
RtecScheduler::INTERNAL,
RtecScheduler::DUPLICATE_NAME))
{
// Delegates to recompute_scheduling and the respective accessors.
this->recompute_scheduling (minimum_priority, maximum_priority,
anomalies ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
this->get_rt_info_set (infos ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
this->get_dependency_set (dependencies ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
this->get_config_info_set (configs ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
#if defined (SCHEDULER_DUMP)
ACE_DEBUG ((LM_TRACE, "Schedule prepared.\n"));
ACE_DEBUG ((LM_TRACE, "Dumping to stdout.\n"));
ACE_Scheduler_Factory::dump_schedule (*(infos.ptr()), *(dependencies.ptr()), *(configs.ptr()),
*(anomalies.ptr()), 0);
ACE_DEBUG ((LM_TRACE, "Dump done.\n"));
#endif // SCHEDULER_DUMP
return;
}
// Recomputes the scheduling priorities, etc.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
void
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
recompute_scheduling (CORBA::Long minimum_priority,
CORBA::Long maximum_priority,
RtecScheduler::Scheduling_Anomaly_Set_out anomalies
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::UTILIZATION_BOUND_EXCEEDED,
RtecScheduler::SYNCHRONIZATION_FAILURE,
RtecScheduler::INSUFFICIENT_THREAD_PRIORITY_LEVELS,
RtecScheduler::TASK_COUNT_MISMATCH,
RtecScheduler::INTERNAL,
RtecScheduler::DUPLICATE_NAME))
{
#if defined (SCHEDULER_LOGGING)
ACE_DEBUG ((LM_TRACE,
" TAO_Reconfig_Scheduler::compute_scheduling.\n"));
#endif /* SCHEDULER_LOGGING */
ACE_GUARD_THROW_EX (ACE_LOCK, ace_mon, this->mutex_,
RtecScheduler::SYNCHRONIZATION_FAILURE ());
ACE_CHECK;
// @@ TO DO - use these to establish the bounds of priority assignment.
ACE_UNUSED_ARG (minimum_priority);
ACE_UNUSED_ARG (maximum_priority);
// If everything is already up to date, we're done.
if (SCHED_ALL_STABLE == stability_flags_)
{
// Must always provide a value for an out parameter
ACE_NEW_THROW_EX (anomalies,
RtecScheduler::Scheduling_Anomaly_Set (0),
CORBA::NO_MEMORY ());
ACE_CHECK;
return;
}
// @@ TO DO - use try/catch blocks to catch exceptions and add anomalies
// to scheduling anomaly set, and then perhaps rethrow)
if ((this->stability_flags_ & SCHED_PROPAGATION_NOT_STABLE)
|| (this->stability_flags_ & SCHED_UTILIZATION_NOT_STABLE))
{
#if defined (SCHEDULER_LOGGING)
ACE_Scheduler_Factory::log_scheduling_entries(entry_ptr_array_,
this->rt_info_count_,
"1_pre_crit_traverse.txt");
#endif
// Traverse criticality dependency graph, assigning a
// topological ordering and identifying threads.
crit_dfs_traverse_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
#if defined (SCHEDULER_LOGGING)
ACE_Scheduler_Factory::log_scheduling_entries(entry_ptr_array_,
this->rt_info_count_,
"2_crit_dfs_traverse_i.txt");
#endif
// Propagate criticalities.
propagate_criticalities_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
#if defined (SCHEDULER_LOGGING)
ACE_Scheduler_Factory::log_scheduling_entries(entry_ptr_array_,
this->rt_info_count_,
"3_propagate_criticalities_i.txt");
#endif
#if defined (SCHEDULER_LOGGING)
ACE_Scheduler_Factory::log_scheduling_entries(entry_ptr_array_,
this->rt_info_count_,
"4_pre_traverse.txt");
#endif
// Traverse dependency graph, assigning a topological ordering and identifying threads.
dfs_traverse_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
#if defined (SCHEDULER_LOGGING)
ACE_Scheduler_Factory::log_scheduling_entries(entry_ptr_array_,
this->rt_info_count_,
"5_dfs_traverse_i.txt");
#endif
// Sort an array of RT_info handles in topological order, check
// for loops using the strongly connected components algorithm.
detect_cycles_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
#if defined (SCHEDULER_LOGGING)
ACE_Scheduler_Factory::log_scheduling_entries(entry_ptr_array_,
this->rt_info_count_,
"6_detect_cycles_i.txt");
#endif
// Perform admission control for task delineator rate tuples.
perform_admission_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
#if defined (SCHEDULER_LOGGING)
ACE_Scheduler_Factory::log_scheduling_entries(entry_ptr_array_,
this->rt_info_count_,
"7_perform_admission_i.txt");
#endif
// Propagate effective execution time and period, set total frame size.
propagate_characteristics_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
#if defined (SCHEDULER_LOGGING)
ACE_Scheduler_Factory::log_scheduling_entries(entry_ptr_array_,
this->rt_info_count_,
"8_propagate_characteristics_i.txt");
#endif
}
if (this->stability_flags_ & SCHED_PRIORITY_NOT_STABLE)
{
// Sort operations by urgency, then assign priorities and
// subpriorities in one pass. Sets last scheduled priority and
// last feasible priority.
assign_priorities_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
#if defined (SCHEDULER_LOGGING)
ACE_Scheduler_Factory::log_scheduling_entries(entry_ptr_array_,
this->rt_info_count_,
"9_assign_priorities_i.txt");
#endif
}
// @@ TODO: record any scheduling anomalies in a set within the scheduler,
// storing the maximum severity level recorded so far.
if (anomalies.ptr () == 0)
{
ACE_NEW_THROW_EX (anomalies,
RtecScheduler::Scheduling_Anomaly_Set (0),
CORBA::NO_MEMORY ());
ACE_CHECK;
}
// Set stability flags last.
this->stability_flags_ = SCHED_ALL_STABLE;
return;
}
// Returns the set of rt_infos, with their assigned priorities (as
// of the last schedule re-computation).
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
void
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
get_rt_info_set (RtecScheduler::RT_Info_Set_out infos
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::SYNCHRONIZATION_FAILURE,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -