⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reconfig_sched_utils.cpp

📁 这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用于网络游戏医学图像网关的高qos要求.更详细的内容可阅读相应的材料
💻 CPP
📖 第 1 页 / 共 4 页
字号:
orig_tuple_subset ()
{
  return orig_tuple_subset_;
}


// Accessor for the set of tuples propagated via dependencies on
// other entries.
TUPLE_SET &
TAO_Reconfig_Scheduler_Entry::
prop_tuple_subset ()
{
  return prop_tuple_subset_;
}


TAO_RT_Info_Tuple *
TAO_Reconfig_Scheduler_Entry::
current_admitted_tuple ()
{
  return current_admitted_tuple_;
}


void
TAO_Reconfig_Scheduler_Entry::
current_admitted_tuple (TAO_RT_Info_Tuple * t)
{
  current_admitted_tuple_ = t;
}

// Accessor for flag indicating whether or not node is enabled.

RtecScheduler::RT_Info_Enabled_Type_t
TAO_Reconfig_Scheduler_Entry::
enabled_state () const
{
  return this->enabled_;
}


// Mutator for flag indicating whether or not node is enabled.

void
TAO_Reconfig_Scheduler_Entry::
enabled_state (RtecScheduler::RT_Info_Enabled_Type_t et)
{
  this->enabled_ = et;
}


////////////////////////////////////////////
// class TAO_Reconfig_Sched_Strategy_Base //
////////////////////////////////////////////

// Ordering function to compare the DFS finish times of
// two task entries, so qsort orders these in topological
// order, with the higher times *first*
int
TAO_Reconfig_Sched_Strategy_Base::comp_entry_finish_times (const void *first, const void *second)
{
  const TAO_Reconfig_Scheduler_Entry *first_entry =
    * ACE_reinterpret_cast (const TAO_Reconfig_Scheduler_Entry *const *,
                            first);

  const TAO_Reconfig_Scheduler_Entry *second_entry =
    * ACE_reinterpret_cast (const TAO_Reconfig_Scheduler_Entry *const *,
                            second);

  // sort blank entries to the end
  if (! first_entry)
  {
    return (second_entry) ? 1 : 0;
  }
  else if (! second_entry)
  {
    return -1;
  }

  // sort disabled entries to the end
  if (first_entry->enabled_state () == RtecScheduler::RT_INFO_DISABLED)
  {
    return (second_entry->enabled_state () == RtecScheduler::RT_INFO_DISABLED) ? 0 : 1;
  }
  else if (second_entry->enabled_state () == RtecScheduler::RT_INFO_DISABLED)
  {
    return -1;
  }

  // Sort entries with higher forward DFS finishing times before those
  // with lower forward DFS finishing times.
  if (first_entry->fwd_finished () >
      second_entry->fwd_finished ())
  {
    return -1;
  }
  else if (first_entry->fwd_finished () <
           second_entry->fwd_finished ())
  {
    return 1;
  }

  return 0;
}

// Determines whether or not an entry is critical, based on operation characteristics.
// returns 1 if critical, 0 if not

int
TAO_Reconfig_Sched_Strategy_Base::is_critical (TAO_Reconfig_Scheduler_Entry &rse)
{
  // Look at the underlying RT_Info's criticality field.
  return (rse.actual_rt_info ()->criticality == RtecScheduler::HIGH_CRITICALITY ||
          rse.actual_rt_info ()->criticality == RtecScheduler::VERY_HIGH_CRITICALITY)
         ? 1 : 0;
}

// Determines whether or not a tuple is critical, based on operation
// characteristics.  returns 1 if critical, 0 if not

int
TAO_Reconfig_Sched_Strategy_Base::is_critical (TAO_RT_Info_Tuple &t)
{
  // Look at the underlying RT_Info's criticality field.
  return (t.criticality == RtecScheduler::HIGH_CRITICALITY ||
          t.criticality == RtecScheduler::VERY_HIGH_CRITICALITY)
         ? 1 : 0;
}


// Compares two entries by subpriority alone.  Returns -1 if the first
// one is higher, 0 if they're the same, and 1 if the second one is
// higher.

int
TAO_Reconfig_Sched_Strategy_Base::compare_subpriority (TAO_Reconfig_Scheduler_Entry &lhs,
                                                       TAO_Reconfig_Scheduler_Entry &rhs)
{
  // First, compare importance.

  if (lhs.actual_rt_info ()->importance > rhs.actual_rt_info ()->importance)
    {
      return -1;
    }
  else if (lhs.actual_rt_info ()->importance < rhs.actual_rt_info ()->importance)
    {
      return 1;
    }

  // Same importance, so look at dfs finish time as a tiebreaker.

  else if (lhs.fwd_finished () > rhs.fwd_finished ())
    {
      return -1;
    }
  else if (lhs.fwd_finished () < rhs.fwd_finished ())
    {
      return 1;
    }

  // Same dfs finish time, so look at handle as a tiebreaker.

  else if (lhs.actual_rt_info ()->handle > rhs.actual_rt_info ()->handle)
    {
      return -1;
    }
  else if (lhs.actual_rt_info ()->handle < rhs.actual_rt_info ()->handle)
    {
      return 1;
    }

  // They're the same if we got here.
  return 0;
}


