📄 reconfig_scheduler_t.cpp
字号:
// the RT_Info itself.
delete ACE_LONGLONG_TO_PTR (TAO_Reconfig_Scheduler_Entry *,
rt_info->volatile_token);
delete rt_info;
}
else
{
ACE_THROW (RtecScheduler::INTERNAL ());
}
}
else
{
ACE_THROW (RtecScheduler::UNKNOWN_TASK ());
}
}
// Delete each Config_Info in the map.
RtecScheduler::Preemption_Priority_t config_priority;
RtecScheduler::Config_Info *config_info;
while (config_info_map_.current_size () > 0)
{
config_priority = (*config_info_map_.begin ()).ext_id_;
if (config_info_map_.unbind (config_priority, config_info) == 0)
{
delete config_info;
}
else
{
ACE_THROW (RtecScheduler::INTERNAL ());
}
}
// Delete each dependency set in the caller map
RtecScheduler::Dependency_Set *dependency_set;
while (calling_dependency_set_map_.current_size () > 0)
{
handle = (*calling_dependency_set_map_.begin ()).ext_id_;
if (calling_dependency_set_map_.unbind (handle, dependency_set) == 0)
{
delete dependency_set;
}
else
{
ACE_THROW (RtecScheduler::INTERNAL ());
}
}
// Delete each dependency set in the called map
while (called_dependency_set_map_.current_size () > 0)
{
handle = (*called_dependency_set_map_.begin ()).ext_id_;
if (called_dependency_set_map_.unbind (handle, dependency_set) == 0)
{
delete dependency_set;
}
else
{
ACE_THROW (RtecScheduler::INTERNAL ());
}
}
// Zero out the scheduling entry pointer array but do not deallocate it.
if (entry_ptr_array_size_ > 0)
{
ACE_OS::memset (this->entry_ptr_array_, 0,
sizeof (TAO_Reconfig_Scheduler_Entry *)
* this->entry_ptr_array_size_);
}
// Zero out the scheduling entry pointer array but do not deallocate it.
if (tuple_ptr_array_size_ > 0)
{
ACE_OS::memset (this->tuple_ptr_array_, 0,
sizeof (TAO_RT_Info_Tuple *)
* this->tuple_ptr_array_size_);
}
// Finally, reset the entry counts and start over with the lowest
// handle number.
this->config_info_count_ = 0;
this->rt_info_count_ = 0;
this->rt_info_tuple_count_ = 0;
this->next_handle_ = 1;
}
// 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, an exception
// is thrown.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
RtecScheduler::handle_t
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
create (const char *entry_point
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::DUPLICATE_NAME,
RtecScheduler::INTERNAL,
RtecScheduler::SYNCHRONIZATION_FAILURE))
{
#if defined (SCHEDULER_LOGGING)
ACE_DEBUG ((LM_TRACE,
" TAO_Reconfig_Scheduler::create.\n"));
#endif /* SCHEDULER_LOGGING */
ACE_GUARD_THROW_EX (ACE_LOCK, ace_mon, this->mutex_,
RtecScheduler::SYNCHRONIZATION_FAILURE ());
ACE_CHECK_RETURN (0);
RtecScheduler::handle_t handle = next_handle_;
create_i (entry_point, handle, 0 ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (handle);
// Set affected stability flags.
this->stability_flags_ |=
SCHED_UTILIZATION_NOT_STABLE |
SCHED_PRIORITY_NOT_STABLE;
return handle;
}
// Lookup a handle for an RT_Info, and return its handle, or an error
// value if it's not present.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
RtecScheduler::handle_t
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
lookup (const char * entry_point
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::UNKNOWN_TASK,
RtecScheduler::SYNCHRONIZATION_FAILURE))
{
#if defined (SCHEDULER_LOGGING)
ACE_DEBUG ((LM_TRACE,
" TAO_Reconfig_Scheduler::lookup.\n"));
#endif /* SCHEDULER_LOGGING */
ACE_GUARD_THROW_EX (ACE_LOCK, ace_mon, this->mutex_,
RtecScheduler::SYNCHRONIZATION_FAILURE ());
ACE_CHECK_RETURN (0);
RtecScheduler::handle_t handle;
handle = this->lookup_i (entry_point ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (handle);
return handle;
}
// Return a pointer to the RT_Info corresponding to the passed handle.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
RtecScheduler::RT_Info *
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
get (RtecScheduler::handle_t handle
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC((CORBA::SystemException,
RtecScheduler::UNKNOWN_TASK,
RtecScheduler::SYNCHRONIZATION_FAILURE))
{
#if defined (SCHEDULER_LOGGING)
ACE_DEBUG ((LM_TRACE,
" TAO_Reconfig_Scheduler::get.\n"));
#endif /* SCHEDULER_LOGGING */
ACE_GUARD_THROW_EX (ACE_LOCK, ace_mon, this->mutex_,
RtecScheduler::SYNCHRONIZATION_FAILURE ());
ACE_CHECK_RETURN (0);
// Find the RT_Info in the hash map.
TAO_RT_Info_Ex *rt_info = 0;
if (rt_info_map_.find (handle, rt_info) != 0)
{
ACE_THROW_RETURN (RtecScheduler::UNKNOWN_TASK (), 0);
}
// Allocate a new RT_Info
RtecScheduler::RT_Info* new_info;
ACE_NEW_THROW_EX (new_info,
RtecScheduler::RT_Info,
CORBA::NO_MEMORY ());
ACE_CHECK_RETURN (0);
*new_info = *rt_info;
return new_info;
}
// Set characteristics of the RT_Info corresponding to the passed handle.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
void
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
set (RtecScheduler::handle_t handle,
RtecScheduler::Criticality_t criticality,
RtecScheduler::Time time,
RtecScheduler::Time typical_time,
RtecScheduler::Time cached_time,
RtecScheduler::Period_t period,
RtecScheduler::Importance_t importance,
RtecScheduler::Quantum_t quantum,
CORBA::Long threads,
RtecScheduler::Info_Type_t info_type
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::UNKNOWN_TASK,
RtecScheduler::INTERNAL,
RtecScheduler::SYNCHRONIZATION_FAILURE))
{
#if defined (SCHEDULER_LOGGING)
ACE_DEBUG ((LM_TRACE,
" TAO_Reconfig_Scheduler::set.\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 if it was disabled. Does not modify NON_VOLATILE ops.
if (rt_info_ptr->enabled_state () == RtecScheduler::RT_INFO_DISABLED)
{
rt_info_ptr->enabled_state (RtecScheduler::RT_INFO_ENABLED);
}
// Call the internal set method.
this->set_i (rt_info_ptr, criticality, time, typical_time,
cached_time, period, importance, quantum,
threads, info_type ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
// Update stability flags. For now, just mark everything as unstable.
// @@ TODO - revisit this and see if we can efficiently detect when
// changes do not affect stability of various aspects.
this->stability_flags_ |= SCHED_UTILIZATION_NOT_STABLE;
this->stability_flags_ |= SCHED_PRIORITY_NOT_STABLE;
this->stability_flags_ |= SCHED_PROPAGATION_NOT_STABLE;
return;
}
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
void
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
reset (RtecScheduler::handle_t handle,
RtecScheduler::Criticality_t criticality,
RtecScheduler::Time time,
RtecScheduler::Time typical_time,
RtecScheduler::Time cached_time,
RtecScheduler::Period_t period,
RtecScheduler::Importance_t importance,
RtecScheduler::Quantum_t quantum,
CORBA::Long threads,
RtecScheduler::Info_Type_t info_type
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::UNKNOWN_TASK,
RtecScheduler::INTERNAL,
RtecScheduler::SYNCHRONIZATION_FAILURE))
{
#if defined (SCHEDULER_LOGGING)
ACE_DEBUG ((LM_TRACE,
" TAO_Reconfig_Scheduler::reset.\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 if it was disabled. Does not modify NON_VOLATILE ops.
if (rt_info_ptr->enabled_state () == RtecScheduler::RT_INFO_NON_VOLATILE)
{
ACE_THROW (RtecScheduler::UNKNOWN_TASK ());
}
else
{
// Reset the RT_Info.
rt_info_ptr->reset (TAO_Reconfig_Scheduler_Entry::ORIGINAL
| TAO_Reconfig_Scheduler_Entry::PROPAGATED);
rt_info_ptr->enabled_state (RtecScheduler::RT_INFO_ENABLED);
}
// Refresh the internal tuple pointer array.
this->refresh_tuple_ptr_array_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
// Then call the internal set method.
this->set_i (rt_info_ptr, criticality, time, typical_time,
cached_time, period, importance, quantum,
threads, info_type ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
// Update stability flags. For now, just mark everything as unstable.
// @@ TODO - revisit this and see if we can efficiently detect when
// changes do not affect stability of various aspects.
this->stability_flags_ |= SCHED_UTILIZATION_NOT_STABLE;
this->stability_flags_ |= SCHED_PRIORITY_NOT_STABLE;
this->stability_flags_ |= SCHED_PROPAGATION_NOT_STABLE;
return;
}
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
void
TAO_Reconfig_Scheduler<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
set_seq (const RtecScheduler::RT_Info_Set& infos
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RtecScheduler::UNKNOWN_TASK,
RtecScheduler::INTERNAL,
RtecScheduler::SYNCHRONIZATION_FAILURE))
{
#if defined (SCHEDULER_LOGGING)
ACE_DEBUG ((LM_TRACE,
" TAO_Reconfig_Scheduler::set_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 < infos.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 (infos[i].handle, rt_info_ptr) != 0)
{
ACE_THROW (RtecScheduler::UNKNOWN_TASK ());
}
if (rt_info_ptr == 0)
{
ACE_THROW (RtecScheduler::INTERNAL ());
}
// Enable the RT_Info if it was disabled. Does not modify NON_VOLATILE ops.
if (rt_info_ptr->enabled_state () == RtecScheduler::RT_INFO_DISABLED)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -