summaryrefslogtreecommitdiff
path: root/TAO/tests
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1998-09-13 15:36:01 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1998-09-13 15:36:01 +0000
commitb2fc6561cc1ddcd620f97842eb2641a70b604077 (patch)
tree89cf2fbc9f76d367eef4254bfab01c063a587452 /TAO/tests
parentc641a8ccb721f4b50366a820fa7d3a3692ab01dd (diff)
downloadATCD-b2fc6561cc1ddcd620f97842eb2641a70b604077.tar.gz
*** empty log message ***
Diffstat (limited to 'TAO/tests')
-rw-r--r--TAO/tests/Cubit/TAO/MT_Cubit/Cubit_Task.cpp7
-rw-r--r--TAO/tests/Cubit/TAO/MT_Cubit/Globals.cpp8
-rw-r--r--TAO/tests/Cubit/TAO/MT_Cubit/Globals.h11
-rw-r--r--TAO/tests/Cubit/TAO/MT_Cubit/README12
-rw-r--r--TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.cpp147
-rw-r--r--TAO/tests/Cubit/TAO/MT_Cubit/Timer.cpp8
-rw-r--r--TAO/tests/Cubit/TAO/MT_Cubit/Timer.h3
-rw-r--r--TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.cpp11
-rw-r--r--TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.h3
-rw-r--r--TAO/tests/Cubit/TAO/MT_Cubit/client.cpp105
-rw-r--r--TAO/tests/Cubit/TAO/MT_Cubit/client.h2
-rw-r--r--TAO/tests/Cubit/TAO/MT_Cubit/server.cpp40
-rw-r--r--TAO/tests/Cubit/TAO/MT_Cubit/server.h5
13 files changed, 214 insertions, 148 deletions
diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/Cubit_Task.cpp b/TAO/tests/Cubit/TAO/MT_Cubit/Cubit_Task.cpp
index c8dc0c9e6fe..39cc0928d15 100644
--- a/TAO/tests/Cubit/TAO/MT_Cubit/Cubit_Task.cpp
+++ b/TAO/tests/Cubit/TAO/MT_Cubit/Cubit_Task.cpp
@@ -222,7 +222,9 @@ Cubit_Task::create_servants (void)
2);
this->orb_manager_.activate_under_child_poa
- (buffer, this->servants_[i], TAO_TRY_ENV);
+ (buffer,
+ this->servants_[i],
+ TAO_TRY_ENV);
TAO_CHECK_ENV;
// Stringify the objref we'll be implementing, and print it
@@ -238,7 +240,8 @@ Cubit_Task::create_servants (void)
TAO_TRY_ENV);
TAO_CHECK_ENV;
- this->servants_iors_[i] = ACE_OS::strdup (str.in ());
+ this->servants_iors_[i] =
+ ACE_OS::strdup (str.in ());
// Register the servant with the Naming Context....
CosNaming::Name cubit_name (1);
diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/Globals.cpp b/TAO/tests/Cubit/TAO/MT_Cubit/Globals.cpp
index d86c2a9bdcd..a30d36c392b 100644
--- a/TAO/tests/Cubit/TAO/MT_Cubit/Globals.cpp
+++ b/TAO/tests/Cubit/TAO/MT_Cubit/Globals.cpp
@@ -82,8 +82,8 @@ Globals::parse_args (int argc, char *argv[])
}
MT_Priority::MT_Priority (void)
- :num_priorities_ (0),
- grain_ (0)
+ : num_priorities_ (0),
+ grain_ (0)
{
}
@@ -120,10 +120,10 @@ MT_Priority::get_low_priority (u_int num_low_priority,
(ACE_SCHED_FIFO, ACE_SCOPE_THREAD);
priority_iterator.more ();
priority_iterator.next ())
- this->num_priorities_ ++;
+ this->num_priorities_++;
// 1 priority is exclusive for the high priority client.
- this->num_priorities_ --;
+ this->num_priorities_--;
// Drop the priority, so that the priority of clients will
// increase with increasing client number.
diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/Globals.h b/TAO/tests/Cubit/TAO/MT_Cubit/Globals.h
index b1e409e9543..ddd6e8b0292 100644
--- a/TAO/tests/Cubit/TAO/MT_Cubit/Globals.h
+++ b/TAO/tests/Cubit/TAO/MT_Cubit/Globals.h
@@ -11,6 +11,10 @@
// = FILENAME
// Globals.h
//
+// = DESCRIPTION
+// All the globally defined classes, functions, types, and #defines
+// are centralized here.
+//
// = AUTHOR
// Nagarajan Surendran <naga@cs.wustl.edu>
//
@@ -125,9 +129,10 @@ public:
virtual ACE_Sched_Priority get_high_priority (void);
// Sets the priority of the high priority thread.
- virtual ACE_Sched_Priority get_low_priority (u_int num_low_priority,
- ACE_Sched_Priority prev_priority,
- u_int use_multiple_priority);
+ virtual ACE_Sched_Priority get_low_priority
+ (u_int num_low_priority,
+ ACE_Sched_Priority prev_priority,
+ u_int use_multiple_priority);
// Sets the priority to be used for the low priority thread.
u_int number_of_priorities (void);
diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/README b/TAO/tests/Cubit/TAO/MT_Cubit/README
index f83530d862c..0e62ad95420 100644
--- a/TAO/tests/Cubit/TAO/MT_Cubit/README
+++ b/TAO/tests/Cubit/TAO/MT_Cubit/README
@@ -1,8 +1,18 @@
// $Id$
-The MT-Cubit example
+THE MT_CUBIT EXAMPLE
--------------------
+This directory contains the source code for the TAO "MT_Cubit"
+benchmark, which enables us to measure the real-time performance of
+TAO. MT_Cubit measures the latency,jitter, determinism, CPU
+utilization, and degree of priority inversion incurred by TAO twoway
+operations invoked under different workloads and priorities. For
+more information and empirical results, please see
+
+http://www.cs.wustl.edu/~schmidt/RT-perf.ps.gz
+http://www.cs.wustl.edu/~schmidt/RT-OS.ps.gz
+
COMPILING
---------
diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.cpp b/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.cpp
index 3cc06e4ea22..63b1b76a9bd 100644
--- a/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.cpp
+++ b/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.cpp
@@ -10,7 +10,7 @@
ACE_RCSID(MT_Cubit, Task_Client, "$Id$")
-Task_State::Task_State (int argc, char **argv)
+Task_State::Task_State (int argc, char *argv[])
: barrier_ (0),
key_ ("Cubit"),
loop_count_ (1000),
@@ -47,11 +47,10 @@ Task_State::Task_State (int argc, char **argv)
}
int
-Task_State::parse_args (int argc,char **argv)
+Task_State::parse_args (int argc,char *argv[])
{
ACE_Get_Opt opts (argc, argv, "U:mu:sn:t:d:rxof:g:1cl");
int c;
- int datatype;
while ((c = opts ()) != -1)
switch (c) {
@@ -89,31 +88,33 @@ Task_State::parse_args (int argc,char **argv)
thread_per_rate_ = 1;
break;
case 'd':
- datatype = ACE_OS::atoi (opts.optarg);
- switch (datatype)
- {
- case CB_OCTET:
- ACE_DEBUG ((LM_DEBUG,
- "Testing Octets\n"));
- datatype_ = CB_OCTET;
- break;
- case CB_LONG:
- ACE_DEBUG ((LM_DEBUG,
- "Testing Longs\n"));
- datatype_ = CB_LONG;
- break;
- case CB_STRUCT:
- ACE_DEBUG ((LM_DEBUG,
- "Testing Structs\n"));
- datatype_ = CB_STRUCT;
- break;
- case CB_SHORT:
- default:
- ACE_DEBUG ((LM_DEBUG,
- "Testing Shorts\n"));
- datatype_ = CB_SHORT;
- break;
- }
+ {
+ int datatype = ACE_OS::atoi (opts.optarg);
+ switch (datatype)
+ {
+ case CB_OCTET:
+ ACE_DEBUG ((LM_DEBUG,
+ "Testing Octets\n"));
+ datatype_ = CB_OCTET;
+ break;
+ case CB_LONG:
+ ACE_DEBUG ((LM_DEBUG,
+ "Testing Longs\n"));
+ datatype_ = CB_LONG;
+ break;
+ case CB_STRUCT:
+ ACE_DEBUG ((LM_DEBUG,
+ "Testing Structs\n"));
+ datatype_ = CB_STRUCT;
+ break;
+ case CB_SHORT:
+ default:
+ ACE_DEBUG ((LM_DEBUG,
+ "Testing Shorts\n"));
+ datatype_ = CB_SHORT;
+ break;
+ }
+ }
continue;
case 'n': // loop count
loop_count_ = (u_int) ACE_OS::atoi (opts.optarg);
@@ -152,7 +153,8 @@ Task_State::parse_args (int argc,char **argv)
if (ior_file_ != 0)
{
- FILE *ior_file = ACE_OS::fopen (ior_file_, "r");
+ FILE *ior_file =
+ ACE_OS::fopen (ior_file_, "r");
if (ior_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
@@ -185,6 +187,7 @@ Task_State::parse_args (int argc,char **argv)
// wanting to begin at the same time the clients begin && the main
// thread wants to know when clients will start running to get
// accurate context switch numbers.
+
if (thread_per_rate_ == 0)
{
if (use_utilization_test_ == 1)
@@ -241,7 +244,7 @@ Task_State::~Task_State (void)
Client::Client (ACE_Thread_Manager *thread_manager,
Task_State *ts,
u_int id)
- : ACE_MT (ACE_Task<ACE_MT_SYNCH> (thread_manager)),
+ : ACE_Task<ACE_MT_SYNCH> (thread_manager),
cubit_impl_ (0),
ts_ (ts),
num_ (0),
@@ -331,9 +334,12 @@ Client::get_high_priority_jitter (void)
JITTER_ARRAY_ITERATOR iterator =
this->ts_->global_jitter_array_[0]->begin ();
+
// latency in usecs.
ACE_timer_t *latency = 0;
- u_int i=0;
+
+ u_int i = 0;
+
for (iterator.first ();
i < number_of_samples && iterator.next (latency) == 1;
i++,iterator.advance ())
@@ -344,6 +350,7 @@ Client::get_high_priority_jitter (void)
// giving it to stats.
stats.sample ((ACE_UINT32) (*latency *1000 *1000 + 0.5));
}
+
// Return the square root of the sum of the differences computed
// above, i.e. jitter.
@@ -356,6 +363,7 @@ Client::get_high_priority_jitter (void)
}
// Returns the jitter in usecs.
+
ACE_timer_t
Client::get_low_priority_jitter (void)
{
@@ -373,6 +381,7 @@ Client::get_low_priority_jitter (void)
// We first compute the sum of the squares of the differences each
// latency has from the average.
+
for (u_int j = 1;
j < this->ts_->thread_count_;
j++)
@@ -384,8 +393,11 @@ Client::get_low_priority_jitter (void)
ACE_timer_t number_of_calls =
this->ts_->count_ [j] / this->ts_->granularity_;
+
ACE_timer_t *latency = 0;
- u_int i=0;
+
+ u_int i = 0;
+
for (iterator.first ();
i < number_of_calls && iterator.next (latency) == 1;
iterator.advance ())
@@ -412,7 +424,8 @@ Client::get_jitter (u_int id)
{
ACE_timer_t jitter = 0.0;
ACE_timer_t average = get_latency (id);
- ACE_timer_t number_of_samples = this->ts_->count_[id] / this->ts_->granularity_;
+ ACE_timer_t number_of_samples =
+ this->ts_->count_[id] / this->ts_->granularity_;
// Compute the standard deviation (i.e. jitter) from the values
// stored in the global_jitter_array_.
@@ -427,8 +440,11 @@ Client::get_jitter (u_int id)
ACE_timer_t number_of_calls =
this->ts_->count_[id] / this->ts_->granularity_;
+
ACE_timer_t *latency = 0;
+
u_int i = 0;
+
for (iterator.first ();
i < number_of_calls && iterator.next (latency) == 1;
i ++,iterator.advance ())
@@ -516,7 +532,7 @@ Client::init_orb (void)
TAO_TRY
{
ACE_DEBUG ((LM_DEBUG,
- "I'm thread %t\n"));
+ "I'm thread %t\n"));
// Add "-ORBobjrefstyle url" argument to the argv vector for the orb
// to / use a URL style to represent the ior.
@@ -619,12 +635,10 @@ Client::get_cubit_from_naming (void)
ACE_NEW_RETURN (buffer,
char[l],
-1);
-
ACE_OS::sprintf (buffer,
"%s%02d",
(char *) this->ts_->key_,
this->id_);
-
// Construct the key for the name service lookup.
CosNaming::Name cubit_name (1);
cubit_name.length (1);
@@ -632,7 +646,6 @@ Client::get_cubit_from_naming (void)
objref = this->mt_cubit_context_->resolve (cubit_name,
TAO_TRY_ENV);
-
if (TAO_TRY_ENV.exception () != 0
|| CORBA::is_nil (objref.in ()))
{
@@ -739,7 +752,8 @@ Client::get_cubit (void)
"(%t) Binding succeeded\n"));
CORBA::String_var str =
- this->orb_->object_to_string (this->cubit_, TAO_TRY_ENV);
+ this->orb_->object_to_string (this->cubit_,
+ TAO_TRY_ENV);
TAO_CHECK_ENV;
ACE_DEBUG ((LM_DEBUG,
@@ -759,20 +773,24 @@ Client::get_cubit (void)
int
Client::svc (void)
{
- int result;
- // initialize the ORB.
- result = this->init_orb ();
+ // Initialize the ORB.
+ int result = this->init_orb ();
if (result != 0)
return result;
- // find the frequency of CORBA requests based on thread id.
+
+ // Find the frequency of CORBA requests based on thread id.
this->find_frequency ();
- // get the cubit object either from naming service or from the ior file.
+
+ // Get the cubit object either from naming service or from the ior
+ // file.
result = this->get_cubit ();
if (result != 0)
return result;
+
ACE_DEBUG ((LM_DEBUG,
"(%t) Waiting for other threads to "
"finish binding..\n"));
+
// Wait for all the client threads to be initialized before going
// any further.
this->ts_->barrier_->wait ();
@@ -792,6 +810,7 @@ Client::svc (void)
this->ts_->semaphore_->release (this->ts_->thread_count_ - 1);
else
this->ts_->semaphore_->release ();
+
// shutdown the server if necessary.
TAO_TRY
{
@@ -805,9 +824,9 @@ Client::svc (void)
}
TAO_CATCHANY
{
- ACE_ERROR ((LM_ERROR,
- "Shutdown of the server failed!\n"));
- TAO_TRY_ENV.print_exception ("shutdown() call failed.\n");
+ ACE_ERROR ((LM_ERROR,
+ "Shutdown of the server failed!\n"));
+ TAO_TRY_ENV.print_exception ("shutdown() call failed.\n");
}
TAO_ENDTRY;
// Delete dynamic memory
@@ -1053,10 +1072,12 @@ Client::print_stats (void)
{
// since latency is in usecs.
ACE_timer_t calls_per_second =
- (this->call_count_ * ACE_ONE_SECOND_IN_USECS) / this->latency_;
+ (this->call_count_ * ACE_ONE_SECOND_IN_USECS)
+ / this->latency_;
// Calculate average latency in usecs.
- this->latency_ = this->latency_/this->call_count_;
+ this->latency_ =
+ this->latency_/this->call_count_;
if (this->latency_ > 0)
{
@@ -1107,14 +1128,11 @@ Client::calc_delta (ACE_timer_t real_time,
int
Client::do_test (void)
{
- u_int i;
- int result;
ACE_timer_t delta = 0;
u_int low_priority_client_count = this->ts_->thread_count_ - 1;
ACE_timer_t sleep_time = // usec
(1 / this->frequency_) * ACE_ONE_SECOND_IN_USECS * this->ts_->granularity_;
-
- for (i = 0;
+ for (u_int i = 0;
// keep running for loop count, OR
i < this->ts_->loop_count_
// keep running if we are the highest priority thread and at
@@ -1141,12 +1159,12 @@ Client::do_test (void)
}
this->num_ = i;
// make a request to the server object depending on the datatype.
- result = this->make_request ();
+ int result = this->make_request ();
if (result != 0)
return 2;
// Stop the timer.
- if ((i % this->ts_->granularity_) == this->ts_->granularity_ - 1
+ if (i % this->ts_->granularity_ == this->ts_->granularity_ - 1
&& this->ts_->use_utilization_test_ == 0)
{
this->timer_->stop ();
@@ -1168,9 +1186,9 @@ Client::do_test (void)
break;
}
else
- // if We are the high priority client.
- // if tryacquire() succeeded then a client must have done a
- // release () on it, thus we decrement the client counter.
+ // If we are the high priority client. If tryacquire()
+ // succeeded then a client must have done a release () on it,
+ // thus we decrement the client counter.
if (id_ == 0
&& this->ts_->thread_count_ > 1)
{
@@ -1195,26 +1213,33 @@ Client::run_tests (void)
JITTER_ARRAY,
-1);
// Time to wait for utilization tests to know when to stop.
- ACE_Time_Value max_wait_time (this->ts_->util_time_, 0);
+ ACE_Time_Value max_wait_time (this->ts_->util_time_,
+ 0);
ACE_Countdown_Time countdown (&max_wait_time);
ACE_NEW_RETURN (this->timer_,
MT_Cubit_Timer (this->ts_->granularity_),
-1);
if (this->ts_->use_utilization_test_ == 1)
this->timer_->start ();
+
// Make the calls in a loop.
- if ((result = this->do_test ()) != 0)
+ result = this->do_test ();
+ if (result != 0)
return result;
+
if (id_ == 0)
this->ts_->high_priority_loop_count_ =
this->call_count_;
+
if (this->ts_->use_utilization_test_ == 1)
{
this->timer_->stop ();
- ACE_timer_t util_time = this->timer_->get_elapsed ();
+ ACE_timer_t util_time =
+ this->timer_->get_elapsed ();
this->ts_->util_test_time_ = util_time;
}
- // print the latency results.
+
+ // Print the latency results.
this->print_stats ();
return 0;
}
diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/Timer.cpp b/TAO/tests/Cubit/TAO/MT_Cubit/Timer.cpp
index f9cceb90982..b0ed07ec8e9 100644
--- a/TAO/tests/Cubit/TAO/MT_Cubit/Timer.cpp
+++ b/TAO/tests/Cubit/TAO/MT_Cubit/Timer.cpp
@@ -26,11 +26,11 @@ void
MT_Cubit_Timer::stop (void)
{
#if defined (CHORUS)
- pstopTime = pccTime1Get ();
+ pstopTime = pccTime1Get ();
#else /* CHORUS */
- // If CHORUS is not defined just use plain timer_.stop ().
- this->timer_.stop ();
- this->timer_.elapsed_time (this->delta_);
+ // If CHORUS is not defined just use plain timer_.stop ().
+ this->timer_.stop ();
+ this->timer_.elapsed_time (this->delta_);
#endif /* !CHORUS */
}
diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/Timer.h b/TAO/tests/Cubit/TAO/MT_Cubit/Timer.h
index 1e905a5b399..b42ea4c334c 100644
--- a/TAO/tests/Cubit/TAO/MT_Cubit/Timer.h
+++ b/TAO/tests/Cubit/TAO/MT_Cubit/Timer.h
@@ -10,7 +10,8 @@
// Timer.h
//
// = AUTHOR
-// Andy Gokhale, Sumedh Mungee, Sergio Flores-Gaitan and Nagarajan Surendran.
+// Andy Gokhale, Sumedh Mungee, Sergio Flores-Gaitan and Nagarajan
+// Surendran.
//
// ============================================================================
diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.cpp b/TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.cpp
index 69a540ebefe..cf107db0914 100644
--- a/TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.cpp
+++ b/TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.cpp
@@ -82,7 +82,9 @@ Util_Thread::run_computations (void)
{
// Bound the number of computations, since we can potentially
// block the machine if this thread never leaves the loop.
- if (this->number_of_computations_ > (ts_->loop_count_ * 1000)) // magic number
+ if (this->number_of_computations_ > (ts_->loop_count_ * 1000))
+ // @@ Naga, can you please remove this magic number and replace
+ // it with a symbolic constant?
{
ACE_DEBUG ((LM_DEBUG,
"\t(%t) utilization test breaking loop so machine won't block.\n"));
@@ -90,12 +92,7 @@ Util_Thread::run_computations (void)
}
this->computation ();
- this->number_of_computations_ ++;
-
-#if 0
- // Shouldn't need this. And I'm not sure if it really helps.
- ACE_OS::thr_yield ();
-#endif /* 0 */
+ this->number_of_computations_++;
}
return 0;
diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.h b/TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.h
index 567529add4f..cd8e4074f39 100644
--- a/TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.h
+++ b/TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.h
@@ -10,7 +10,8 @@
// Util_Thread.h
//
// = AUTHOR
-// Andy Gokhale, Sumedh Mungee, Sergio Flores-Gaitan and Nagarajan Surendran.
+// Andy Gokhale, Sumedh Mungee, Sergio Flores-Gaitan and Nagarajan
+// Surendran.
//
// ============================================================================
diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/client.cpp b/TAO/tests/Cubit/TAO/MT_Cubit/client.cpp
index 51103d3654b..9b84bb72219 100644
--- a/TAO/tests/Cubit/TAO/MT_Cubit/client.cpp
+++ b/TAO/tests/Cubit/TAO/MT_Cubit/client.cpp
@@ -92,6 +92,9 @@ int
Client_i::init (int argc, char *argv[])
{
#if defined (ACE_HAS_THREADS)
+ // @@ Naga, can you please abstract this stuff out into the
+ // Global.{h,cpp} class since I think it's rather messy?
+
// Enable FIFO scheduling, e.g., RT scheduling class on Solaris.
if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
#if defined (__Lynx__)
@@ -152,14 +155,16 @@ Client_i::init (int argc, char *argv[])
ACE_OS::atoi (this->argv_[i+1]);
}
#if defined (CHORUS)
+ // @@ Naga, can you please abstract this out into a macro or
+ // something in Global.h, like you did for the VxWorks VME driver?
// start the pccTimer for Chorus ClassiX.
int pTime;
// Initialize the PCC timer Chip
pccTimerInit ();
- if(pccTimer(PCC2_TIMER1_START,
- &pTime) != K_OK)
+ if (pccTimer (PCC2_TIMER1_START,
+ &pTime) != K_OK)
ACE_DEBUG ((LM_DEBUG,
"pccTimer has a pending benchmark\n"));
#endif /* CHORUS */
@@ -264,6 +269,7 @@ Client_i::output_latency (void)
this->ts_->global_jitter_array_ [j]->begin ();
u_int i = 0;
ACE_timer_t *latency = 0;
+
for (iterator.first ();
(i < (j == 0
? this->ts_->high_priority_loop_count_
@@ -324,6 +330,8 @@ Client_i::calc_util_time (void)
this->util_task_duration_ = timer.get_elapsed ();
#else
for (u_int i = 0;
+ // @@ Naga, can you please "abstract" out this magic number and
+ // replace it with a symbolic constant?
i < 10000;
i++)
this->util_thread_->computation ();
@@ -355,15 +363,16 @@ Client_i::activate_high_client (void)
ACE_DEBUG ((LM_DEBUG,
"Creating 1 client with high priority of %d\n",
this->high_priority_));
- if (this->high_priority_client_->activate (THR_BOUND | ACE_SCHED_FIFO,
- 1,
- 0,
- this->high_priority_,
- -1,
- 0,
- 0,
- 0,
- (ACE_thread_t *) &this->task_id_) == -1)
+ if (this->high_priority_client_->activate
+ (THR_BOUND | ACE_SCHED_FIFO,
+ 1,
+ 0,
+ this->high_priority_,
+ -1,
+ 0,
+ 0,
+ 0,
+ (ACE_thread_t *) &this->task_id_) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p; priority is %d\n",
"activate failed",
@@ -424,12 +433,12 @@ Client_i::activate_low_client (void)
(THR_BOUND | ACE_SCHED_FIFO,
1,
0,
- this->low_priority_, // These are constructor defaults.
- -1, // int grp_id = -1,
- 0, // ACE_Task_Base *task = 0,
- 0, // ACE_hthread_t thread_handles[] = 0,
- 0, // void *stack[] = 0,
- 0, // size_t stack_size[] = 0,
+ this->low_priority_, // These are constructor defaults.
+ -1, // int grp_id = -1,
+ 0, // ACE_Task_Base *task = 0,
+ 0, // ACE_hthread_t thread_handles[] = 0,
+ 0, // void *stack[] = 0,
+ 0, // size_t stack_size[] = 0,
(ACE_thread_t *) &this->task_id_) == -1)
ACE_ERROR ((LM_ERROR,
"%p; priority is %d\n",
@@ -559,10 +568,10 @@ Client_i::print_latency_stats (void)
ACE_DEBUG ((LM_DEBUG, "Test done.\n"
"High priority client latency : %f msec, jitter: %f msec\n"
"Low priority client latency : %f msec, jitter: %f msec\n",
- this->high_priority_client_->get_high_priority_latency ()/ACE_ONE_SECOND_IN_MSECS,
- this->high_priority_client_->get_high_priority_jitter ()/ACE_ONE_SECOND_IN_MSECS,
- this->low_priority_client_[0]->get_low_priority_latency ()/ACE_ONE_SECOND_IN_MSECS,
- this->low_priority_client_[0]->get_low_priority_jitter ()/ACE_ONE_SECOND_IN_MSECS));
+ this->high_priority_client_->get_high_priority_latency () / ACE_ONE_SECOND_IN_MSECS,
+ this->high_priority_client_->get_high_priority_jitter () / ACE_ONE_SECOND_IN_MSECS,
+ this->low_priority_client_[0]->get_low_priority_latency () / ACE_ONE_SECOND_IN_MSECS,
+ this->low_priority_client_[0]->get_low_priority_jitter () / ACE_ONE_SECOND_IN_MSECS));
// output_latency ();
#endif /* !VXWORKS && !CHORUS */
}
@@ -657,22 +666,27 @@ Client_i::start_servant (void)
this->high_priority_));
// Make the high priority task an active object.
- if (high_priority_task->activate (THR_BOUND | ACE_SCHED_FIFO,
- 1,
- 0,
- this->high_priority_) == -1)
+ if (high_priority_task->activate
+ (THR_BOUND | ACE_SCHED_FIFO,
+ 1,
+ 0,
+ this->high_priority_) == -1)
ACE_ERROR ((LM_ERROR,
"(%P|%t) %p\n"
"\thigh_priority_task->activate failed"));
- // ACE_DEBUG ((LM_DEBUG,"(%t) Waiting for argument parsing\n"));
ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ready_mon, GLOBALS::instance ()->ready_mtx_,-1));
+
+ // @@ Naga, can you please add a comment documenting what's going
+ // on here?
while (!GLOBALS::instance ()->ready_)
GLOBALS::instance ()->ready_cnd_.wait ();
- // ACE_DEBUG ((LM_DEBUG,"(%t) Argument parsing waiting done\n"));
- // wait for all the threads.
+
GLOBALS::instance ()->barrier_->wait ();
- this->ts_->one_ior_ = high_priority_task->get_servant_ior (0);
+
+ this->ts_->one_ior_ =
+ high_priority_task->get_servant_ior (0);
+
return 0;
}
@@ -702,39 +716,46 @@ Client_i::do_priority_inversion_test (void)
if (result < 0)
return result;
- // ACE_DEBUG ((LM_DEBUG,"(%t) Waiting for argument parsing\n"));
ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ready_mon, this->ts_->ready_mtx_,-1));
- // wait on the condition variable until the high priority thread wakes us up.
+
+ // Wait on the condition variable until the high priority thread
+ // wakes us up.
while (!this->ts_->ready_)
this->ts_->ready_cnd_.wait ();
- // ACE_DEBUG ((LM_DEBUG,"(%t) Argument parsing waiting done\n"));
- // create and activate the low priority clients.
+
result = this->activate_low_client ();
+
if (result < 0)
return result;
- // activate the utilization thread if necessary.
+
+ // Activate the utilization thread if necessary.
result = this->activate_util_thread ();
if (result < 0)
return result;
+
// Wait for all the client threads to be initialized before going
// any further.
this->ts_->barrier_->wait ();
+
STOP_QUANTIFY;
CLEAR_QUANTIFY;
- // collect the context switch data.
+
+ // Collect the context switch data.
this->get_context_switches ();
+
// Wait for all the client threads to exit (except the utilization
// thread).
this->client_thread_manager_.wait ();
+
STOP_QUANTIFY;
ACE_DEBUG ((LM_DEBUG,"(%P|%t) >>>>>>> ending test on %D\n"));
this->timer_.stop ();
this->timer_.elapsed_time (this->delta_);
- // Signal the utilization thread to finish with its work.. only
- // if utilization test was specified. See description of this
- // variable in header file.
+ // Signal the utilization thread to finish with its work.. only if
+ // utilization test was specified. See description of this variable
+ // in header file.
if (this->ts_->use_utilization_test_ == 1)
{
this->util_thread_->done_ = 1;
@@ -767,6 +788,7 @@ Client_i::do_thread_per_rate_test (void)
CB_1HZ_CONSUMER);
ACE_Sched_Priority priority;
+ // @@ Naga, shouldn't this be abstracted into the Globals.* file?
#if defined (VXWORKS)
priority = ACE_THR_PRI_FIFO_DEF;
#elif defined (ACE_WIN32)
@@ -775,6 +797,7 @@ Client_i::do_thread_per_rate_test (void)
#else /* ! VXWORKS */
priority = ACE_THR_PRI_FIFO_DEF + 25;
#endif /* ! ACE_WIN32 */
+
ACE_DEBUG ((LM_DEBUG,
"Creating 20 Hz client with priority %d\n",
priority));
@@ -793,7 +816,8 @@ Client_i::do_thread_per_rate_test (void)
ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ready_mon, this->ts_->ready_mtx_,-1));
- // wait on the condition variable until the high priority thread wakes us up.
+ // Wait on the condition variable until the high priority thread
+ // wakes us up.
while (!this->ts_->ready_)
this->ts_->ready_cnd_.wait ();
@@ -879,10 +903,9 @@ int
main (int argc, char *argv[])
{
#endif /* VXWORKS */
- int result;
Client_i client;
- result = client.init (argc,argv);
+ int result = client.init (argc,argv);
if (result < 0)
return result;
diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/client.h b/TAO/tests/Cubit/TAO/MT_Cubit/client.h
index 3fb82aec6e4..4800ceb4798 100644
--- a/TAO/tests/Cubit/TAO/MT_Cubit/client.h
+++ b/TAO/tests/Cubit/TAO/MT_Cubit/client.h
@@ -57,7 +57,7 @@ public:
int do_thread_per_rate_test (void);
// Performs the test with 4 threads each sending requests at rates
- // of 20,10,5 and 1Hz.
+ // of 20, 10, 5, and 1Hz.
int start_servant (void);
// Starts the client utilization thread.
diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/server.cpp b/TAO/tests/Cubit/TAO/MT_Cubit/server.cpp
index 8de9a66921e..d6783888e96 100644
--- a/TAO/tests/Cubit/TAO/MT_Cubit/server.cpp
+++ b/TAO/tests/Cubit/TAO/MT_Cubit/server.cpp
@@ -49,6 +49,7 @@ Server::Server (void)
int
Server::init (int argc, char **argv)
{
+ // @@ Naga, can't this be abstracted away into the Globals.* files?!
#if defined (ACE_HAS_THREADS)
// Enable FIFO scheduling, e.g., RT scheduling class on Solaris.
if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
@@ -193,7 +194,9 @@ Server::write_iors (void)
{
if (ior_f != 0)
{
- ACE_OS::fprintf (ior_f, "%s\n", this->cubits_[j]);
+ ACE_OS::fprintf (ior_f,
+ "%s\n",
+ this->cubits_[j]);
ACE_DEBUG ((LM_DEBUG,
"this->cubits_[%d] ior = %s\n",
j,
@@ -219,18 +222,15 @@ Server::activate_high_servant (void)
ACE_OS::sprintf (orbhost,
"-ORBhost %s ",
GLOBALS::instance ()->hostname);
-
char *high_second_argv[] = {orbport,
orbhost,
"-ORBobjrefstyle URL ",
"-ORBsndsock 32768 ",
"-ORBrcvsock 32768 ",
0};
-
ACE_NEW_RETURN (this->high_argv_,
ACE_ARGV (this->argv_,high_second_argv),
-1);
-
ACE_NEW_RETURN (this->high_priority_task_,
Cubit_Task (this->high_argv_->buf (),
"internet",
@@ -256,6 +256,7 @@ Server::activate_high_servant (void)
// Wait on the condition variable for the high priority client to
// finish parsing the arguments.
+
while (!GLOBALS::instance ()->ready_)
GLOBALS::instance ()->ready_cnd_.wait ();
@@ -266,28 +267,25 @@ Server::activate_high_servant (void)
int
Server::activate_low_servants (void)
{
- char orbport[BUFSIZ];
char orbhost[BUFSIZ];
- int i;
ACE_OS::sprintf (orbhost,
"-ORBhost %s ",
GLOBALS::instance ()->hostname);
-
ACE_DEBUG ((LM_DEBUG,
"Creating %d servants starting at priority %d\n",
this->num_low_priority_,
this->low_priority_));
-
// Create the low priority servants.
ACE_NEW_RETURN (this->low_priority_tasks_,
Cubit_Task *[GLOBALS::instance ()->num_of_objs],
-1);
-
- for (i = this->num_low_priority_;
+ for (int i = this->num_low_priority_;
i > 0;
i--)
{
+ char orbport[BUFSIZ];
+
ACE_OS::sprintf (orbport,
"-ORBport %d",
GLOBALS::instance ()->base_port == 0
@@ -314,10 +312,11 @@ Server::activate_low_servants (void)
-1);
// Make the low priority task an active object.
- if (this->low_priority_tasks_ [i - 1]->activate (THR_BOUND | ACE_SCHED_FIFO,
- 1,
- 0,
- this->low_priority_) == -1)
+ if (this->low_priority_tasks_ [i - 1]->activate
+ (THR_BOUND | ACE_SCHED_FIFO,
+ 1,
+ 0,
+ this->low_priority_) == -1)
ACE_ERROR ((LM_ERROR,
"(%P|%t) %p\n"
"\tthis->low_priority_tasks_[i]->activate"));
@@ -338,9 +337,10 @@ Server::activate_low_servants (void)
//threads, we make sure we don't go overboard.
&& this->num_priorities_ * this->grain_ > this->num_low_priority_ - (i - 1))
// Get the next higher priority.
- this->low_priority_ = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO,
- this->low_priority_,
- ACE_SCOPE_THREAD);
+ this->low_priority_ = ACE_Sched_Params::next_priority
+ (ACE_SCHED_FIFO,
+ this->low_priority_,
+ ACE_SCOPE_THREAD);
}
} /* end of for() */
@@ -351,7 +351,6 @@ Server::activate_low_servants (void)
int
Server::start_servants (void)
{
- int result;
// Do the preliminary argument processing for options -p and -h.
this->prelim_args_process ();
@@ -379,12 +378,13 @@ Server::start_servants (void)
ACE_ERROR_RETURN ((LM_ERROR,
"Failure in activating low priority servant\n"),
-1);
+
// Wait in the barrier.
GLOBALS::instance ()->barrier_->wait ();
- result = this->write_iors ();
+
+ int result = this->write_iors ();
if (result != 0)
return result;
-
return 0;
}
diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/server.h b/TAO/tests/Cubit/TAO/MT_Cubit/server.h
index d40a4e20711..226cc1a559e 100644
--- a/TAO/tests/Cubit/TAO/MT_Cubit/server.h
+++ b/TAO/tests/Cubit/TAO/MT_Cubit/server.h
@@ -10,7 +10,8 @@
// server.h
//
// = AUTHOR
-// Andy Gokhale, Sumedh Mungee,Sergio Flores-Gaitan and Nagarajan Surendran.
+// Andy Gokhale, Sumedh Mungee,Sergio Flores-Gaitan and Nagarajan
+// Surendran.
//
// ============================================================================
@@ -80,7 +81,7 @@ private:
void init_low_priority (void);
// sets the priority to be used for the low priority servants.
- int write_iors (void);
+ int write_iors (void);
// Writes the iors of the servants to a file
int activate_high_servant (void);