summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrodrigu <crodrigu@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-02-12 00:24:51 +0000
committercrodrigu <crodrigu@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-02-12 00:24:51 +0000
commite004020d9adb6d553283f5b4ef9e29dae0edee29 (patch)
treebea4b0ee55e8ac2e3a0833a936d15fe7ea36316c
parentd74ace6de6cd1c5c864cff7f67e3661f681b55a2 (diff)
downloadATCD-e004020d9adb6d553283f5b4ef9e29dae0edee29.tar.gz
ChangeLogTag: Wed Feb 12 00:19:58 UTC 2003 Craig Rodrigues <crodrigu@bbn.com>
-rw-r--r--TAO/ChangeLog58
-rw-r--r--TAO/tao/RTCORBA/Linear_Priority_Mapping.cpp1
-rw-r--r--TAO/tao/RTCORBA/RT_ORBInitializer.cpp70
-rw-r--r--TAO/tao/RTCORBA/RT_ORBInitializer.h12
-rw-r--r--TAO/tao/RTCORBA/RT_ORB_Loader.cpp14
-rw-r--r--TAO/tao/RTCORBA/RT_Protocols_Hooks.cpp5
6 files changed, 140 insertions, 20 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 4e496feaae7..dc8d83e493c 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,61 @@
+Wed Feb 12 00:19:58 UTC 2003 Craig Rodrigues <crodrigu@bbn.com>
+
+ * tao/RTCORBA/Linear_Priority_Mapping.cpp (to_CORBA):
+ Unconditionally display error message upon priority mapping failure.
+ * tao/RTCORBA/RT_Protocol_Hooks.cpp: Display errno value and message
+ if setting the native thread priority fails.
+ * tao/RTCORBA/RT_ORBInitiializer.h:
+ Create a new class member variable sched_policy_flags_.
+ The value of sched_policy_flags_ is a bitmask value that can be one of
+ THR_SCHED_RR, THR_SCHED_FIFO, THR_SCHED_DEFAULT, etc.
+ sched_policy_flags_ value is stored in the
+ TAO_ORB_Core TAO_ORB_Parameters structure.
+ In TAO_Thread_Lane::create_dynamic_threads(), the sched_policy_flags_
+ is passed to the ACE_Task_Base::activate() call for creating new
+ threads for a RTCORBA thread pool.
+
+ sched_policy_ is an integer value that can be one of
+ ACE_SCHED_RR, ACE_SCHED_FIFO, ACE_SCHED_OTHER, etc. This value
+ can be passed directly to the newly modified ACE_OS::thr_setpriority()
+ call. For POSIX pthreads, this value maps directly to the
+ policy parameter of the pthread_setschedparam() call.
+ ACE_SCHED_* values can also be passed directly to ACE_Sched_Params
+ for determining the minimum and maximum priority value for a particular
+ policy.
+
+ * tao/RTCORBA/RT_ORBInitiializer.cpp:
+ Change all assignments of sched_policy_ variable to use
+ ACE_SCHED_* values and not THR_SCHED_* values.
+ In the TAO_RT_ORBInitializer constructor, set sched_policy_flags_
+ to the appropriate THR_SCHED_* values depending on what ACE_SCHED_*
+ value is specified.
+
+ In TAO_RT_ORBInitializer::pre_init(), pass sched_policy_flags_
+ to orb_core()->orb_params()->sched_policy(), since this value
+ will be later used in the activate() call in
+ TAO_Thread_Lane::create_dynamic_threads().
+
+ At the end of TAO_RT_ORBInitializer::pre_init(), set the policy
+ of the ACE_Thread::self() to the policy specified by -ORBSchedPolicy, and
+ set the priority of ACE_Thread::self() to the lowest priority
+ of the specified policy. If this is not done, then errors will
+ occur on Linux, because the default policy in ACE_OS::thr_setprio()
+ is 0 (which maps to SCHED_OTHER), which will cause strange errors
+ when the scheduling policy is set to something else, like SCHED_RR.
+
+ Since the return value of ACE_OS::thr_getprio() can be invalid for
+ a given policy, ie. 0 is valid for SCHED_OTHER, but invalid for
+ SCHED_RR, I then decided to set the priority to the minimum
+ priority of the policy/scheduling class.
+
+ In addition, in RTPortableServer's
+ TAO_RT_Servant_Dispatcher::post_invoke() function, the priority
+ of the thread will be reset to what it was before the invocation.
+ This means that on platforms which use pthread_setschedparam(),
+ the initial priority and policy of the thread need to be
+ set to acceptable initial values, otherwise CORBA::DATA_CONVERSION
+ errors will be thrown in this TAO_RT_Servant_Dispatcher::post_invoke().
+
Tue Feb 11 13:58:23 2003 Nanbor Wang <nanbor@cs.wustl.edu>
* orbsvcs/vc7_orbsvcs.mwc: Added this temporary file that
diff --git a/TAO/tao/RTCORBA/Linear_Priority_Mapping.cpp b/TAO/tao/RTCORBA/Linear_Priority_Mapping.cpp
index f45c7ae3ea0..9c169d29349 100644
--- a/TAO/tao/RTCORBA/Linear_Priority_Mapping.cpp
+++ b/TAO/tao/RTCORBA/Linear_Priority_Mapping.cpp
@@ -125,7 +125,6 @@ TAO_Linear_Priority_Mapping::to_CORBA (RTCORBA::NativePriority native_priority,
&& (native_priority < this->max_
|| native_priority > this->min_)))
{
- if (TAO_debug_level > 2)
ACE_DEBUG ((LM_DEBUG,
"TAO (%P|%t) - Linear_Priority_Mapping::to_CORBA: "
" priority %d out of range [%d,%d]\n",
diff --git a/TAO/tao/RTCORBA/RT_ORBInitializer.cpp b/TAO/tao/RTCORBA/RT_ORBInitializer.cpp
index 08d325042f4..d6df73592d7 100644
--- a/TAO/tao/RTCORBA/RT_ORBInitializer.cpp
+++ b/TAO/tao/RTCORBA/RT_ORBInitializer.cpp
@@ -30,6 +30,7 @@ ACE_RCSID (TAO, RT_ORBInitializer, "$Id$")
#include "ace/Service_Repository.h"
#include "ace/Svc_Conf.h"
+#include "ace/Sched_Params.h"
static const char *rt_poa_factory_name = "TAO_RT_POA";
static const char *rt_poa_factory_directive = "dynamic TAO_RT_POA Service_Object * TAO_RTPortableServer:_make_TAO_RT_Object_Adapter_Factory()";
@@ -41,8 +42,25 @@ TAO_RT_ORBInitializer::TAO_RT_ORBInitializer (int priority_mapping_type,
: priority_mapping_type_ (priority_mapping_type),
network_priority_mapping_type_ (network_priority_mapping_type),
sched_policy_ (sched_policy),
+ sched_policy_flags_ (0),
scope_policy_ (scope_policy)
{
+ switch (sched_policy_)
+ {
+ case ACE_SCHED_RR:
+ sched_policy_flags_ = THR_SCHED_RR;
+ break;
+ case ACE_SCHED_FIFO:
+ sched_policy_flags_ = THR_SCHED_FIFO;
+ break;
+ case ACE_SCHED_OTHER:
+ sched_policy_flags_ = THR_SCHED_DEFAULT;
+ break;
+ default:
+ ACE_DEBUG((LM_DEBUG, ACE_LIB_TEXT("(%N,%l) Unknown sched_policy value.\nDefaulting to THR_SCHED_DEFAULT for sched_policy_flags_.\n") ));
+ sched_policy_flags_ = THR_SCHED_DEFAULT;
+ break;
+ }
}
void
@@ -83,29 +101,22 @@ TAO_RT_ORBInitializer::pre_init (
TAO_RT_Protocols_Hooks::set_server_protocols_hook
(TAO_ServerProtocolPolicy::hook);
- // Conversion.
- long sched_policy = ACE_SCHED_OTHER;
- if (this->sched_policy_ == THR_SCHED_FIFO)
- sched_policy = ACE_SCHED_FIFO;
- else if (this->sched_policy_ == THR_SCHED_RR)
- sched_policy = ACE_SCHED_RR;
-
// Create the initial priority mapping instance.
TAO_Priority_Mapping *pm;
switch (this->priority_mapping_type_)
{
case TAO_PRIORITY_MAPPING_CONTINUOUS:
ACE_NEW (pm,
- TAO_Continuous_Priority_Mapping (sched_policy));
+ TAO_Continuous_Priority_Mapping (this->sched_policy_));
break;
case TAO_PRIORITY_MAPPING_LINEAR:
ACE_NEW (pm,
- TAO_Linear_Priority_Mapping (sched_policy));
+ TAO_Linear_Priority_Mapping (this->sched_policy_));
break;
default:
case TAO_PRIORITY_MAPPING_DIRECT:
ACE_NEW (pm,
- TAO_Direct_Priority_Mapping (sched_policy));
+ TAO_Direct_Priority_Mapping (this->sched_policy_));
break;
}
@@ -136,7 +147,7 @@ TAO_RT_ORBInitializer::pre_init (
default:
case TAO_NETWORK_PRIORITY_MAPPING_LINEAR:
ACE_NEW (npm,
- TAO_Linear_Network_Priority_Mapping (sched_policy));
+ TAO_Linear_Network_Priority_Mapping (this->sched_policy_));
break;
}
@@ -215,7 +226,42 @@ TAO_RT_ORBInitializer::pre_init (
ACE_CHECK;
tao_info->orb_core ()->orb_params ()->scope_policy (this->scope_policy_);
- tao_info->orb_core ()->orb_params ()->sched_policy (this->sched_policy_);
+
+ /* We need to store sched_policy_flags_ and not sched_policy_ in the
+ * orb_params(), because in TAO_Thread_Lane::create_dynamic_threads(),
+ * the flags are passed to ACE_Task_Base::activate() in order to set
+ * the priority.
+ */
+ tao_info->orb_core ()->orb_params ()->sched_policy (this->sched_policy_flags_);
+
+ /* Based on what the scheduling policy is, set the priority to the lowest
+ * priority for that scheduling policy. We need to do this in order to
+ * set the pthread policy for pthread_setschedparam().
+ * Also, we want the pthread policy and priority to be set to a sensible
+ * value, since the post_invoke() operation in the RT-POA will reset the
+ * CORBA priority to what it was before an incoming request.
+ */
+ int priority;
+ ACE_hthread_t thr_id;
+ ACE_Thread::self(thr_id);
+
+ int result = ACE_OS::thr_getprio(thr_id, priority);
+ if ( result != 0 ) {
+ ACE_ERROR ((LM_ERROR, "(%N,%l) ACE_OS::thr_getprio failed, priority %d errno %p\n", priority));
+ return;
+ }
+
+ int priority_min = ACE_Sched_Params::priority_min(this->sched_policy_);
+ int priority_max = ACE_Sched_Params::priority_max(this->sched_policy_);
+ if(priority < priority_min || priority > priority_max) { // Check this
+ priority = priority_min;
+ }
+
+ result = ACE_OS::thr_setprio(thr_id, priority, this->sched_policy_);
+ if ( result != 0 ) {
+ ACE_ERROR ((LM_ERROR, "(%N,%l) ACE_OS::thr_setprio failed, priority %d errno %p\n", priority));
+ }
+
}
void
diff --git a/TAO/tao/RTCORBA/RT_ORBInitializer.h b/TAO/tao/RTCORBA/RT_ORBInitializer.h
index f03b0ff864d..395aa0d70e6 100644
--- a/TAO/tao/RTCORBA/RT_ORBInitializer.h
+++ b/TAO/tao/RTCORBA/RT_ORBInitializer.h
@@ -88,9 +88,19 @@ private:
/// Network Priority mapping type.
int network_priority_mapping_type_;
- /// Scheduling policy.
+ /** Scheduling policy. This value is passed to ACE_OS::thr_setprio().
+ * For POSIX pthreads, it maps directly to the pthread_setschedparam() policy
+ * parameter. Legal values are ACE_SCHED_RR, ACE_SCHED_FIFO,
+ * ACE_SCHED_OTHER, ACE_SCHED_*, etc.
+ */
long sched_policy_;
+ /** Scheduling policy flags. This value is passed as part of the
+ * flags argument to ACE_Task_Base::activate(). Legal values are
+ * THR_SCHED_RR, THR_SCHED_FIFO, THR_SCHED_DEFAULT, etc.
+ */
+ long sched_policy_flags_;
+
/// Scope policy.
long scope_policy_;
};
diff --git a/TAO/tao/RTCORBA/RT_ORB_Loader.cpp b/TAO/tao/RTCORBA/RT_ORB_Loader.cpp
index e13bf36fea5..586001c7399 100644
--- a/TAO/tao/RTCORBA/RT_ORB_Loader.cpp
+++ b/TAO/tao/RTCORBA/RT_ORB_Loader.cpp
@@ -35,7 +35,7 @@ TAO_RT_ORB_Loader::init (int argc,
// Set defaults.
int priority_mapping_type = TAO_RT_ORBInitializer::TAO_PRIORITY_MAPPING_DIRECT;
int network_priority_mapping_type = TAO_RT_ORBInitializer::TAO_NETWORK_PRIORITY_MAPPING_LINEAR;
- long sched_policy = THR_SCHED_DEFAULT;
+ long sched_policy = -1;
long scope_policy = THR_SCOPE_PROCESS;
int curarg = 0;
@@ -75,13 +75,13 @@ TAO_RT_ORB_Loader::init (int argc,
if (ACE_OS::strcasecmp (name,
ACE_LIB_TEXT("SCHED_OTHER")) == 0)
- sched_policy = THR_SCHED_DEFAULT;
+ sched_policy = ACE_SCHED_OTHER;
else if (ACE_OS::strcasecmp (name,
ACE_LIB_TEXT("SCHED_FIFO")) == 0)
- sched_policy = THR_SCHED_FIFO;
+ sched_policy = ACE_SCHED_FIFO;
else if (ACE_OS::strcasecmp (name,
ACE_LIB_TEXT("SCHED_RR")) == 0)
- sched_policy = THR_SCHED_RR;
+ sched_policy = ACE_SCHED_RR;
else
ACE_DEBUG ((LM_DEBUG,
ACE_LIB_TEXT("RT_ORB_Loader - unknown argument")
@@ -134,6 +134,12 @@ TAO_RT_ORB_Loader::init (int argc,
}
}
+ if (sched_policy == -1) {
+ ACE_ERROR_RETURN( (LM_ERROR,
+ ACE_LIB_TEXT("(%N,%l) -ORBSchedPolicy not defined.\n") ),
+ -1);
+ }
+
// Register the ORB initializer.
ACE_TRY_NEW_ENV
{
diff --git a/TAO/tao/RTCORBA/RT_Protocols_Hooks.cpp b/TAO/tao/RTCORBA/RT_Protocols_Hooks.cpp
index 3a8d90c2553..e01ab7aa269 100644
--- a/TAO/tao/RTCORBA/RT_Protocols_Hooks.cpp
+++ b/TAO/tao/RTCORBA/RT_Protocols_Hooks.cpp
@@ -596,8 +596,9 @@ TAO_RT_Protocols_Hooks::set_thread_native_priority (CORBA::Short native_priority
ACE_hthread_t current;
ACE_Thread::self (current);
- if (ACE_Thread::setprio (current, native_priority) == -1)
- return -1;
+ if (ACE_Thread::setprio (current, native_priority) == -1) {
+ ACE_ERROR_RETURN((LM_ERROR, ACE_LIB_TEXT("(%N,%l) Error setting thread priority to %d, errno %d %m\n"), native_priority, errno ), -1);
+ }
return 0;
}