////////////////////////////////////////////////
// class TAO_MUF_FAIR_Reconfig_Sched_Strategy //
////////////////////////////////////////////////

// Ordering function used to qsort an array of TAO_RT_Info_Tuple
// pointers into a total <priority, subpriority> ordering.  Returns -1
// if the first one is higher, 0 if they're the same, and 1 if the
// second one is higher.

int
TAO_MUF_FAIR_Reconfig_Sched_Strategy::total_priority_comp (const void *s, const void *t)
{
  // Convert the passed pointers: the double cast is needed to
  // make Sun C++ 4.2 happy.
  TAO_Reconfig_Scheduler_Entry **first =
    ACE_reinterpret_cast (TAO_Reconfig_Scheduler_Entry **,
                          ACE_const_cast (void *, s));
  TAO_Reconfig_Scheduler_Entry **second =
    ACE_reinterpret_cast (TAO_Reconfig_Scheduler_Entry **,
                          ACE_const_cast (void *, t));

  // Check the converted pointers.
  if (first == 0 || *first == 0)
    {
      return (second == 0 || *second == 0) ? 0 : 1;
    }
  else if (second == 0 || *second == 0)
    {
      return -1;
    }

  // sort disabled entries to the end
  if ((*first)->enabled_state () == RtecScheduler::RT_INFO_DISABLED)
  {
    return ((*second)->enabled_state () == RtecScheduler::RT_INFO_DISABLED) ? 0 : 1;
  }
  else if ((*second)->enabled_state () == RtecScheduler::RT_INFO_DISABLED)
  {
    return -1;
  }

  int result =
    TAO_MUF_FAIR_Reconfig_Sched_Strategy::compare_priority (**first,
                                                            **second);

  // Check whether they were distinguished by priority.
  if (result == 0)
    {
      return TAO_Reconfig_Sched_Strategy_Base::compare_subpriority (**first,
                                                                    **second);
    }
  else
    {
      return result;
    }
}


// Ordering function used to qsort an array of RT_Info_Tuple
// pointers into a total ordering for admission control.  Returns
// -1 if the first one is higher, 0 if they're the same, and 1 if
// the second one is higher.

int
TAO_MUF_FAIR_Reconfig_Sched_Strategy::total_admission_comp (const void *s,
                                                            const void *t)
{
    // Convert the passed pointers: the double cast is needed to
  // make Sun C++ 4.2 happy.
  TAO_RT_Info_Tuple **first =
    ACE_reinterpret_cast (TAO_RT_Info_Tuple **,
                          ACE_const_cast (void *, s));

  TAO_Reconfig_Scheduler_Entry * first_entry =
      ACE_LONGLONG_TO_PTR (TAO_Reconfig_Scheduler_Entry *,
                           (*first)->volatile_token);

  TAO_RT_Info_Tuple **second =
    ACE_reinterpret_cast (TAO_RT_Info_Tuple **,
                          ACE_const_cast (void *, t));

  TAO_Reconfig_Scheduler_Entry * second_entry =
      ACE_LONGLONG_TO_PTR (TAO_Reconfig_Scheduler_Entry *,
                           (*second)->volatile_token);

  // Check the converted pointers.
  if (first == 0 || *first == 0)
    {
      return (second == 0 || *second == 0) ? 0 : 1;
    }
  else if (second == 0 || *second == 0)
    {
      return -1;
    }

  // sort disabled tuples to the end
  if ((*first)->enabled_state () == RtecScheduler::RT_INFO_DISABLED)
  {
    return ((*second)->enabled_state () == RtecScheduler::RT_INFO_DISABLED) ? 0 : 1;
  }
  else if ((*second)->enabled_state () == RtecScheduler::RT_INFO_DISABLED)
  {
    return -1;
  }

  // First, compare according to rate index.

  if ((*first)->rate_index < (*second)->rate_index)
    {
      return -1;
    }
  else if ((*second)->rate_index < (*first)->rate_index)
    {
      return 1;
    }

  // Then compare by priority.

  int result =
    TAO_MUF_FAIR_Reconfig_Sched_Strategy::compare_priority (**first, **second);
  if (result != 0)
    {
      return result;
    }

  // Then compare by subpriority.

  result = TAO_Reconfig_Sched_Strategy_Base::compare_subpriority (*first_entry,
                                                                  *second_entry);
  if (result != 0)
    {
      return result;
    }

  return 0;
}



