summaryrefslogtreecommitdiff
path: root/Kokyu/DSRT_Schedulers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Kokyu/DSRT_Schedulers.cpp')
-rw-r--r--Kokyu/DSRT_Schedulers.cpp86
1 files changed, 52 insertions, 34 deletions
diff --git a/Kokyu/DSRT_Schedulers.cpp b/Kokyu/DSRT_Schedulers.cpp
index 63f4360ae4d..ea320838205 100644
--- a/Kokyu/DSRT_Schedulers.cpp
+++ b/Kokyu/DSRT_Schedulers.cpp
@@ -20,10 +20,28 @@ DSRT_Scheduler_Impl::DSRT_Scheduler_Impl ()
min_prio_ (ACE_Sched_Params::priority_min (sched_policy_, sched_scope_)),
max_prio_ (ACE_Sched_Params::priority_max (sched_policy_, sched_scope_))
{
+#if defined (ACE_WIN32)
+ // Count up the number of distinct native priorities on current
+ // platform.
+ int n;
+ Priority_t current_priority = this->min_prio_;
+ for (n = 1; current_priority != this->max_; ++n)
+ {
+ current_priority =
+ ACE_Sched_Params::next_priority (this->sched_policy_,
+ current_priority);
+ }
+
+ this->prio_range_ = n-1;
+
+#else
+ this->prio_range_ = this->max_prio_ - this->min_prio_;
+#endif /* ACE_WIN32 */
+
}
int
-DSRT_Scheduler_Impl::schedule (guid_t id, const QoSDescriptor& qos)
+DSRT_Scheduler_Impl::schedule (guid_t id, const DSRT_QoSDescriptor& qos)
{
return this->schedule_i (id, qos);
}
@@ -94,8 +112,34 @@ MIF_Scheduler_Impl::init (int argc, ACE_TCHAR* argv[])
arg_shifter.consume_arg ();
}
}
+ else if (ACE_OS::strcasecmp (arg, ACE_LIB_TEXT("-min_importance")) == 0)
+ {
+ arg_shifter.consume_arg ();
+
+ if (arg_shifter.is_parameter_next ())
+ {
+ const ACE_TCHAR* opt = arg_shifter.get_current ();
+ this->min_importance_ = ACE_OS::atoi (opt);
+ arg_shifter.consume_arg ();
+ }
+ }
+ else if (ACE_OS::strcasecmp (arg, ACE_LIB_TEXT("-max_importance")) == 0)
+ {
+ arg_shifter.consume_arg ();
+
+ if (arg_shifter.is_parameter_next ())
+ {
+ const ACE_TCHAR* opt = arg_shifter.get_current ();
+ this->max_importance_ = ACE_OS::atoi (opt);
+ arg_shifter.consume_arg ();
+ }
+ }
}
+ this->importance_range_ = this->max_importance_ - this->min_importance_;
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("MIF_Scheduler: importance_range = %d\n"),
+ this->importance_range_));
return 0;
}
@@ -106,44 +150,14 @@ MIF_Scheduler_Impl::fini (void)
}
Priority_t
-MIF_Scheduler_Impl::schedule_i (guid_t id, const QoSDescriptor& qos)
+MIF_Scheduler_Impl::schedule_i (guid_t id, const DSRT_QoSDescriptor& qos)
{
ACE_UNUSED_ARG ((id));
ACE_DEBUG ((LM_DEBUG, "(%t) request for MIF schedule\n"));
- switch (qos.importance_)
- {
- case VERY_LOW_IMPORTANCE:
- return min_prio_;
- break;
-
- case LOW_IMPORTANCE:
- return ACE_Sched_Params::next_priority
- (sched_policy_, min_prio_, sched_scope_);
- break;
-
- case MEDIUM_IMPORTANCE:
- return ACE_Sched_Params::next_priority
- (sched_policy_,
- ACE_Sched_Params::next_priority
- (sched_policy_, min_prio_, sched_scope_),
- sched_scope_);
- break;
-
- case HIGH_IMPORTANCE:
- return ACE_Sched_Params::previous_priority
- (sched_policy_, max_prio_, sched_scope_);
- break;
-
- case VERY_HIGH_IMPORTANCE:
- return max_prio_;
- break;
-
- default:
- break;
- }
+ Priority_t prio_ = qos.importance_ * this->prio_range_ / this->importance_range_;
- return min_prio_;
+ return prio_;
}
@@ -151,6 +165,10 @@ MIF_Scheduler_Impl::schedule_i (guid_t id, const QoSDescriptor& qos)
// ****************************************************************
+//could not use ACE_FACTORY_DEFINE macro here because of Kokyu namespace
+// see new Kokyu::MIF_Scheduler_Impl in _make_xx factory function
+//need to revisit later
+
void _gobble_MIF_Scheduler_Impl (void *p) { \
ACE_Service_Object *_p = ACE_static_cast (ACE_Service_Object *, p);
ACE_ASSERT (_p != 0);