diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-04-03 07:51:09 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-04-03 07:51:09 +0000 |
commit | 7788eadaec27788cf605e4d177baa0641604de31 (patch) | |
tree | 5feb8aad0132e089830ec869e9b1910b836c8775 | |
parent | 3ceda05e6ed70cff68a99a77c13c8863df989ace (diff) | |
download | ATCD-7788eadaec27788cf605e4d177baa0641604de31.tar.gz |
*** empty log message ***
-rw-r--r-- | TAO/performance-tests/Cubit/TAO/MT_Cubit/Task_Client.cpp | 162 | ||||
-rw-r--r-- | TAO/performance-tests/Cubit/TAO/MT_Cubit/Task_Client.h | 7 | ||||
-rw-r--r-- | TAO/performance-tests/Cubit/TAO/MT_Cubit/Util_Thread.cpp | 4 | ||||
-rw-r--r-- | TAO/performance-tests/Cubit/TAO/MT_Cubit/Util_Thread.h | 4 | ||||
-rw-r--r-- | TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit_i.cpp | 18 | ||||
-rw-r--r-- | TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit_i.h | 3 | ||||
-rw-r--r-- | TAO/performance-tests/Cubit/TAO/MT_Cubit/server.cpp | 45 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.cpp | 162 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.h | 7 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.cpp | 4 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.h | 4 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.cpp | 18 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.h | 3 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/server.cpp | 45 |
14 files changed, 286 insertions, 200 deletions
diff --git a/TAO/performance-tests/Cubit/TAO/MT_Cubit/Task_Client.cpp b/TAO/performance-tests/Cubit/TAO/MT_Cubit/Task_Client.cpp index 5107554cc0b..623dff29898 100644 --- a/TAO/performance-tests/Cubit/TAO/MT_Cubit/Task_Client.cpp +++ b/TAO/performance-tests/Cubit/TAO/MT_Cubit/Task_Client.cpp @@ -60,8 +60,8 @@ Task_State::Task_State (int argc, char **argv) break; case CB_SHORT: default: - datatype_ = CB_SHORT; ACE_DEBUG ((LM_DEBUG, "Testing Shorts\n")); + datatype_ = CB_SHORT; break; } continue; @@ -91,12 +91,12 @@ Task_State::Task_State (int argc, char **argv) if (ior_file_ != 0) { - FILE *iorFile = ACE_OS::fopen (ior_file_, "r"); + FILE *ior_file = ACE_OS::fopen (ior_file_, "r"); char buf[BUFSIZ]; int i = 0; int j = 0; - while (ACE_OS::fgets (buf, BUFSIZ, iorFile) != 0) + while (ACE_OS::fgets (buf, BUFSIZ, ior_file) != 0) { j = ACE_OS::strlen (buf); buf[j - 1] = 0; // this is to delete the "\n" that was read from the file. @@ -104,7 +104,7 @@ Task_State::Task_State (int argc, char **argv) i++; } - ACE_OS::fclose (iorFile); + ACE_OS::fclose (ior_file); } // thread_count_ + 1 because there is one utilization thread also @@ -134,7 +134,9 @@ Client::put_ave_latency (int ave_latency, u_int thread_id) } void -Client::put_latency (double *jitter, double latency, u_int thread_id) +Client::put_latency (double *jitter, + double latency, + u_int thread_id) { ACE_MT (ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, ts_->lock_)); @@ -142,9 +144,13 @@ Client::put_latency (double *jitter, double latency, u_int thread_id) ts_->global_jitter_array_[thread_id] = jitter; #if defined (ACE_LACKS_FLOATING_POINT) - ACE_DEBUG ((LM_DEBUG, "(%t) My latency was %u\n", latency)); + ACE_DEBUG ((LM_DEBUG, + "(%t) My latency was %u\n", + latency)); #else - ACE_DEBUG ((LM_DEBUG, "(%t) My latency was %f\n", latency)); + ACE_DEBUG ((LM_DEBUG, + "(%t) My latency was %f\n", + latency)); #endif /* ! ACE_LACKS_FLOATING_POINT */ } @@ -168,7 +174,7 @@ Client::get_low_priority_latency (void) int Client::get_latency (u_int thread_id) { - return ts_->ave_latency_ [thread_id]; + return ts_->ave_latency_[thread_id]; } double @@ -184,12 +190,13 @@ Client::get_high_priority_jitter (void) // each latency has from the average for (u_int i = 0; i < ts_->loop_count_; i ++) { - double difference = ts_->global_jitter_array_ [0][i] - average; + double difference = + ts_->global_jitter_array_ [0][i] - average; jitter += difference * difference; } - // return the square root of the sum of the differences computed - // above, i.e. jitter + // Return the square root of the sum of the differences computed + // above, i.e. jitter. return sqrt (jitter); } @@ -202,8 +209,8 @@ Client::get_low_priority_jitter (void) // Compute the standard deviation (i.e. jitter) from the values // stored in the global_jitter_array_. - // we first compute the sum of the squares of the differences - // each latency has from the average + // We first compute the sum of the squares of the differences each + // latency has from the average. for (u_int j = 1; j < ts_->start_count_; j ++) for (u_int i = 0; i < ts_->loop_count_; i ++) { @@ -211,15 +218,16 @@ Client::get_low_priority_jitter (void) jitter += difference * difference; } - // return the square root of the sum of the differences computed - // above, i.e. jitter + // Return the square root of the sum of the differences computed + // above, i.e. jitter. return sqrt (jitter); } int Client::svc (void) { - ACE_DEBUG ((LM_DEBUG, "(%t) Thread created\n")); + ACE_DEBUG ((LM_DEBUG, + "(%t) Thread created\n")); u_int thread_id; Cubit_ptr cb = 0; @@ -240,12 +248,12 @@ Client::svc (void) ACE_OS::strcpy (tmp_buf, tmp_args.buf ()); - // Add the argument + // Add the argument. ACE_OS::strcat (tmp_buf, " -ORBobjrefstyle url "); // Convert back to argv vector style. - ACE_ARGV tmp_args2(tmp_buf); + ACE_ARGV tmp_args2 (tmp_buf); int argc = tmp_args2.argc (); char *const *argv = tmp_args2.argv (); @@ -300,39 +308,37 @@ Client::svc (void) } } else - { - switch (thread_id) - { - case CB_40HZ_CONSUMER: - ACE_DEBUG ((LM_DEBUG, - "(%t) Im the high priority client, " - "my id is %d.\n", thread_id)); - frequency = CB_40HZ_CONSUMER_RATE; - break; - case CB_20HZ_CONSUMER: - ACE_DEBUG ((LM_DEBUG, "(%t) Im the high priority client, " - "my id is %d.\n", thread_id)); - frequency = CB_20HZ_CONSUMER_RATE; - break; - case CB_10HZ_CONSUMER: - ACE_DEBUG ((LM_DEBUG, "(%t) Im the high priority client, " - "my id is %d.\n", thread_id)); - frequency = CB_10HZ_CONSUMER_RATE; - break; - case CB_5HZ_CONSUMER: - ACE_DEBUG ((LM_DEBUG, "(%t) Im the high priority client, " - "my id is %d.\n", thread_id)); - frequency = CB_5HZ_CONSUMER_RATE; - break; - case CB_1HZ_CONSUMER: - ACE_DEBUG ((LM_DEBUG, "(%t) Im the high priority client, " - "my id is %d.\n", thread_id)); - frequency = CB_1HZ_CONSUMER_RATE; - break; - default: - ACE_DEBUG ((LM_DEBUG, "(%t) Invalid Thread ID.\n", thread_id)); - } - } + switch (thread_id) + { + case CB_40HZ_CONSUMER: + ACE_DEBUG ((LM_DEBUG, + "(%t) Im the high priority client, " + "my id is %d.\n", thread_id)); + frequency = CB_40HZ_CONSUMER_RATE; + break; + case CB_20HZ_CONSUMER: + ACE_DEBUG ((LM_DEBUG, "(%t) Im the high priority client, " + "my id is %d.\n", thread_id)); + frequency = CB_20HZ_CONSUMER_RATE; + break; + case CB_10HZ_CONSUMER: + ACE_DEBUG ((LM_DEBUG, "(%t) Im the high priority client, " + "my id is %d.\n", thread_id)); + frequency = CB_10HZ_CONSUMER_RATE; + break; + case CB_5HZ_CONSUMER: + ACE_DEBUG ((LM_DEBUG, "(%t) Im the high priority client, " + "my id is %d.\n", thread_id)); + frequency = CB_5HZ_CONSUMER_RATE; + break; + case CB_1HZ_CONSUMER: + ACE_DEBUG ((LM_DEBUG, "(%t) Im the high priority client, " + "my id is %d.\n", thread_id)); + frequency = CB_1HZ_CONSUMER_RATE; + break; + default: + ACE_DEBUG ((LM_DEBUG, "(%t) Invalid Thread ID.\n", thread_id)); + } TAO_TRY { @@ -359,7 +365,9 @@ Client::svc (void) char *buffer; int l = ACE_OS::strlen (ts_->key_) + 3; - ACE_NEW_RETURN (buffer, char[l], -1); + ACE_NEW_RETURN (buffer, + char[l], + -1); ACE_OS::sprintf (buffer, "%s%02d", @@ -371,10 +379,11 @@ Client::svc (void) cubit_name.length (1); cubit_name[0].id = CORBA::string_dup (buffer); - objref = this->mt_cubit_context_->resolve (cubit_name, TAO_TRY_ENV); + objref = this->mt_cubit_context_->resolve (cubit_name, + TAO_TRY_ENV); - if ( (TAO_TRY_ENV.exception () != 0) - || CORBA::is_nil (objref.in ()) ) + if (TAO_TRY_ENV.exception () != 0 + || CORBA::is_nil (objref.in ())) { ACE_DEBUG ((LM_DEBUG, " (%t) resolve() returned nil\n")); @@ -389,7 +398,7 @@ Client::svc (void) } } - if ( (naming_success == CORBA::B_FALSE) && (ts_->factory_ior_ != 0) ) + if (naming_success == CORBA::B_FALSE && ts_->factory_ior_ != 0) { ACE_DEBUG ((LM_DEBUG, " (%t) ----- Using the factory IOR method to get cubit objects -----\n")); @@ -407,18 +416,21 @@ Client::svc (void) // Narrow the CORBA::Object reference to the stub object, // checking the type along the way using _is_a. Cubit_Factory_var cb_factory = - Cubit_Factory::_narrow (objref.in (), TAO_TRY_ENV); + Cubit_Factory::_narrow (objref.in (), + TAO_TRY_ENV); TAO_CHECK_ENV; if (CORBA::is_nil (cb_factory.in ())) ACE_ERROR_RETURN ((LM_ERROR, - "Create cubit factory failed\n"), 1); + "Create cubit factory failed\n"), + 1); ACE_DEBUG ((LM_DEBUG, "(%t) >>> Factory binding succeeded\n")); - char * tmp_ior = cb_factory->create_cubit (thread_id, TAO_TRY_ENV); + char * tmp_ior = cb_factory->create_cubit (thread_id, + TAO_TRY_ENV); TAO_CHECK_ENV; if (tmp_ior == 0) @@ -436,7 +448,7 @@ Client::svc (void) } else { - char * my_ior = ts_->iors_[thread_id]; + char *my_ior = ts_->iors_[thread_id]; if (my_ior == 0) ACE_ERROR_RETURN ((LM_ERROR, @@ -456,12 +468,14 @@ Client::svc (void) // Narrow the CORBA::Object reference to the stub object, // checking the type along the way using _is_a. - cb = Cubit::_narrow (objref.in (), TAO_TRY_ENV); + cb = Cubit::_narrow (objref.in (), + TAO_TRY_ENV); TAO_CHECK_ENV; if (CORBA::is_nil (cb)) ACE_ERROR_RETURN ((LM_ERROR, - "Create cubit failed\n"), 1); + "Create cubit failed\n"), + 1); ACE_DEBUG ((LM_DEBUG, "(%t) Binding succeeded\n")); @@ -471,7 +485,8 @@ Client::svc (void) TAO_CHECK_ENV; ACE_DEBUG ((LM_DEBUG, - "(%t) CUBIT OBJECT connected <%s>\n", str.in ())); + "(%t) CUBIT OBJECT connected <%s>\n", + str.in ())); ACE_DEBUG ((LM_DEBUG, "(%t) Waiting for other threads to " @@ -495,8 +510,12 @@ Client::svc (void) ACE_DEBUG ((LM_DEBUG, "(%t) **** USING ONEWAY CALLS ****\n")); - int result = this->run_tests (cb, ts_->loop_count_, thread_id, - ts_->datatype_, frequency); + // Perform the tests. + int result = this->run_tests (cb, + ts_->loop_count_, + thread_id, + ts_->datatype_, + frequency); if (result == -1) return -1; @@ -508,7 +527,8 @@ Client::svc (void) cb->shutdown (env); if (env.exception () != 0) { - ACE_ERROR ((LM_ERROR, "Shutdown of the server failed!\n")); + ACE_ERROR ((LM_ERROR, + "Shutdown of the server failed!\n")); env.print_exception ("shutdown() call failed.\n"); } } @@ -553,7 +573,8 @@ Client::run_tests (Cubit_ptr cb, ACE_Time_Value delta_t; timer_.start (); - // ACE_OS::ACE_HRTIMER_START; not using sysBench when CHORUS defined + // ACE_OS::ACE_HRTIMER_START; not using sysBench when CHORUS + // defined. if (ts_->oneway_ == 0) { @@ -582,7 +603,6 @@ Client::run_tests (Cubit_ptr cb, env.exception ()), 2); } - arg_octet = arg_octet * arg_octet * arg_octet; if (arg_octet != ret_octet) @@ -594,9 +614,8 @@ Client::run_tests (Cubit_ptr cb, error_count++; } call_count++; + break; } - break; - case CB_SHORT: // Cube a short. { @@ -806,7 +825,8 @@ Client::run_tests (Cubit_ptr cb, 0, thread_id); ACE_DEBUG ((LM_DEBUG, - "*** Warning: Latency is less than or equal to zero. Precision may have been lost.\n")); + "*** Warning: Latency is less than or equal to zero." + " Precision may have been lost.\n")); } } ACE_DEBUG ((LM_DEBUG, diff --git a/TAO/performance-tests/Cubit/TAO/MT_Cubit/Task_Client.h b/TAO/performance-tests/Cubit/TAO/MT_Cubit/Task_Client.h index b8fe73761c7..ae826e50d14 100644 --- a/TAO/performance-tests/Cubit/TAO/MT_Cubit/Task_Client.h +++ b/TAO/performance-tests/Cubit/TAO/MT_Cubit/Task_Client.h @@ -36,7 +36,8 @@ #if defined (ACE_LACKS_FLOATING_POINT) #define double ACE_UINT32 #define fabs(X) ((X) >= 0 ? (X) : -(X)) -// the following is just temporal, until we finish the sqrt() implementation. +// the following is just temporary, until we finish the sqrt() +// implementation. #define sqrt(X) (1) #endif /* ACE_LACKS_FLOATING_POINT */ @@ -60,9 +61,7 @@ func (u_int i) enum Cubit_Datatypes { - // = The various datatypes which the client and the server can - // exchange. - + // = The various datatypes the client and the server can exchange. CB_OCTET, CB_SHORT, CB_LONG, diff --git a/TAO/performance-tests/Cubit/TAO/MT_Cubit/Util_Thread.cpp b/TAO/performance-tests/Cubit/TAO/MT_Cubit/Util_Thread.cpp index 28460bc91f9..409bfaa8d9c 100644 --- a/TAO/performance-tests/Cubit/TAO/MT_Cubit/Util_Thread.cpp +++ b/TAO/performance-tests/Cubit/TAO/MT_Cubit/Util_Thread.cpp @@ -39,8 +39,8 @@ Util_Thread::get_number_of_computations (void) return this->number_of_computations_; } -// Perform repeated prime factor computations on an arbitrary number -// and you thought your life was boring. :-) +// Perform repeated prime factor computations on an arbitrary number. +// And you thought your life was boring... :-) int Util_Thread::run_computations (void) diff --git a/TAO/performance-tests/Cubit/TAO/MT_Cubit/Util_Thread.h b/TAO/performance-tests/Cubit/TAO/MT_Cubit/Util_Thread.h index 2be42c1deab..e1de9332dd5 100644 --- a/TAO/performance-tests/Cubit/TAO/MT_Cubit/Util_Thread.h +++ b/TAO/performance-tests/Cubit/TAO/MT_Cubit/Util_Thread.h @@ -19,8 +19,8 @@ #include "Task_Client.h" -// This is the arbitrary number that the Util_Thread -// uses to check for primality. +// This is the arbitrary number that the Util_Thread uses to check for +// primality. const int CUBIT_ARBIT_NUMBER = 10000019; class Util_Thread : public ACE_Task<ACE_SYNCH> diff --git a/TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit_i.cpp b/TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit_i.cpp index 4edabfaf14a..573e4fe2fd6 100644 --- a/TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit_i.cpp +++ b/TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit_i.cpp @@ -37,9 +37,9 @@ Cubit_i::cube_struct (const Cubit::Many &values, CORBA::Environment &) { Cubit::Many out_values; - out_values.o = values.o * values.o * values.o; - out_values.s = values.s * values.s * values.s; - out_values.l = values.l * values.l * values.l; + out_values.o = values.o * values.o * values.o; + out_values.s = values.s * values.s * values.s; + out_values.l = values.l * values.l * values.l; return out_values; } @@ -57,11 +57,16 @@ void Cubit_i::shutdown (CORBA::Environment &) // Constructor -Cubit_Factory_i::Cubit_Factory_i (CORBA::String * cubits, u_int num_of_objs) +Cubit_Factory_i::Cubit_Factory_i (CORBA::String *cubits, + u_int num_of_objs) : num_of_objs_ (num_of_objs) { - my_cubit_ = new CORBA::String [num_of_objs_]; - for (u_int i = 0; i < num_of_objs_; ++i) + ACE_NEW (my_cubit_, + CORBA::String[num_of_objs_]); + + for (u_int i = 0; + i < num_of_objs_; + ++i) my_cubit_[i] = ACE_OS::strdup (cubits[i]); } @@ -87,6 +92,7 @@ Cubit_Factory_i::create_cubit (CORBA::UShort orb_index, "(%P|%t) ior returned is [%d]:<%s>\n", orb_index, my_cubit_[orb_index])); + return ACE_OS::strdup (my_cubit_[orb_index]); } diff --git a/TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit_i.h b/TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit_i.h index 22da06e157f..96bbd22d62d 100644 --- a/TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit_i.h +++ b/TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit_i.h @@ -49,7 +49,8 @@ class Cubit_Factory_i : public POA_Cubit_Factory // = TITLE // Cubit Factory implementation class. public: - Cubit_Factory_i (CORBA::String * cubits, u_int num_of_objs); + Cubit_Factory_i (CORBA::String *cubits, + u_int num_of_objs); // Constructor. ~Cubit_Factory_i (void); diff --git a/TAO/performance-tests/Cubit/TAO/MT_Cubit/server.cpp b/TAO/performance-tests/Cubit/TAO/MT_Cubit/server.cpp index d545ef1f338..58942cc464f 100644 --- a/TAO/performance-tests/Cubit/TAO/MT_Cubit/server.cpp +++ b/TAO/performance-tests/Cubit/TAO/MT_Cubit/server.cpp @@ -178,9 +178,11 @@ Cubit_Task::initialize_orb (void) 1); this->naming_context_ = - CosNaming::NamingContext::_narrow (naming_obj.in (), TAO_TRY_ENV); + CosNaming::NamingContext::_narrow (naming_obj.in (), + TAO_TRY_ENV); - // Check the environment and return 1 if exception occurred or nil pointer. + // Check the environment and return 1 if exception occurred or + // nil pointer. if (TAO_TRY_ENV.exception () != 0 || CORBA::is_nil (this->naming_context_.in ())==CORBA::B_TRUE ) return 1; @@ -406,6 +408,7 @@ Cubit_Factory_Task::svc (void) ">>> (%P|%t) Beginning Cubit Factory task with args = '%s'\n", orbargs_)); + // @@ This should be replaced with the TAO_ORB_Manager... this->initialize_orb (); this->create_factory (); @@ -518,6 +521,9 @@ Cubit_Factory_Task::initialize_orb (void) } // Parses the command line arguments and returns an error status. +// @@ This method should be integrated into one of the classes +// (preferably into an Options singleton) rather than kept as a +// stand-alone function. static int parse_args (int argc, char *argv[]) @@ -567,16 +573,22 @@ parse_args (int argc, char *argv[]) return 0; } -int +// @@ This method should be integrated into one of the classes rather +// than kept as a stand-alone function. + +static int initialize (int argc, char **argv) { #if defined (VXWORKS) hostAdd ("mv2604e", "130.38.183.178"); #if defined (VME_DRIVER) STATUS status = vmeDrv (); + if (status != OK) printf ("ERROR on call to vmeDrv()\n"); + status = vmeDevCreate ("/vme"); + if (status != OK) printf ("ERROR on call to vmeDevCreate()\n"); #endif /* defined (VME_DRIVER) */ @@ -613,7 +625,11 @@ initialize (int argc, char **argv) } // Starts up the servants -int + +// @@ This method should be integrated into one of the classes rather +// than kept as a stand-alone function. + +static int start_servants (void) { char *args1; @@ -623,11 +639,11 @@ start_servants (void) -1); int i; + // Barrier for the multiple clients to synchronize after binding to + // the servants. ACE_Barrier barrier_ (num_of_objs + 1); - // Barrier for the multiple clients to synchronize after - // binding to the servants. - // Create an array to hold pointers to the Cubit objects + // Create an array to hold pointers to the Cubit objects. CORBA::String *cubits; ACE_NEW_RETURN (cubits, @@ -660,7 +676,7 @@ start_servants (void) 0, priority); - // Create an array to hold pointers to the low priority tasks.. + // Create an array to hold pointers to the low priority tasks. Cubit_Task **low_priority_task; ACE_NEW_RETURN (low_priority_task, @@ -679,6 +695,7 @@ start_servants (void) num_of_objs - 1)); // Create the low priority servants. + for (i = 0; i < num_of_objs - 1; i++) { char *args; @@ -727,17 +744,17 @@ start_servants (void) for (i = 0; i < num_of_objs-1; ++i) cubits[i + 1] = low_priority_task[i]->get_servant_ior (0); - FILE *iorFile = 0; + FILE *ior_file = 0; if (ior_file != 0) - iorFile = fopen (ior_file, "w"); + ior_file = fopen (ior_file, "w"); for (i = 0; i < num_of_objs; ++i) { if (ior_file != 0) { - fputs (cubits[i], iorFile); - fputs ("\n", iorFile); + fputs (cubits[i], ior_file); + fputs ("\n", ior_file); } ACE_OS::printf ("cubits[%d] ior = %s\n", i, @@ -745,7 +762,7 @@ start_servants (void) } if (ior_file != 0) - ACE_OS::fclose (iorFile); + ACE_OS::fclose (ior_file); ACE_NEW_RETURN (factory_task, Cubit_Factory_Task (args, "internet", cubits, num_of_objs), @@ -773,7 +790,7 @@ main (int argc, char *argv[]) ACE_ERROR_RETURN ((LM_ERROR, "Error in Initialization\n"), 1); - if(start_servants () != 0) + if (start_servants () != 0) ACE_ERROR_RETURN ((LM_ERROR, "Error creating the servants\n"), 1); diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.cpp b/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.cpp index 5107554cc0b..623dff29898 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.cpp +++ b/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.cpp @@ -60,8 +60,8 @@ Task_State::Task_State (int argc, char **argv) break; case CB_SHORT: default: - datatype_ = CB_SHORT; ACE_DEBUG ((LM_DEBUG, "Testing Shorts\n")); + datatype_ = CB_SHORT; break; } continue; @@ -91,12 +91,12 @@ Task_State::Task_State (int argc, char **argv) if (ior_file_ != 0) { - FILE *iorFile = ACE_OS::fopen (ior_file_, "r"); + FILE *ior_file = ACE_OS::fopen (ior_file_, "r"); char buf[BUFSIZ]; int i = 0; int j = 0; - while (ACE_OS::fgets (buf, BUFSIZ, iorFile) != 0) + while (ACE_OS::fgets (buf, BUFSIZ, ior_file) != 0) { j = ACE_OS::strlen (buf); buf[j - 1] = 0; // this is to delete the "\n" that was read from the file. @@ -104,7 +104,7 @@ Task_State::Task_State (int argc, char **argv) i++; } - ACE_OS::fclose (iorFile); + ACE_OS::fclose (ior_file); } // thread_count_ + 1 because there is one utilization thread also @@ -134,7 +134,9 @@ Client::put_ave_latency (int ave_latency, u_int thread_id) } void -Client::put_latency (double *jitter, double latency, u_int thread_id) +Client::put_latency (double *jitter, + double latency, + u_int thread_id) { ACE_MT (ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, ts_->lock_)); @@ -142,9 +144,13 @@ Client::put_latency (double *jitter, double latency, u_int thread_id) ts_->global_jitter_array_[thread_id] = jitter; #if defined (ACE_LACKS_FLOATING_POINT) - ACE_DEBUG ((LM_DEBUG, "(%t) My latency was %u\n", latency)); + ACE_DEBUG ((LM_DEBUG, + "(%t) My latency was %u\n", + latency)); #else - ACE_DEBUG ((LM_DEBUG, "(%t) My latency was %f\n", latency)); + ACE_DEBUG ((LM_DEBUG, + "(%t) My latency was %f\n", + latency)); #endif /* ! ACE_LACKS_FLOATING_POINT */ } @@ -168,7 +174,7 @@ Client::get_low_priority_latency (void) int Client::get_latency (u_int thread_id) { - return ts_->ave_latency_ [thread_id]; + return ts_->ave_latency_[thread_id]; } double @@ -184,12 +190,13 @@ Client::get_high_priority_jitter (void) // each latency has from the average for (u_int i = 0; i < ts_->loop_count_; i ++) { - double difference = ts_->global_jitter_array_ [0][i] - average; + double difference = + ts_->global_jitter_array_ [0][i] - average; jitter += difference * difference; } - // return the square root of the sum of the differences computed - // above, i.e. jitter + // Return the square root of the sum of the differences computed + // above, i.e. jitter. return sqrt (jitter); } @@ -202,8 +209,8 @@ Client::get_low_priority_jitter (void) // Compute the standard deviation (i.e. jitter) from the values // stored in the global_jitter_array_. - // we first compute the sum of the squares of the differences - // each latency has from the average + // We first compute the sum of the squares of the differences each + // latency has from the average. for (u_int j = 1; j < ts_->start_count_; j ++) for (u_int i = 0; i < ts_->loop_count_; i ++) { @@ -211,15 +218,16 @@ Client::get_low_priority_jitter (void) jitter += difference * difference; } - // return the square root of the sum of the differences computed - // above, i.e. jitter + // Return the square root of the sum of the differences computed + // above, i.e. jitter. return sqrt (jitter); } int Client::svc (void) { - ACE_DEBUG ((LM_DEBUG, "(%t) Thread created\n")); + ACE_DEBUG ((LM_DEBUG, + "(%t) Thread created\n")); u_int thread_id; Cubit_ptr cb = 0; @@ -240,12 +248,12 @@ Client::svc (void) ACE_OS::strcpy (tmp_buf, tmp_args.buf ()); - // Add the argument + // Add the argument. ACE_OS::strcat (tmp_buf, " -ORBobjrefstyle url "); // Convert back to argv vector style. - ACE_ARGV tmp_args2(tmp_buf); + ACE_ARGV tmp_args2 (tmp_buf); int argc = tmp_args2.argc (); char *const *argv = tmp_args2.argv (); @@ -300,39 +308,37 @@ Client::svc (void) } } else - { - switch (thread_id) - { - case CB_40HZ_CONSUMER: - ACE_DEBUG ((LM_DEBUG, - "(%t) Im the high priority client, " - "my id is %d.\n", thread_id)); - frequency = CB_40HZ_CONSUMER_RATE; - break; - case CB_20HZ_CONSUMER: - ACE_DEBUG ((LM_DEBUG, "(%t) Im the high priority client, " - "my id is %d.\n", thread_id)); - frequency = CB_20HZ_CONSUMER_RATE; - break; - case CB_10HZ_CONSUMER: - ACE_DEBUG ((LM_DEBUG, "(%t) Im the high priority client, " - "my id is %d.\n", thread_id)); - frequency = CB_10HZ_CONSUMER_RATE; - break; - case CB_5HZ_CONSUMER: - ACE_DEBUG ((LM_DEBUG, "(%t) Im the high priority client, " - "my id is %d.\n", thread_id)); - frequency = CB_5HZ_CONSUMER_RATE; - break; - case CB_1HZ_CONSUMER: - ACE_DEBUG ((LM_DEBUG, "(%t) Im the high priority client, " - "my id is %d.\n", thread_id)); - frequency = CB_1HZ_CONSUMER_RATE; - break; - default: - ACE_DEBUG ((LM_DEBUG, "(%t) Invalid Thread ID.\n", thread_id)); - } - } + switch (thread_id) + { + case CB_40HZ_CONSUMER: + ACE_DEBUG ((LM_DEBUG, + "(%t) Im the high priority client, " + "my id is %d.\n", thread_id)); + frequency = CB_40HZ_CONSUMER_RATE; + break; + case CB_20HZ_CONSUMER: + ACE_DEBUG ((LM_DEBUG, "(%t) Im the high priority client, " + "my id is %d.\n", thread_id)); + frequency = CB_20HZ_CONSUMER_RATE; + break; + case CB_10HZ_CONSUMER: + ACE_DEBUG ((LM_DEBUG, "(%t) Im the high priority client, " + "my id is %d.\n", thread_id)); + frequency = CB_10HZ_CONSUMER_RATE; + break; + case CB_5HZ_CONSUMER: + ACE_DEBUG ((LM_DEBUG, "(%t) Im the high priority client, " + "my id is %d.\n", thread_id)); + frequency = CB_5HZ_CONSUMER_RATE; + break; + case CB_1HZ_CONSUMER: + ACE_DEBUG ((LM_DEBUG, "(%t) Im the high priority client, " + "my id is %d.\n", thread_id)); + frequency = CB_1HZ_CONSUMER_RATE; + break; + default: + ACE_DEBUG ((LM_DEBUG, "(%t) Invalid Thread ID.\n", thread_id)); + } TAO_TRY { @@ -359,7 +365,9 @@ Client::svc (void) char *buffer; int l = ACE_OS::strlen (ts_->key_) + 3; - ACE_NEW_RETURN (buffer, char[l], -1); + ACE_NEW_RETURN (buffer, + char[l], + -1); ACE_OS::sprintf (buffer, "%s%02d", @@ -371,10 +379,11 @@ Client::svc (void) cubit_name.length (1); cubit_name[0].id = CORBA::string_dup (buffer); - objref = this->mt_cubit_context_->resolve (cubit_name, TAO_TRY_ENV); + objref = this->mt_cubit_context_->resolve (cubit_name, + TAO_TRY_ENV); - if ( (TAO_TRY_ENV.exception () != 0) - || CORBA::is_nil (objref.in ()) ) + if (TAO_TRY_ENV.exception () != 0 + || CORBA::is_nil (objref.in ())) { ACE_DEBUG ((LM_DEBUG, " (%t) resolve() returned nil\n")); @@ -389,7 +398,7 @@ Client::svc (void) } } - if ( (naming_success == CORBA::B_FALSE) && (ts_->factory_ior_ != 0) ) + if (naming_success == CORBA::B_FALSE && ts_->factory_ior_ != 0) { ACE_DEBUG ((LM_DEBUG, " (%t) ----- Using the factory IOR method to get cubit objects -----\n")); @@ -407,18 +416,21 @@ Client::svc (void) // Narrow the CORBA::Object reference to the stub object, // checking the type along the way using _is_a. Cubit_Factory_var cb_factory = - Cubit_Factory::_narrow (objref.in (), TAO_TRY_ENV); + Cubit_Factory::_narrow (objref.in (), + TAO_TRY_ENV); TAO_CHECK_ENV; if (CORBA::is_nil (cb_factory.in ())) ACE_ERROR_RETURN ((LM_ERROR, - "Create cubit factory failed\n"), 1); + "Create cubit factory failed\n"), + 1); ACE_DEBUG ((LM_DEBUG, "(%t) >>> Factory binding succeeded\n")); - char * tmp_ior = cb_factory->create_cubit (thread_id, TAO_TRY_ENV); + char * tmp_ior = cb_factory->create_cubit (thread_id, + TAO_TRY_ENV); TAO_CHECK_ENV; if (tmp_ior == 0) @@ -436,7 +448,7 @@ Client::svc (void) } else { - char * my_ior = ts_->iors_[thread_id]; + char *my_ior = ts_->iors_[thread_id]; if (my_ior == 0) ACE_ERROR_RETURN ((LM_ERROR, @@ -456,12 +468,14 @@ Client::svc (void) // Narrow the CORBA::Object reference to the stub object, // checking the type along the way using _is_a. - cb = Cubit::_narrow (objref.in (), TAO_TRY_ENV); + cb = Cubit::_narrow (objref.in (), + TAO_TRY_ENV); TAO_CHECK_ENV; if (CORBA::is_nil (cb)) ACE_ERROR_RETURN ((LM_ERROR, - "Create cubit failed\n"), 1); + "Create cubit failed\n"), + 1); ACE_DEBUG ((LM_DEBUG, "(%t) Binding succeeded\n")); @@ -471,7 +485,8 @@ Client::svc (void) TAO_CHECK_ENV; ACE_DEBUG ((LM_DEBUG, - "(%t) CUBIT OBJECT connected <%s>\n", str.in ())); + "(%t) CUBIT OBJECT connected <%s>\n", + str.in ())); ACE_DEBUG ((LM_DEBUG, "(%t) Waiting for other threads to " @@ -495,8 +510,12 @@ Client::svc (void) ACE_DEBUG ((LM_DEBUG, "(%t) **** USING ONEWAY CALLS ****\n")); - int result = this->run_tests (cb, ts_->loop_count_, thread_id, - ts_->datatype_, frequency); + // Perform the tests. + int result = this->run_tests (cb, + ts_->loop_count_, + thread_id, + ts_->datatype_, + frequency); if (result == -1) return -1; @@ -508,7 +527,8 @@ Client::svc (void) cb->shutdown (env); if (env.exception () != 0) { - ACE_ERROR ((LM_ERROR, "Shutdown of the server failed!\n")); + ACE_ERROR ((LM_ERROR, + "Shutdown of the server failed!\n")); env.print_exception ("shutdown() call failed.\n"); } } @@ -553,7 +573,8 @@ Client::run_tests (Cubit_ptr cb, ACE_Time_Value delta_t; timer_.start (); - // ACE_OS::ACE_HRTIMER_START; not using sysBench when CHORUS defined + // ACE_OS::ACE_HRTIMER_START; not using sysBench when CHORUS + // defined. if (ts_->oneway_ == 0) { @@ -582,7 +603,6 @@ Client::run_tests (Cubit_ptr cb, env.exception ()), 2); } - arg_octet = arg_octet * arg_octet * arg_octet; if (arg_octet != ret_octet) @@ -594,9 +614,8 @@ Client::run_tests (Cubit_ptr cb, error_count++; } call_count++; + break; } - break; - case CB_SHORT: // Cube a short. { @@ -806,7 +825,8 @@ Client::run_tests (Cubit_ptr cb, 0, thread_id); ACE_DEBUG ((LM_DEBUG, - "*** Warning: Latency is less than or equal to zero. Precision may have been lost.\n")); + "*** Warning: Latency is less than or equal to zero." + " Precision may have been lost.\n")); } } ACE_DEBUG ((LM_DEBUG, diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.h b/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.h index b8fe73761c7..ae826e50d14 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.h +++ b/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.h @@ -36,7 +36,8 @@ #if defined (ACE_LACKS_FLOATING_POINT) #define double ACE_UINT32 #define fabs(X) ((X) >= 0 ? (X) : -(X)) -// the following is just temporal, until we finish the sqrt() implementation. +// the following is just temporary, until we finish the sqrt() +// implementation. #define sqrt(X) (1) #endif /* ACE_LACKS_FLOATING_POINT */ @@ -60,9 +61,7 @@ func (u_int i) enum Cubit_Datatypes { - // = The various datatypes which the client and the server can - // exchange. - + // = The various datatypes the client and the server can exchange. CB_OCTET, CB_SHORT, CB_LONG, diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.cpp b/TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.cpp index 28460bc91f9..409bfaa8d9c 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.cpp +++ b/TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.cpp @@ -39,8 +39,8 @@ Util_Thread::get_number_of_computations (void) return this->number_of_computations_; } -// Perform repeated prime factor computations on an arbitrary number -// and you thought your life was boring. :-) +// Perform repeated prime factor computations on an arbitrary number. +// And you thought your life was boring... :-) int Util_Thread::run_computations (void) diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.h b/TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.h index 2be42c1deab..e1de9332dd5 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.h +++ b/TAO/tests/Cubit/TAO/MT_Cubit/Util_Thread.h @@ -19,8 +19,8 @@ #include "Task_Client.h" -// This is the arbitrary number that the Util_Thread -// uses to check for primality. +// This is the arbitrary number that the Util_Thread uses to check for +// primality. const int CUBIT_ARBIT_NUMBER = 10000019; class Util_Thread : public ACE_Task<ACE_SYNCH> diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.cpp b/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.cpp index 4edabfaf14a..573e4fe2fd6 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.cpp +++ b/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.cpp @@ -37,9 +37,9 @@ Cubit_i::cube_struct (const Cubit::Many &values, CORBA::Environment &) { Cubit::Many out_values; - out_values.o = values.o * values.o * values.o; - out_values.s = values.s * values.s * values.s; - out_values.l = values.l * values.l * values.l; + out_values.o = values.o * values.o * values.o; + out_values.s = values.s * values.s * values.s; + out_values.l = values.l * values.l * values.l; return out_values; } @@ -57,11 +57,16 @@ void Cubit_i::shutdown (CORBA::Environment &) // Constructor -Cubit_Factory_i::Cubit_Factory_i (CORBA::String * cubits, u_int num_of_objs) +Cubit_Factory_i::Cubit_Factory_i (CORBA::String *cubits, + u_int num_of_objs) : num_of_objs_ (num_of_objs) { - my_cubit_ = new CORBA::String [num_of_objs_]; - for (u_int i = 0; i < num_of_objs_; ++i) + ACE_NEW (my_cubit_, + CORBA::String[num_of_objs_]); + + for (u_int i = 0; + i < num_of_objs_; + ++i) my_cubit_[i] = ACE_OS::strdup (cubits[i]); } @@ -87,6 +92,7 @@ Cubit_Factory_i::create_cubit (CORBA::UShort orb_index, "(%P|%t) ior returned is [%d]:<%s>\n", orb_index, my_cubit_[orb_index])); + return ACE_OS::strdup (my_cubit_[orb_index]); } diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.h b/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.h index 22da06e157f..96bbd22d62d 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.h +++ b/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.h @@ -49,7 +49,8 @@ class Cubit_Factory_i : public POA_Cubit_Factory // = TITLE // Cubit Factory implementation class. public: - Cubit_Factory_i (CORBA::String * cubits, u_int num_of_objs); + Cubit_Factory_i (CORBA::String *cubits, + u_int num_of_objs); // Constructor. ~Cubit_Factory_i (void); diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/server.cpp b/TAO/tests/Cubit/TAO/MT_Cubit/server.cpp index d545ef1f338..58942cc464f 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/server.cpp +++ b/TAO/tests/Cubit/TAO/MT_Cubit/server.cpp @@ -178,9 +178,11 @@ Cubit_Task::initialize_orb (void) 1); this->naming_context_ = - CosNaming::NamingContext::_narrow (naming_obj.in (), TAO_TRY_ENV); + CosNaming::NamingContext::_narrow (naming_obj.in (), + TAO_TRY_ENV); - // Check the environment and return 1 if exception occurred or nil pointer. + // Check the environment and return 1 if exception occurred or + // nil pointer. if (TAO_TRY_ENV.exception () != 0 || CORBA::is_nil (this->naming_context_.in ())==CORBA::B_TRUE ) return 1; @@ -406,6 +408,7 @@ Cubit_Factory_Task::svc (void) ">>> (%P|%t) Beginning Cubit Factory task with args = '%s'\n", orbargs_)); + // @@ This should be replaced with the TAO_ORB_Manager... this->initialize_orb (); this->create_factory (); @@ -518,6 +521,9 @@ Cubit_Factory_Task::initialize_orb (void) } // Parses the command line arguments and returns an error status. +// @@ This method should be integrated into one of the classes +// (preferably into an Options singleton) rather than kept as a +// stand-alone function. static int parse_args (int argc, char *argv[]) @@ -567,16 +573,22 @@ parse_args (int argc, char *argv[]) return 0; } -int +// @@ This method should be integrated into one of the classes rather +// than kept as a stand-alone function. + +static int initialize (int argc, char **argv) { #if defined (VXWORKS) hostAdd ("mv2604e", "130.38.183.178"); #if defined (VME_DRIVER) STATUS status = vmeDrv (); + if (status != OK) printf ("ERROR on call to vmeDrv()\n"); + status = vmeDevCreate ("/vme"); + if (status != OK) printf ("ERROR on call to vmeDevCreate()\n"); #endif /* defined (VME_DRIVER) */ @@ -613,7 +625,11 @@ initialize (int argc, char **argv) } // Starts up the servants -int + +// @@ This method should be integrated into one of the classes rather +// than kept as a stand-alone function. + +static int start_servants (void) { char *args1; @@ -623,11 +639,11 @@ start_servants (void) -1); int i; + // Barrier for the multiple clients to synchronize after binding to + // the servants. ACE_Barrier barrier_ (num_of_objs + 1); - // Barrier for the multiple clients to synchronize after - // binding to the servants. - // Create an array to hold pointers to the Cubit objects + // Create an array to hold pointers to the Cubit objects. CORBA::String *cubits; ACE_NEW_RETURN (cubits, @@ -660,7 +676,7 @@ start_servants (void) 0, priority); - // Create an array to hold pointers to the low priority tasks.. + // Create an array to hold pointers to the low priority tasks. Cubit_Task **low_priority_task; ACE_NEW_RETURN (low_priority_task, @@ -679,6 +695,7 @@ start_servants (void) num_of_objs - 1)); // Create the low priority servants. + for (i = 0; i < num_of_objs - 1; i++) { char *args; @@ -727,17 +744,17 @@ start_servants (void) for (i = 0; i < num_of_objs-1; ++i) cubits[i + 1] = low_priority_task[i]->get_servant_ior (0); - FILE *iorFile = 0; + FILE *ior_file = 0; if (ior_file != 0) - iorFile = fopen (ior_file, "w"); + ior_file = fopen (ior_file, "w"); for (i = 0; i < num_of_objs; ++i) { if (ior_file != 0) { - fputs (cubits[i], iorFile); - fputs ("\n", iorFile); + fputs (cubits[i], ior_file); + fputs ("\n", ior_file); } ACE_OS::printf ("cubits[%d] ior = %s\n", i, @@ -745,7 +762,7 @@ start_servants (void) } if (ior_file != 0) - ACE_OS::fclose (iorFile); + ACE_OS::fclose (ior_file); ACE_NEW_RETURN (factory_task, Cubit_Factory_Task (args, "internet", cubits, num_of_objs), @@ -773,7 +790,7 @@ main (int argc, char *argv[]) ACE_ERROR_RETURN ((LM_ERROR, "Error in Initialization\n"), 1); - if(start_servants () != 0) + if (start_servants () != 0) ACE_ERROR_RETURN ((LM_ERROR, "Error creating the servants\n"), 1); |