// Compares two RT_Info entries by priority alone.  Returns -1 if the
// first one is higher, 0 if they're the same, and 1 if the second one is higher.

int
TAO_MUF_FAIR_Reconfig_Sched_Strategy::compare_priority (TAO_Reconfig_Scheduler_Entry &lhs,
                                                        TAO_Reconfig_Scheduler_Entry &rhs)
{
  // In MUF, priority is per criticality level: compare criticalities.
  if (lhs.actual_rt_info ()->criticality >
      rhs.actual_rt_info ()->criticality)
    {
      return -1;
    }
  else if (lhs.actual_rt_info ()->criticality <
           rhs.actual_rt_info ()->criticality)
    {
      return 1;
    }

  // They're the same if we got here.
  return 0;
}


// Compares two RT_Info tuples by priority alone.  Returns -1 if the
// first one is higher, 0 if they're the same, and 1 if the second one is higher.

int
TAO_MUF_FAIR_Reconfig_Sched_Strategy::compare_priority (TAO_RT_Info_Tuple &lhs,
                                                        TAO_RT_Info_Tuple &rhs)
{
  // In MUF, priority is per criticality level: compare criticalities.
  if (lhs.criticality > rhs.criticality)
    {
      return -1;
    }
  else if (lhs.criticality < rhs.criticality)
    {
      return 1;
    }

  // They're the same if we got here.
  return 0;
}


// Fills in a static dispatch configuration for a priority level, based
// on the operation characteristics of a representative scheduling entry.

int
TAO_MUF_FAIR_Reconfig_Sched_Strategy::assign_config (RtecScheduler::Config_Info &info,
                                                     TAO_Reconfig_Scheduler_Entry &rse)
{
    // Global and thread priority of dispatching queue are simply
    // those assigned the representative operation it will dispatch.
    info.preemption_priority = rse.actual_rt_info ()->preemption_priority;
    info.thread_priority = rse.actual_rt_info ()->priority;

    // Dispatching queues are all laxity-based in this strategy.
    info.dispatching_type = RtecScheduler::LAXITY_DISPATCHING;

  return 0;
}

///////////////////////////////////////////////////
// class TAO_RMS_FAIR_Reconfig_Sched_Strategy //
///////////////////////////////////////////////////


// Ordering function used to qsort an array of TAO_RT_Info_Tuple
// pointers into a total <priority, subpriority> ordering.  Returns -1
// if the first one is higher, 0 if they're the same, and 1 if the
// second one is higher.

int
TAO_RMS_FAIR_Reconfig_Sched_Strategy::total_priority_comp (const void *s, const void *t)
{
  // Convert the passed pointers: the double cast is needed to
  // make Sun C++ 4.2 happy.
  TAO_Reconfig_Scheduler_Entry **first =
    ACE_reinterpret_cast (TAO_Reconfig_Scheduler_Entry **,
                          ACE_const_cast (void *, s));
  TAO_Reconfig_Scheduler_Entry **second =
    ACE_reinterpret_cast (TAO_Reconfig_Scheduler_Entry **,
                          ACE_const_cast (void *, t));

  // Check the converted pointers.
  if (first == 0 || *first == 0)
    {
      return (second == 0 || *second == 0) ? 0 : 1;
    }
  else if (second == 0 || *second == 0)
    {
      return -1;
    }

  // sort disabled entries to the end
  if ((*first)->enabled_state () == RtecScheduler::RT_INFO_DISABLED)
  {
    return ((*second)->enabled_state () == RtecScheduler::RT_INFO_DISABLED) ? 0 : 1;
  }
  else if ((*second)->enabled_state () == RtecScheduler::RT_INFO_DISABLED)
  {
    return -1;
  }


  // Check whether they are distinguished by priority, and if not,
  // then by subpriority.

  int result =
    TAO_RMS_FAIR_Reconfig_Sched_Strategy::compare_priority (**first,
                                                               **second);

  if (result == 0)
    {
      return TAO_Reconfig_Sched_Strategy_Base::compare_subpriority (**first,
                                                                    **second);
    }
  else
    {
      return result;
    }
}


// Ordering function used to qsort an array of RT_Info_Tuple
// pointers into a total ordering for admission control.  Returns
// -1 if the first one is higher, 0 if they're the same, and 1 if
// the second one is higher.

int
TAO_RMS_FAIR_Reconfig_Sched_Strategy::total_admission_comp (const void *s,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -