📄 reconfig_sched_utils_t.cpp
字号:
// ============================================================================
//
// Reconfig_Sched_Utils_T.cpp,v 1.15 2003/10/11 04:06:48 venkita Exp
//
// ============================================================================
//
// = LIBRARY
// orbsvcs
//
// = FILENAME
// Reconfig_Sched_Utils_T.cpp
//
// = AUTHOR
// Chris Gill <cdgill@cs.wustl.edu>
//
// ============================================================================
#ifndef TAO_RECONFIG_SCHED_UTILS_T_C
#define TAO_RECONFIG_SCHED_UTILS_T_C
#include "Reconfig_Sched_Utils_T.h"
#include "ace/Sched_Params.h"
#include "ace/ACE.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if !defined (__ACE_INLINE__)
#include "Reconfig_Sched_Utils_T.i"
#endif /* __ACE_INLINE__ */
ACE_RCSID(Sched, Reconfig_Sched_Utils_T, "Reconfig_Sched_Utils_T.cpp,v 1.15 2003/10/11 04:06:48 venkita Exp")
////////////////////////////////
// TAO_RSE_Dependency_Visitor //
////////////////////////////////
// Constructor.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
TAO_RSE_Dependency_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
TAO_RSE_Dependency_Visitor
(DEPENDENCY_SET_MAP & dependency_map, RT_INFO_MAP & rt_info_map)
: dependency_map_ (dependency_map),
rt_info_map_ (rt_info_map)
{
}
// Visit a Reconfig Scheduler Entry. This method calls protected hook
// methods that can be overridden by derived classes, according to the
// Template Method design pattern.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK> int
TAO_RSE_Dependency_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
visit (TAO_Reconfig_Scheduler_Entry &rse)
{
int result = 0;
/* WSOA merge - commented out
// Call unconditional action method, which performs any necessary
// modifications that are applied to each node unconditionally.
if (this->unconditional_action (rse) < 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"TAO_RSE_Dependency_Visitor::"
"visit: error from unconditional action.\n"), -1);
}
*/
// Call precondition hook method, and only proceed if the
// precondition returns 0 for success.
result = this->precondition (rse);
if (result < 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"TAO_RSE_Dependency_Visitor::"
"visit: error from precondition evaluation.\n"), -1);
}
if (result == 0)
{
// Call prefix action method, which performs any necessary
// modifications on the node prior to visiting its successors.
if (this->prefix_action (rse) < 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"TAO_RSE_Dependency_Visitor::"
"visit: error from prefix action.\n"), -1);
}
// Get the dependency set for the current entry.
RtecScheduler::Dependency_Set *dependency_set = 0;
if (dependency_map_.find (rse.actual_rt_info ()->handle,
dependency_set) == 0)
{
// Iterate over the set of dependencies for the current entry.
TAO_Reconfig_Scheduler_Entry * next_rse = 0;
TAO_RT_Info_Ex *next_rt_info;
for (u_int i = 0; i < dependency_set->length (); ++i)
{
// Skip over disabled dependencies
if ((*dependency_set) [i].enabled == RtecBase::DEPENDENCY_DISABLED)
{
continue;
}
// Take the handle from the dependency and use it
// to obtain an RT_Info pointer from the map.
if (rt_info_map_.find ((*dependency_set) [i].rt_info,
next_rt_info) != 0)
{
ACE_ERROR_RETURN ((LM_ERROR, "RT_Info (%i) not found.\n",
(*dependency_set) [i].rt_info), -1);
}
// Extract a pointer to the scheduling entry from the RT_Info.
if (next_rt_info == 0)
{
ACE_ERROR_RETURN ((LM_ERROR, "RT_Info in map was null.\n"),
-1);
}
// Reference the associated scheduling entry: the double cast is
// needed to ensure that the size of the pointer and the size of the
// stored magic cookie are the same (see the definition of
// ptr_arith_t in ACE to grok how this works portably).
next_rse =
ACE_LONGLONG_TO_PTR (TAO_Reconfig_Scheduler_Entry *,
next_rt_info->volatile_token);
if (next_rse == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"Entry pointer in RT_Info was null.\n"),
-1);
}
// Call pre-recursion action method, which performs any necessary
// modifications to a successor (or the entry) prior to recursing
// on the successor.
result = this->pre_recurse_action (rse, *next_rse,
(*dependency_set) [i]);
if (result < 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"TAO_RSE_Dependency_Visitor::visit: "
"error from pre-recursion action.\n"),
-1);
}
// If the pre-recursion action returned 0, visit the successor.
if (result == 0)
{
this->visit (*next_rse);
}
}
}
// Call postfix action method, which performs any necessary
// modifications on the node after visiting all its successors.
if (this->postfix_action (rse) < 0)
{
ACE_ERROR_RETURN ((LM_ERROR, "TAO_RSE_Dependency_Visitor::"
"visit: error from postfix action.\n"), -1);
}
}
return 0;
}
/* WSOA merge - commented out
// Performs an unconditional action when the entry is first reached.
// Returns 0 for success, and -1 if an error occurred.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK> int
TAO_RSE_Dependency_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
unconditional_action (TAO_Reconfig_Scheduler_Entry &rse)
{
// Default behavior: just return success.
ACE_UNUSED_ARG (rse);
return 0;
}
*/
// Tests whether or not any conditional actions should be taken for
// the entry. Returns 0 if the actions should be applied, 1 if the
// entry should be left alone, and -1 if an error occurred.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK> int
TAO_RSE_Dependency_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
precondition (TAO_Reconfig_Scheduler_Entry &rse)
{
// Only signal to proceed (0) if the passed entry is enabled or non-volatile
return (rse.enabled_state () == RtecScheduler::RT_INFO_DISABLED)
? 1
: 0;
}
// Performs an action on the entry prior to visiting any of
// its successors. Returns 0 on success and -1 on error.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK> int
TAO_RSE_Dependency_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
prefix_action (TAO_Reconfig_Scheduler_Entry &rse)
{
// Default behavior: just return success.
ACE_UNUSED_ARG (rse);
return 0;
}
// Performs an action on a successor entry prior to visiting
// it. Returns 0 on success and -1 on error.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK> int
TAO_RSE_Dependency_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
pre_recurse_action (TAO_Reconfig_Scheduler_Entry &entry,
TAO_Reconfig_Scheduler_Entry &successor,
const RtecScheduler::Dependency_Info &di)
{
// Default behavior: just return success.
ACE_UNUSED_ARG (entry);
ACE_UNUSED_ARG (successor);
ACE_UNUSED_ARG (di);
return 0;
}
// Performs an action on the entry after visiting all of
// its successors. Returns 0 on success and -1 on error.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK> int
TAO_RSE_Dependency_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
postfix_action (TAO_Reconfig_Scheduler_Entry &rse)
{
// Default behavior: just return success.
ACE_UNUSED_ARG (rse);
return 0;
}
/////////////////////////
// TAO_RSE_DFS_Visitor //
/////////////////////////
// Constructor.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
TAO_RSE_DFS_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
TAO_RSE_DFS_Visitor
(ACE_TYPENAME TAO_RSE_Dependency_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::DEPENDENCY_SET_MAP & dependency_map,
ACE_TYPENAME TAO_RSE_Dependency_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::RT_INFO_MAP & rt_info_map)
: TAO_RSE_Dependency_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>
(dependency_map, rt_info_map),
DFS_time_ (0)
{
}
// Makes sure the entry has not previously been visited in forward DFS.
// Returns 0 if the actions should be applied, 1 if the entry
// should be left alone, and -1 if an error occurred.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK> int
TAO_RSE_DFS_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
precondition (TAO_Reconfig_Scheduler_Entry &rse)
{
int result =
TAO_RSE_Dependency_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
precondition (rse);
return (result == 0)
? ((rse.fwd_dfs_status () == TAO_Reconfig_Scheduler_Entry::NOT_VISITED)
? 0
: 1)
: result;
}
// Marks entry as forward visited and sets its forward DFS start
// time, prior to visiting any of its successors. Returns 0 on
// success and -1 on error.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK> int
TAO_RSE_DFS_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
prefix_action (TAO_Reconfig_Scheduler_Entry &rse)
{
rse.fwd_dfs_status (TAO_Reconfig_Scheduler_Entry::VISITED);
rse.fwd_discovered (this->DFS_time_++);
return 0;
}
// Marks whether or not successor is a thread delineator prior to
// visiting it. Returns 0 on success and -1 on error.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK> int
TAO_RSE_DFS_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
pre_recurse_action (TAO_Reconfig_Scheduler_Entry &entry,
TAO_Reconfig_Scheduler_Entry &successor,
const RtecScheduler::Dependency_Info &di)
{
ACE_UNUSED_ARG (entry);
ACE_UNUSED_ARG (di);
// Enabled operations we reached via a dependency and that do not
// specify a period are not thread delineators.
if (successor.enabled_state () != RtecScheduler::RT_INFO_DISABLED
&& successor.actual_rt_info ()->period == 0
&& successor.actual_rt_info ()->threads == 0)
{
successor.is_thread_delineator (0);
}
return 0;
}
// Marks entry as forward finished and sets its forward DFS finish
// time, after all of its successors have been visited. Returns 0
// on success and -1 on error.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK> int
TAO_RSE_DFS_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
postfix_action (TAO_Reconfig_Scheduler_Entry &rse)
{
rse.fwd_dfs_status (TAO_Reconfig_Scheduler_Entry::FINISHED);
rse.fwd_finished (this->DFS_time_++);
return 0;
}
/////////////////////////
// TAO_RSE_SCC_Visitor //
/////////////////////////
// Constructor.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK>
TAO_RSE_SCC_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
TAO_RSE_SCC_Visitor
(ACE_TYPENAME TAO_RSE_Dependency_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::DEPENDENCY_SET_MAP & dependency_map,
ACE_TYPENAME TAO_RSE_Dependency_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::RT_INFO_MAP & rt_info_map)
: TAO_RSE_Dependency_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>
(dependency_map, rt_info_map),
DFS_time_ (0),
number_of_cycles_ (0),
in_a_cycle_ (0)
{
}
// Accessor for number of cycles detected in traversal.
template <class RECONFIG_SCHED_STRATEGY, class ACE_LOCK> int
TAO_RSE_SCC_Visitor<RECONFIG_SCHED_STRATEGY, ACE_LOCK>::
number_of_cycles (void)
{
return this->number_of_cycles_;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -