📄 reconfig_scheduler_t.cpp
字号:
RtecScheduler::INTERNAL))
{
// return the set of scheduled RT_Infos
if (infos.ptr () == 0)
{
ACE_NEW_THROW_EX (infos,
RtecScheduler::RT_Info_Set (this->rt_info_count_),
CORBA::NO_MEMORY ());
ACE_CHECK;
}
infos->length (this->rt_info_count_);
TAO_RT_Info_Ex* rt_info = 0;
for (ACE_TYPENAME RT_INFO_MAP::iterator info_iter (this->rt_info_map_);
info_iter.done () == 0;
++info_iter)
{
// TODO - rethink this: is it more useful to only return the *enabled* RT_Infos?
rt_info = (*info_iter).int_id_;
infos[ACE_static_cast (CORBA::ULong, rt_info->handle - 1)] = *rt_info;
}
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_dependency_set (RtecScheduler::Dependency_Set_out dependencies
ACE_ENV_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::SYNCHRONIZATION_FAILURE,
RtecScheduler::INTERNAL))
{
// Return the set of dependencies: just need to iterate over one of the maps.
if (dependencies.ptr () == 0)
{
dependencies = new RtecScheduler::Dependency_Set (this->dependency_count_);
}
dependencies->length (this->dependency_count_);
RtecScheduler::Dependency_Set *dependency_set = 0;
int i = 0;
for (ACE_TYPENAME DEPENDENCY_SET_MAP::iterator
dependency_iter (this->called_dependency_set_map_);
dependency_iter.done () == 0 && i < this->dependency_count_;
++dependency_iter)
{
dependency_set = (*dependency_iter).int_id_;
for (u_int j = 0;
j < dependency_set->length () && i < this->dependency_count_;
++i, ++j)
{
(* dependencies) [i] = (*dependency_set) [j];
// For two-way calls, swap the handles (stored in reverse order in the called map)
if ((* dependencies) [i].dependency_type == RtecBase::TWO_WAY_CALL)
{
(* dependencies) [i].rt_info = (* dependency_set) [j].rt_info_depended_on;
(* dependencies) [i].rt_info_depended_on = (* dependency_set) [j].rt_info;
}
}
}
return;
}
// Returns the set of config_infos, describing the appropriate
// number, types, and priority levels for the dispatching lanes.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
void
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
get_config_info_set (RtecScheduler::Config_Info_Set_out configs
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::SYNCHRONIZATION_FAILURE,
RtecScheduler::INTERNAL))
{
// Return the set of scheduled Config_Infos.
if (configs.ptr () == 0)
{
ACE_NEW_THROW_EX (configs,
RtecScheduler::Config_Info_Set(this->
config_info_count_),
CORBA::NO_MEMORY ());
ACE_CHECK;
}
configs->length (this->config_info_count_);
RtecScheduler::Config_Info* config_info = 0;
for (ACE_TYPENAME CONFIG_INFO_MAP::iterator config_iter (this->config_info_map_);
config_iter.done () == 0;
++config_iter)
{
config_info = (*config_iter).int_id_;
configs[ACE_static_cast (CORBA::ULong, config_info->preemption_priority)] = *config_info;
}
return;
}
// Provides the thread priority and queue type for the given priority
// level.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
void
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
dispatch_configuration (RtecScheduler::Preemption_Priority_t p_priority,
RtecScheduler::OS_Priority& t_priority,
RtecScheduler::Dispatching_Type_t & d_type
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::NOT_SCHEDULED,
RtecScheduler::SYNCHRONIZATION_FAILURE,
RtecScheduler::UNKNOWN_PRIORITY_LEVEL))
{
#if defined (SCHEDULER_LOGGING)
ACE_DEBUG ((LM_TRACE,
" TAO_Reconfig_Scheduler::dispatch_configuration.\n"));
#endif /* SCHEDULER_LOGGING */
ACE_GUARD_THROW_EX (ACE_LOCK, ace_mon, this->mutex_,
RtecScheduler::SYNCHRONIZATION_FAILURE ());
ACE_CHECK;
// Check stability flags
if ((this->stability_flags_ & SCHED_PRIORITY_NOT_STABLE)
&& this->enforce_schedule_stability_)
{
ACE_THROW (RtecScheduler::NOT_SCHEDULED ());
}
RtecScheduler::Config_Info *config_info;
if (config_info_map_.find (p_priority, config_info) != 0)
{
ACE_THROW (RtecScheduler::UNKNOWN_PRIORITY_LEVEL());
}
t_priority = config_info->thread_priority;
d_type = config_info->dispatching_type;
}
// Returns the last priority number assigned to an operation in the
// schedule. The number returned is one less than the total number
// of scheduled priorities. All scheduled priorities range from 0
// to the number returned, inclusive.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
RtecScheduler::Preemption_Priority_t
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
last_scheduled_priority (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::SYNCHRONIZATION_FAILURE,
RtecScheduler::NOT_SCHEDULED))
{
#if defined (SCHEDULER_LOGGING)
ACE_DEBUG ((LM_TRACE,
" TAO_Reconfig_Scheduler::last_scheduled_priority.\n"));
#endif /* SCHEDULER_LOGGING */
ACE_GUARD_THROW_EX (ACE_LOCK, ace_mon, this->mutex_,
RtecScheduler::SYNCHRONIZATION_FAILURE ());
ACE_CHECK_RETURN (0);
// Check schedule stability flags.
if ((this->stability_flags_ & SCHED_PRIORITY_NOT_STABLE)
&& this->enforce_schedule_stability_)
{
ACE_THROW_RETURN (RtecScheduler::NOT_SCHEDULED (),
(RtecScheduler::Preemption_Priority_t) -1);
}
return last_scheduled_priority_;
}
// Provides the set of Config_Infos associated with the current schedule.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
void
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
get_config_infos (RtecScheduler::Config_Info_Set_out configs
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::SYNCHRONIZATION_FAILURE,
RtecScheduler::NOT_SCHEDULED))
{
ACE_GUARD_THROW_EX (ACE_LOCK, ace_mon, this->mutex_,
RtecScheduler::SYNCHRONIZATION_FAILURE ());
ACE_CHECK;
// Check schedule stability flags.
if ((this->stability_flags_ & SCHED_PRIORITY_NOT_STABLE)
&& this->enforce_schedule_stability_)
{
ACE_THROW (RtecScheduler::NOT_SCHEDULED ());
}
// return the set of Config_Infos
if (configs.ptr () == 0)
{
ACE_NEW_THROW_EX (configs,
RtecScheduler::Config_Info_Set(this->
config_info_count_),
CORBA::NO_MEMORY ());
ACE_CHECK;
}
configs->length (this->config_info_count_);
RtecScheduler::Config_Info* config_info = 0;
for (ACE_TYPENAME CONFIG_INFO_MAP::iterator config_iter (this->config_info_map_);
config_iter.done () == 0;
++config_iter)
{
config_info = (*config_iter).int_id_;
configs[ACE_static_cast (CORBA::ULong, config_info->preemption_priority)] = *config_info;
}
}
// Internal method to create an RT_Info. If it does not exist, a new
// RT_Info is created and inserted into the schedule, and the handle
// of the new RT_Info is returned. If the RT_Info already exists,
// then if the ignore_duplicates flag is set, the handle is simply
// returned; otherwise, an exception is thrown.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
TAO_RT_Info_Ex *
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
create_i (const char *entry_point,
RtecScheduler::handle_t handle,
int ignore_duplicates
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::DUPLICATE_NAME,
RtecScheduler::INTERNAL))
{
#if defined (SCHEDULER_LOGGING)
ACE_DEBUG ((LM_TRACE,
" TAO_Reconfig_Scheduler::create_i.\n"));
#endif /* SCHEDULER_LOGGING */
TAO_RT_Info_Ex* new_rt_info = 0;
TAO_Reconfig_Scheduler_Entry* new_sched_entry = 0;
int result = 0;
// If we're ignoring duplicates, check for and return the existing
// entry if there is one.
if (ignore_duplicates
&& rt_info_map_.find (handle, new_rt_info) == 0)
{
return new_rt_info;
}
// Create a new scheduling entry for the RT_Info.
ACE_NEW_THROW_EX (new_rt_info,
TAO_RT_Info_Ex,
CORBA::NO_MEMORY ());
ACE_CHECK_RETURN (0);
// Make sure the new scheduling entry is cleaned up if we exit abruptly.
auto_ptr<TAO_RT_Info_Ex> new_rt_info_ptr (new_rt_info);
// Set some reasonable default values, and store the passed ones.
new_rt_info->entry_point = CORBA::string_dup (entry_point);
new_rt_info->handle = handle;
// Bind the new RT_Info to its handle, in the RT_Info map.
result = rt_info_map_.bind (handle, new_rt_info);
switch (result)
{
case -1:
// Something bad but unknown occurred while trying to bind in map.
ACE_THROW_RETURN (RtecScheduler::INTERNAL (), 0);
case 1:
// Tried to bind an operation that was already in the map.
if (ignore_duplicates)
{
// Should never get here unless something is badly awry.
ACE_THROW_RETURN (RtecScheduler::INTERNAL (), 0);
}
else
{
// Already bound, and we're not ignoring duplicates.
ACE_THROW_RETURN (RtecScheduler::DUPLICATE_NAME (), 0);
}
default:
break;
}
// Bind the new RT_Info to *its* entry point, in the tree.
result = rt_info_tree_.bind (new_rt_info->entry_point, new_rt_info);
switch (result)
{
case -1:
// Something bad but unknown occurred while trying to bind in tree.
rt_info_map_.unbind (handle);
ACE_THROW_RETURN (RtecScheduler::INTERNAL (), 0);
case 1:
// Tried to bind an operation that was already in the tree.
rt_info_map_.unbind (handle);
ACE_THROW_RETURN (RtecScheduler::DUPLICATE_NAME (), 0);
default:
break;
}
// Create a new scheduling entry for the RT_Info.
ACE_NEW_THROW_EX (new_sched_entry,
TAO_Reconfig_Scheduler_Entry (*new_rt_info),
CORBA::NO_MEMORY ());
ACE_CHECK_RETURN (0);
// Make sure the new scheduling entry is cleaned up if we exit abruptly.
auto_ptr<TAO_Reconfig_Scheduler_Entry> new_sched_entry_ptr (new_sched_entry);
// Maintain the size of the entry pointer array.
::maintain_scheduling_array (entry_ptr_array_, entry_ptr_array_size_,
handle ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
// Store the new entry in the scheduling entry pointer array.
entry_ptr_array_ [handle - 1] = new_sched_entry;
// Release the auto pointers, so their destruction does not
// remove the new rt_info that is now in the map and tree,
// or the scheduling entry attached to the rt_info.
new_rt_info_ptr.release ();
new_sched_entry_ptr.release ();
// Connect the entry to the RT_Info.
new_rt_info->volatile_token =
ACE_static_cast (CORBA::ULongLong,
ACE_reinterpret_cast (ptrdiff_t,
new_sched_entry));
// With everything safely registered in the map and tree, just
// update the next handle and info counter and return the new info.
if (handle >= this->next_handle_)
{
this->next_handle_ = handle + 1;
}
if (handle > this->rt_info_count_)
{
this->rt_info_count_ = handle;
}
return new_rt_info;
}
// Internal method to set characteristics of the passed RT_Info.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK> void
TAO_Reconfig_Sc
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -