summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryamuna <yamuna@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-01-17 21:09:36 +0000
committeryamuna <yamuna@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-01-17 21:09:36 +0000
commit75a342198e9d81a31980e21d79c295fe06901359 (patch)
treeebaa1f9d06f610b2f4a61c57e41f90175cd6da0b
parent44093e523e234227f5d39d58a9e9ee1b40352ec0 (diff)
downloadATCD-RTCORBA_Diffserv.tar.gz
*** empty log message ***RTCORBA_Diffserv
-rw-r--r--TAO/examples/RTCORBA/Activity/Activity.cpp33
-rw-r--r--TAO/examples/RTCORBA/Activity/Activity.h1
-rwxr-xr-xTAO/examples/RTCORBA/Activity/Job.idl4
-rw-r--r--TAO/examples/RTCORBA/Activity/Job_i.cpp3
-rw-r--r--TAO/examples/RTCORBA/Activity/Job_i.h3
-rw-r--r--TAO/examples/RTCORBA/Activity/Periodic_Task.cpp33
-rw-r--r--TAO/examples/RTCORBA/Activity/Periodic_Task.h3
-rwxr-xr-xTAO/examples/RTCORBA/Activity/README6
-rw-r--r--TAO/examples/RTCORBA/Activity/Thread_Task.cpp105
-rw-r--r--TAO/examples/RTCORBA/Activity/Thread_Task.h2
10 files changed, 156 insertions, 37 deletions
diff --git a/TAO/examples/RTCORBA/Activity/Activity.cpp b/TAO/examples/RTCORBA/Activity/Activity.cpp
index 1d9a3966392..ffcf31fa9d5 100644
--- a/TAO/examples/RTCORBA/Activity/Activity.cpp
+++ b/TAO/examples/RTCORBA/Activity/Activity.cpp
@@ -11,6 +11,7 @@
#include "Job_i.h"
#include "POA_Holder.h"
#include "Builder.h"
+#include "Task_Stats.h"
//***************************************************************//
extern "C" void handler (int)
@@ -47,6 +48,12 @@ Activity::orb (void)
return orb_.in ();
}
+RTCORBA::RTORB_ptr
+Activity::rt_orb (void)
+{
+ return rt_orb_.in ();
+}
+
long
Activity::scope_policy (void)
{
@@ -239,10 +246,16 @@ Activity::activate_schedule (ACE_ENV_SINGLE_ARG_DECL)
name.length (1);
name[0].id = CORBA::string_dup (task->job ());
- CORBA::Object_var obj =
- this->naming_->resolve (name ACE_ENV_ARG_PARAMETER);
+ ACE_DEBUG ((LM_DEBUG,
+ "Before resolve %s\n",
+ task->job ()));
+
+ CORBA::Object_var obj = this->naming_->resolve (name ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
+ ACE_DEBUG ((LM_DEBUG,
+ "After resolve\n"));
+
Job_var job = Job::_narrow (obj.in () ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
@@ -254,12 +267,12 @@ Activity::activate_schedule (ACE_ENV_SINGLE_ARG_DECL)
job->_get_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
-
+
RTCORBA::PriorityModelPolicy_var priority_policy =
RTCORBA::PriorityModelPolicy::_narrow (policy.in ()
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
-
+
if (CORBA::is_nil (priority_policy.in ()))
ACE_DEBUG ((LM_DEBUG,
"ERROR: Priority Model Policy not exposed!\n"));
@@ -268,7 +281,7 @@ Activity::activate_schedule (ACE_ENV_SINGLE_ARG_DECL)
RTCORBA::PriorityModel priority_model =
priority_policy->priority_model (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
-
+
if (priority_model == RTCORBA::CLIENT_PROPAGATED)
ACE_DEBUG ((LM_DEBUG,
"%s priority_model = RTCORBA::CLIENT_PROPAGATED\n", task->job ()));
@@ -277,14 +290,14 @@ Activity::activate_schedule (ACE_ENV_SINGLE_ARG_DECL)
"%s priority_model = RTCORBA::SERVER_DECLARED\n", task->job ()));
}
} /* if (TAO_debug_level > 0) */
-
+
task->job (job.in ());
task->activate_task (barrier_);
active_task_count_++;
-
+
ACE_DEBUG ((LM_DEBUG, "Job %s scheduled\n", task->job ()));
}
-
+
ACE_DEBUG ((LM_DEBUG, "Waiting for tasks to synch..."));
barrier_->wait ();
ACE_DEBUG ((LM_DEBUG, "Tasks have synched..."));
@@ -462,6 +475,8 @@ main (int argc, char *argv[])
ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGHUP);
+ BASE_TIME::instance ();
+
ACE_Timer_Heap timer_queue;
ACE_Reactor::instance ()->set_timer_queue (&timer_queue);
@@ -473,7 +488,7 @@ main (int argc, char *argv[])
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
- "Caught exception:");
+ "Caught exception: Activity\n");
return 1;
}
ACE_ENDTRY;
diff --git a/TAO/examples/RTCORBA/Activity/Activity.h b/TAO/examples/RTCORBA/Activity/Activity.h
index f26bf91a408..e2e303f127f 100644
--- a/TAO/examples/RTCORBA/Activity/Activity.h
+++ b/TAO/examples/RTCORBA/Activity/Activity.h
@@ -55,6 +55,7 @@ public:
/// = Accessors
CORBA::ORB_ptr orb (void);
+ RTCORBA::RTORB_ptr rt_orb (void);
RTCORBA::Current_ptr current (void);
long scope_policy (void);
long sched_policy (void);
diff --git a/TAO/examples/RTCORBA/Activity/Job.idl b/TAO/examples/RTCORBA/Activity/Job.idl
index 67c6efa531b..5b5ee49895f 100755
--- a/TAO/examples/RTCORBA/Activity/Job.idl
+++ b/TAO/examples/RTCORBA/Activity/Job.idl
@@ -4,7 +4,9 @@
interface Job
{
- void work (in unsigned long work);
+ typedef sequence<octet> data;
+ void work (in unsigned long work,
+ in data payload);
oneway void shutdown ();
};
diff --git a/TAO/examples/RTCORBA/Activity/Job_i.cpp b/TAO/examples/RTCORBA/Activity/Job_i.cpp
index 69320dc5323..edcff3b2206 100644
--- a/TAO/examples/RTCORBA/Activity/Job_i.cpp
+++ b/TAO/examples/RTCORBA/Activity/Job_i.cpp
@@ -35,7 +35,8 @@ Job_i::init (ACE_Arg_Shifter& arg_shifter)
}
void
-Job_i::work (CORBA::ULong work ACE_ENV_ARG_DECL_NOT_USED)
+Job_i::work (CORBA::ULong work,
+ const Job::data& ACE_ENV_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException))
{
static CORBA::ULong prime_number = 9619;
diff --git a/TAO/examples/RTCORBA/Activity/Job_i.h b/TAO/examples/RTCORBA/Activity/Job_i.h
index 3426fda03df..55ca6d6edc1 100644
--- a/TAO/examples/RTCORBA/Activity/Job_i.h
+++ b/TAO/examples/RTCORBA/Activity/Job_i.h
@@ -38,7 +38,8 @@ class activity_Export Job_i : public POA_Job, public virtual PortableServer::Ref
const ACE_CString& poa (void);
/// = inteface Job method implementation.
- virtual void work (CORBA::ULong work ACE_ENV_ARG_DECL)
+ virtual void work (CORBA::ULong work,
+ const Job::data& payload ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((
CORBA::SystemException
));
diff --git a/TAO/examples/RTCORBA/Activity/Periodic_Task.cpp b/TAO/examples/RTCORBA/Activity/Periodic_Task.cpp
index 03a87bb3a6c..079a101c280 100644
--- a/TAO/examples/RTCORBA/Activity/Periodic_Task.cpp
+++ b/TAO/examples/RTCORBA/Activity/Periodic_Task.cpp
@@ -51,6 +51,14 @@ Periodic_Task::init_task (ACE_Arg_Shifter& arg_shifter)
{
exec_time_ = ACE_OS::atoi (current_arg);
arg_shifter.consume_arg ();
+
+ if (exec_time_ != 0)
+ {
+ ACE_NEW_RETURN (task_stats_, Task_Stats (5000), -1);
+
+ if (task_stats_->init () == -1)
+ return -1;
+ }
}
else if ((current_arg = arg_shifter.get_the_parameter ("-Phase")))
{
@@ -61,20 +69,31 @@ Periodic_Task::init_task (ACE_Arg_Shifter& arg_shifter)
{
iter_ = ACE_OS::atoi (current_arg);
arg_shifter.consume_arg ();
-
- // create the stat object.
- ACE_NEW_RETURN (task_stats_, Task_Stats (iter_), -1);
-
- if (task_stats_->init () == -1)
- return -1;
+
+ if (iter_ != 0)
+ {
+ // create the stat object.
+ ACE_NEW_RETURN (task_stats_, Task_Stats (iter_), -1);
+
+ if (task_stats_->init () == -1)
+ return -1;
+ }
}
else if ((current_arg = arg_shifter.get_the_parameter ("-Load")))
{
load_ = ACE_OS::atoi (current_arg);
arg_shifter.consume_arg ();
+ }
+ else if ((current_arg = arg_shifter.get_the_parameter ("-Diffserv")))
+ {
+ enable_network_priority_ = ACE_OS::atoi (current_arg);
+ arg_shifter.consume_arg ();
+ ACE_DEBUG ((LM_DEBUG,
+ "Enable Network Priority %d\n",
+ enable_network_priority_));
return 0;
- }
+ }
else
{
ACE_DEBUG ((LM_DEBUG, "parse Task unknown option %s\n",
diff --git a/TAO/examples/RTCORBA/Activity/Periodic_Task.h b/TAO/examples/RTCORBA/Activity/Periodic_Task.h
index 0c82ad4b87c..01a955dde15 100644
--- a/TAO/examples/RTCORBA/Activity/Periodic_Task.h
+++ b/TAO/examples/RTCORBA/Activity/Periodic_Task.h
@@ -84,6 +84,9 @@ class activity_Export Periodic_Task : public ACE_Task <ACE_SYNCH>
/// = Stats house keeping
Task_Stats* task_stats_;
+
+ ///Enable Network Priority Flag
+ int enable_network_priority_;
};
#endif /* PERIODIC_TASK_H */
diff --git a/TAO/examples/RTCORBA/Activity/README b/TAO/examples/RTCORBA/Activity/README
index b1ee809bb84..009fb7ea97f 100755
--- a/TAO/examples/RTCORBA/Activity/README
+++ b/TAO/examples/RTCORBA/Activity/README
@@ -78,9 +78,10 @@ where,
-Phase <phase> = The phase to start at (uS)
-Iter <iterations> = Number of Periods to exec.
-Load <load_weight> = a load factor passed to the job that varies its processing.
+-Diffserv <0 | 1> = Set/Unset the CORBA Priority Mapping to Diffserv
e.g.
--ThreadTask -JobName job_10 -Priority 10 -Period 1 -ExecTime 10000 -Phase 0 -Iter 20 -Load 1000
+-ThreadTask -JobName job_10 -Priority 10 -Period 1 -ExecTime 10000 -Phase 0 -Iter 20 -Load 1000 -Diffserv 1
specifes a Thread Task in which,
JobName = job_10
@@ -90,6 +91,7 @@ JobName = job_10
-Phase = 0uS
-Iter = 20 iterations
-Load = 1000
+-Diffserv = 1 (this implies that all data packets sent will have the diffserv codepoint sent in them )
3. Running the example
----------------------
@@ -99,7 +101,7 @@ e.g. ./Naming_Service -o naming_ior
b). Start one or more instances of ./activity depending on the test configuration that you have designed.
-e.g. ./activity -ORBInitRef NamingService=file://naming_ior -ORBSvcConf svc.conf.whatever -ORBDebugLevel 1
+e.g. ./activity -ORBInitRef NameService=file://naming_ior -ORBSvcConf svc.conf.whatever -ORBDebugLevel 1
c) once all the instances exit, the test will generate data files: <job_name>.dat
diff --git a/TAO/examples/RTCORBA/Activity/Thread_Task.cpp b/TAO/examples/RTCORBA/Activity/Thread_Task.cpp
index 49beaae62f5..167d1bca360 100644
--- a/TAO/examples/RTCORBA/Activity/Thread_Task.cpp
+++ b/TAO/examples/RTCORBA/Activity/Thread_Task.cpp
@@ -3,6 +3,7 @@
#include "ace/High_Res_Timer.h"
#include "tao/debug.h"
+#include "tao/ORB_Core.h"
#include "Activity.h"
#include "Task_Stats.h"
@@ -42,9 +43,71 @@ Thread_Task::activate_task (ACE_Barrier* barrier)
return 0;
}
+void
+Thread_Task::change_network_priority (void)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "Change Network Priority\n"));
+
+ ACE_TRY_NEW_ENV
+ {
+
+ RTCORBA::RTORB_var rt_orb = ACTIVITY::instance ()->rt_orb ();
+
+ // if (check_for_nil (rt_orb.in (), "RTORB") == -1)
+ // ACE_ERROR ((LM_ERROR,
+ // "RTORB is nil\n"));
+
+ //Set the tcp protocol protperties
+ RTCORBA::TCPProtocolProperties_var tcp_properties =
+ rt_orb->create_tcp_protocol_properties (ACE_DEFAULT_MAX_SOCKET_BUFSIZ,
+ ACE_DEFAULT_MAX_SOCKET_BUFSIZ,
+ 1,
+ 0,
+ 1,
+ 1
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ RTCORBA::ProtocolList protocols;
+ protocols.length (1);
+ protocols[0].protocol_type = 0;
+ protocols[0].transport_protocol_properties =
+ RTCORBA::ProtocolProperties::_duplicate (tcp_properties.in ());
+ protocols[0].orb_protocol_properties =
+ RTCORBA::ProtocolProperties::_nil ();
+
+ CORBA::PolicyList policy_list;
+ policy_list.length (1);
+ policy_list[0] =
+ rt_orb->create_client_protocol_policy (protocols
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+
+ ACTIVITY::instance ()->orb ()->orb_core ()->policy_current ().set_policy_overrides (policy_list,
+ CORBA::SET_OVERRIDE
+ ACE_ENV_ARG_PARAMETER);
+
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Caught exception: change_network_priority\n");
+ }
+ ACE_ENDTRY;
+}
+
int
Thread_Task::svc (void)
{
+ ACE_DEBUG ((LM_DEBUG,
+ "Thread_Task::svc\n"));
+
+ if (this->enable_network_priority_)
+ this->change_network_priority ();
+
// if debugging, dump the priority that we're actually at.
if (TAO_debug_level > 0)
{
@@ -81,25 +144,35 @@ Thread_Task::svc (void)
ACE_UINT32 gsf = ACE_High_Res_Timer::global_scale_factor ();
- ACE_hrtime_t before, after;
+ ACE_hrtime_t before, after = 0, total_time = 0;
+
+ Job::data payload;
+ payload.length (1500);
+
+ total_time = ACE_OS::gethrtime () + ACE_UINT64 (exec_time_ / 1000000 * gsf * ACE_HR_SCALE_CONVERSION);
- for (int i = 0; i < iter_ ; ++i)
+ int i = 0;
+ while ( i < iter_ )
{
+ i++;
+
before = ACE_OS::gethrtime ();
-
- job_->work (load_);
-
+
+ job_->work (load_,
+ payload);
+
after = ACE_OS::gethrtime ();
- task_stats_->sample (before, after);
-
+ if (after <= total_time || iter_ > 0)
+ task_stats_->sample (before, after);
+
if (period_ != 0) // blast mode, no sleep.
- {
+ {
// convert to microseconds
#if !defined ACE_LACKS_LONGLONG_T
-
+
ACE_UINT32 elapsed_microseconds = ACE_UINT32((after - before) / gsf);
-
+
#else /* ! ACE_LACKS_LONGLONG_T */
ACE_UINT32 elapsed_microseconds = (after - before) / gsf;
@@ -110,22 +183,22 @@ Thread_Task::svc (void)
elapsed_microseconds*=1000; // convert to uSec on Win32
#endif /* ACE_WIN32 */
- // did we miss any deadlines?
-
+ // did we miss any deadlines?
+
int missed =
elapsed_microseconds > period_ ? elapsed_microseconds/period_ : 0;
-
+
long sleep_time = (missed + 1)*period_ ;
sleep_time -= elapsed_microseconds;
-
+
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG, "(%t) sleep time = %d\n", sleep_time));
-
+
ACE_Time_Value t_sleep (0, sleep_time);
ACE_OS::sleep (t_sleep);
} /* period != 0 */
} /* for */
-
+
task_stats_->end_time (ACE_OS::gethrtime ());
job_->shutdown (); // tell the job that we're done.
diff --git a/TAO/examples/RTCORBA/Activity/Thread_Task.h b/TAO/examples/RTCORBA/Activity/Thread_Task.h
index e1d470d7753..ce3a4f1d541 100644
--- a/TAO/examples/RTCORBA/Activity/Thread_Task.h
+++ b/TAO/examples/RTCORBA/Activity/Thread_Task.h
@@ -40,6 +40,8 @@ class activity_Export Thread_Task : public Periodic_Task
/// task svc
virtual int svc (void);
+
+ void change_network_priority (void);
};
#endif /* THREAD_TASK_H */