diff options
-rw-r--r-- | TAO/performance-tests/Cubit/TAO/MT_Cubit/client.h | 66 | ||||
-rw-r--r-- | TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit.idl | 10 | ||||
-rw-r--r-- | TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit_i.cpp | 1 | ||||
-rw-r--r-- | TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit_i.h | 7 | ||||
-rw-r--r-- | TAO/performance-tests/Cubit/TAO/MT_Cubit/server.cpp | 93 | ||||
-rw-r--r-- | TAO/performance-tests/Cubit/TAO/MT_Cubit/server.h | 89 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/client.h | 66 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/cubit.idl | 10 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.cpp | 1 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.h | 7 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/server.cpp | 93 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/server.h | 89 |
12 files changed, 286 insertions, 246 deletions
diff --git a/TAO/performance-tests/Cubit/TAO/MT_Cubit/client.h b/TAO/performance-tests/Cubit/TAO/MT_Cubit/client.h index cdf3b29a302..99e3591122c 100644 --- a/TAO/performance-tests/Cubit/TAO/MT_Cubit/client.h +++ b/TAO/performance-tests/Cubit/TAO/MT_Cubit/client.h @@ -43,12 +43,13 @@ public: ~Client_i (void); // destructor. - int init (int argc,char **argv); - // initialize the state of Client_i. + int init (int argc, char *argv[]); + // Initialize the state of <Client_i>. void run (void); - // run the tests. + // Run the tests. + // @@ Naga, can you please add comments for these methods? int do_priority_inversion_test (ACE_Thread_Manager *thread_manager); int do_thread_per_rate_test (ACE_Thread_Manager *thread_manager); @@ -60,45 +61,46 @@ public: #if defined (VXWORKS) void output_taskinfo (void); #endif /* VXWORKS */ + private: void init_low_priority (void); - // sets the priority to be used for the low priority clients. + // Sets the priority to be used for the low priority clients. void calc_util_time (void); - // calculate the time for one util computation. + // Calculate the time for one util computation. int activate_high_client (ACE_Thread_Manager *thread_manager); - // activates the high priority client. + // Activates the high priority client. int activate_low_client (ACE_Thread_Manager *thread_manager); - // activates the low priority client. + // Activates the low priority client. int activate_util_thread (void); - // activates the utilization thread. + // Activates the utilization thread. void print_priority_inversion_stats (void); - // prints the results of the tests. + // Prints the results of the tests. void print_context_stats (void); - // prints the context switch results. + // Prints the context switch results. void print_util_stats (void); - // prints the utilization test results. + // Prints the utilization test results. void print_latency_stats (void); - // prints the latency and jitter results. + // Prints the latency and jitter results. Client *high_priority_client_; - // pointer to the high priority client object. + // Pointer to the high priority client object. Client **low_priority_client_; - // array to hold pointers to the low priority tasks. + // Array to hold pointers to the low priority tasks. ACE_High_Res_Timer timer_; // Timer for timing the tests. MT_Priority priority_; - // priority helper object. + // Priority helper object. Util_Thread *util_thread_; // Utilization thread. @@ -107,30 +109,31 @@ private: // Utilization thread manager. ACE_timer_t util_task_duration_; - // time for one computation of utilization thread. + // Time for one computation of utilization thread. Task_State *ts_; - // pointer to task state. + // Pointer to task state. ACE_Sched_Priority high_priority_; - // priority used for the high priority client. + // Priority used for the high priority client. ACE_Sched_Priority low_priority_; - // priority used by the low priority clients. + // Priority used by the low priority clients. u_int num_low_priority_; - // number of low priority clients + // Number of low priority clients u_int num_priorities_; - // number of priorities used. + // Number of priorities used. u_int grain_; - // Granularity of the assignment of the priorities. Some OSs - // have fewer levels of priorities than we have threads in our - // test, so with this mechanism we assign priorities to groups - // of threads when there are more threads than priorities. + // Granularity of the assignment of the priorities. Some OSs have + // fewer levels of priorities than we have threads in our test, so + // with this mechanism we assign priorities to groups of threads + // when there are more threads than priorities. u_int counter_; + // @@ Naga, can you please add a comment here? char *task_id_; // Set a task_id string starting with "@", so we are able to @@ -140,17 +143,24 @@ private: // elapsed time for the latency tests. int argc_; + // @@ Naga, can you please add a comment here? char **argv_; + // @@ Naga, can you please add a comment here? ACE_Thread_Manager client_thread_manager_; - // Create a separate manager for the client. This allows the use - // of its wait () method on VxWorks, without interfering with the + // Create a separate manager for the client. This allows the use of + // its wait () method on VxWorks, without interfering with the // server's (global) thread manager. ACE_timer_t total_latency_; + // @@ Naga, can you please add a comment here? + ACE_timer_t total_latency_high_; + // @@ Naga, can you please add a comment here? + ACE_timer_t total_util_task_duration_; + // @@ Naga, can you please add a comment here? u_int context_switch_; // Stores the total number of context switches incurred by the @@ -159,7 +169,7 @@ private: #if (defined (ACE_HAS_PRUSAGE_T) || defined (ACE_HAS_GETRUSAGE)) && !defined (ACE_WIN32) ACE_Profile_Timer timer_for_context_switch; ACE_Profile_Timer::Rusage usage; -#endif +#endif /* (defined (ACE_HAS_PRUSAGE_T) || defined (ACE_HAS_GETRUSAGE)) && !defined (ACE_WIN32) */ }; diff --git a/TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit.idl b/TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit.idl index 74041bad851..113c7e24697 100644 --- a/TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit.idl +++ b/TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit.idl @@ -18,19 +18,19 @@ interface Cubit }; octet cube_octet (in octet o); - // cube an octet + // Cube an octet. short cube_short (in short s); - // cube a short + // Cube a short. long cube_long (in long l); - // cube a long + // Cube a long. Many cube_struct (in Many values); - // cube each of the members of a struct + // Cube each of the members of a struct. oneway void noop (); - // null operation + // Null operation. oneway void shutdown (); // shut down the application 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 493a65e0b60..a5dfc6bcf11 100644 --- a/TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit_i.cpp +++ b/TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit_i.cpp @@ -41,6 +41,7 @@ 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; 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 e48f6a0633d..a0f58ba2c30 100644 --- a/TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit_i.h +++ b/TAO/performance-tests/Cubit/TAO/MT_Cubit/cubit_i.h @@ -14,8 +14,8 @@ // // ============================================================================ -#if !defined (_CUBIT_I_HH) -#define _CUBIT_I_HH +#if !defined (_CUBIT_I_H) +#define _CUBIT_I_H #include "cubitS.h" @@ -24,6 +24,7 @@ class Cubit_i : public POA_Cubit // = TITLE // Cubit implementation class. public: + // = Initialization and termination methods. Cubit_i (CORBA::ORB_ptr orb); ~Cubit_i (void); @@ -48,4 +49,4 @@ protected: // Keep a pointer to the ORB so we can shut it down. }; -#endif /* _CUBIT_I_HH */ +#endif /* _CUBIT_I_H */ diff --git a/TAO/performance-tests/Cubit/TAO/MT_Cubit/server.cpp b/TAO/performance-tests/Cubit/TAO/MT_Cubit/server.cpp index 230d7c0e666..530b51ee34e 100644 --- a/TAO/performance-tests/Cubit/TAO/MT_Cubit/server.cpp +++ b/TAO/performance-tests/Cubit/TAO/MT_Cubit/server.cpp @@ -25,6 +25,7 @@ ACE_RCSID(MT_Cubit, server, "$Id$") +#if defined (VXWORKS) && defined (FORCE_ARGS) char *force_argv[]= { "server", @@ -32,6 +33,7 @@ char *force_argv[]= "-f", "ior.txt" }; +#endif /* defined (VXWORKS) && defined (FORCE_ARGS) */ Server::Server (void) :argc_ (0), @@ -49,20 +51,18 @@ Server::initialize (int argc, char **argv) { #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, + if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO, #if defined (__Lynx__) - 30, + 30, #elif defined (VXWORKS) /* ! __Lynx__ */ - 6, + 6, #elif defined (ACE_WIN32) - ACE_Sched_Params::priority_max (ACE_SCHED_FIFO, - ACE_SCOPE_THREAD), + ACE_Sched_Params::priority_max + (ACE_SCHED_FIFO, ACE_SCOPE_THREAD), #else - ACE_THR_PRI_FIFO_DEF + 25, + ACE_THR_PRI_FIFO_DEF + 25, #endif /* ! __Lynx__ */ - ACE_SCOPE_PROCESS)) != 0) + ACE_SCOPE_PROCESS)) != 0) { if (ACE_OS::last_error () == EPERM) ACE_DEBUG ((LM_MAX, @@ -89,9 +89,10 @@ Server::initialize (int argc, char **argv) this->argv_ = force_argv; #endif /* VXWORKS && FORCE_ARGS */ - // Make sure we've got plenty of socket handles. This call will - // use the default maximum. + // Make sure we've got plenty of socket handles. This call will use + // the default maximum. ACE::set_handle_limit (); + return 0; } @@ -126,7 +127,8 @@ void Server::init_low_priority (void) { ACE_Sched_Priority prev_priority = this->high_priority_; - // Drop the priority + + // Drop the priority. if (GLOBALS::instance ()->thread_per_rate == 1 || GLOBALS::instance ()->use_multiple_priority == 1) this->low_priority_ = @@ -138,30 +140,32 @@ Server::init_low_priority (void) this->priority_.get_low_priority (this->num_low_priority_, prev_priority, 0); + this->num_priorities_ = this->priority_.number_of_priorities (); this->grain_ = this->priority_.grain (); this->counter_ = 0; } // Write the ior's to a file so the client can read them. + void Server::write_iors (void) { u_int j; + this->cubits_[0] = ACE_OS::strdup (this->high_priority_task_->get_servant_ior (0)); for (j = 1; j < GLOBALS::instance ()->num_of_objs; ++j) - this->cubits_[j] = ACE_OS::strdup (this->low_priority_tasks_[j-1]->get_servant_ior (0)); + this->cubits_[j] = + ACE_OS::strdup (this->low_priority_tasks_[j-1]->get_servant_ior (0)); FILE *ior_f = 0; if (GLOBALS::instance ()->ior_file != 0) - { - // ACE_DEBUG ((LM_DEBUG,"(%P|%t) Opening file:%s\n",GLOBALS::instance ()->ior_file)); - ior_f = ACE_OS::fopen (GLOBALS::instance ()->ior_file, "w"); - } + ior_f = ACE_OS::fopen (GLOBALS::instance ()->ior_file, + "w"); for (j = 0; j < GLOBALS::instance ()->num_of_objs; @@ -169,19 +173,16 @@ Server::write_iors (void) { if (ior_f != 0) { - // ACE_DEBUG ((LM_DEBUG,"(%P|%t) ior_file is open :%s",GLOBALS::instance ()->ior_file)); ACE_OS::fprintf (ior_f, "%s\n", this->cubits_[j]); - ACE_OS::printf ("this->cubits_[%d] ior = %s\n", - j, - this->cubits_[j]); + ACE_DEBUG ((LM_DEBUG, + "this->cubits_[%d] ior = %s\n", + j, + this->cubits_[j])); } } if (ior_f != 0) - { - // ACE_DEBUG ((LM_DEBUG,"(%P|%t) Closing ior file\n")); - ACE_OS::fclose (ior_f); - } + ACE_OS::fclose (ior_f); } int @@ -203,9 +204,11 @@ Server::activate_high_servant (ACE_Thread_Manager *serv_thr_mgr) "-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", @@ -213,11 +216,13 @@ Server::activate_high_servant (ACE_Thread_Manager *serv_thr_mgr) serv_thr_mgr, 0), //task id 0. -1); + // Make the high priority task an active object. - if (this->high_priority_task_->activate (THR_BOUND | ACE_SCHED_FIFO, - 1, - 0, - this->high_priority_) == -1) + if (this->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")); @@ -225,15 +230,14 @@ Server::activate_high_servant (ACE_Thread_Manager *serv_thr_mgr) ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ready_mon, GLOBALS::instance ()->ready_mtx_, - -1) - ); + -1)); - // wait on the condition variable for the high priority client to + // Wait on the condition variable for the high priority client to // finish parsing the arguments. while (!GLOBALS::instance ()->ready_) GLOBALS::instance ()->ready_cnd_.wait (); - // default return success. + // Default return success. return 0; } @@ -247,6 +251,7 @@ Server::activate_low_servants (ACE_Thread_Manager *serv_thr_mgr) 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_, @@ -256,7 +261,10 @@ Server::activate_low_servants (ACE_Thread_Manager *serv_thr_mgr) ACE_NEW_RETURN (this->low_priority_tasks_, Cubit_Task *[GLOBALS::instance ()->num_of_objs], -1); - for (i = this->num_low_priority_; i > 0; i--) + + for (i = this->num_low_priority_; + i > 0; + i--) { ACE_OS::sprintf (orbport, "-ORBport %d", @@ -274,6 +282,7 @@ Server::activate_low_servants (ACE_Thread_Manager *serv_thr_mgr) ACE_ARGV (this->argv_, low_second_argv), -1); + ACE_NEW_RETURN (this->low_priority_tasks_ [i - 1], Cubit_Task (this->low_argv_->buf (), "internet", @@ -281,6 +290,7 @@ Server::activate_low_servants (ACE_Thread_Manager *serv_thr_mgr) serv_thr_mgr, i), -1); + // Make the low priority task an active object. if (this->low_priority_tasks_ [i - 1]->activate (THR_BOUND | ACE_SCHED_FIFO, 1, @@ -300,11 +310,11 @@ Server::activate_low_servants (ACE_Thread_Manager *serv_thr_mgr) || GLOBALS::instance ()->thread_per_rate == 1) { this->counter_ = (this->counter_ + 1) % this->grain_; + if (this->counter_ == 0 - && //Just so when we distribute the priorities among the //threads, we make sure we don't go overboard. - this->num_priorities_ * this->grain_ > this->num_low_priority_ - (i - 1)) + && 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_, @@ -333,7 +343,7 @@ Server::start_servants (ACE_Thread_Manager *serv_thr_mgr) "Creating servant 0 with high priority %d\n", this->high_priority_)); - // activate the high priority servant task + // Activate the high priority servant task if (this->activate_high_servant (serv_thr_mgr) < 0) ACE_ERROR_RETURN ((LM_ERROR, "Failure in activating high priority servant\n"), @@ -342,23 +352,22 @@ Server::start_servants (ACE_Thread_Manager *serv_thr_mgr) this->num_low_priority_ = GLOBALS::instance ()->num_of_objs - 1; - // initialize the priority of the low priority servants. + // Initialize the priority of the low priority servants. this->init_low_priority (); - // activate the low priority servants. + // Activate the low priority servants. if (this->activate_low_servants (serv_thr_mgr) < 0) ACE_ERROR_RETURN ((LM_ERROR, "Failure in activating low priority servant\n"), -1); - // wait in the barrier. + // Wait in the barrier. GLOBALS::instance ()->barrier_->wait (); - this->write_iors (); return 0; } -// main routine. +// The main() function. #if defined (VXWORKS) // Rename main to server to make it easier to run both client and diff --git a/TAO/performance-tests/Cubit/TAO/MT_Cubit/server.h b/TAO/performance-tests/Cubit/TAO/MT_Cubit/server.h index d270381632e..d24a89df6eb 100644 --- a/TAO/performance-tests/Cubit/TAO/MT_Cubit/server.h +++ b/TAO/performance-tests/Cubit/TAO/MT_Cubit/server.h @@ -1,8 +1,6 @@ /* -*- C++ -*- */ // $Id$ -#if !defined (SERVER_H) -#define SERVER_H // ============================================================================ // // = LIBRARY @@ -16,13 +14,17 @@ // // ============================================================================ +#if !defined (SERVER_H) +#define SERVER_H + // ACE includes. #if defined (TAO_PLATFORM_SVC_CONF_FILE_NOTSUP) -#define TAO_DEFAULT_SERVER_STRATEGY_FACTORY_ARGS { "-ORBconcurrency", "thread-per-connection", \ +#define TAO_DEFAULT_SERVER_STRATEGY_FACTORY_ARGS \ +{ "-ORBconcurrency", "thread-per-connection", \ "-ORBdemuxstrategy", "dynamic", \ "-ORBtablesize", "128" } -#endif +#endif /* TAO_PLATFORM_SVC_CONF_FILE_NOTSUP */ #include "ace/OS.h" #include "ace/Get_Opt.h" @@ -48,16 +50,7 @@ extern "C" STATUS vmeDrv (void); extern "C" STATUS vmeDevCreate (char *); #endif /* VME_DRIVER */ -#if !defined (ACE_HAS_THREADS) -class NOOP_ACE_Barrier -{ -public: - NOOP_ACE_Barrier (int ) {} - void wait (void) {} -}; -#define ACE_Barrier NOOP_ACE_Barrier -#endif /* ACE_HAS_THREADS */ - +// Make the globals a Singleton. typedef ACE_Singleton<Globals,ACE_Null_Mutex> GLOBALS; // @@ Naga, can you please split this class into a separate file @@ -79,6 +72,7 @@ public: // Active Object entry point. CORBA::String get_servant_ior (u_int index); + // @@ Naga, can you please comment this? protected: Cubit_Task (void); @@ -89,7 +83,7 @@ private: // Initialize the ORB, and POA. int create_servants (void); - // Create the servants + // Create the servants. CORBA::String key_; // All cubit objects will have this as prefix to its key. @@ -107,97 +101,100 @@ private: // Pointer to the ORB Cubit_i **servants_; - // Array to hold the servants + // Array to hold the servants. CORBA::String *servants_iors_; - // ior strings of the servants + // IOR strings of the servants. //CosNaming::NamingContext_var naming_context_; - // Object reference to the naming service + // Object reference to the naming service. u_int task_id_; - // id used for naming service object name. + // ID used for naming service object name. CosNaming::NamingContext_var mt_cubit_context_; - // context where all MT Cubit objects will be created. + // Context where all MT Cubit objects will be created. TAO_ORB_Manager orb_manager_; - // The TAO ORB Manager + // The TAO ORB Manager. TAO_Naming_Client my_name_client_; // An instance of the name client used for resolving the factory // objects. }; -class Server - :public virtual MT_Priority +// @@ Naga, why do we inherit this "public virtual?" Isn't "virtual" +// good enough? +class Server : public virtual MT_Priority { // = TITLE // A multithreaded cubit server class. + // // = DESCRIPTION // This class encapsulates the functionality of a multi-threaded - // cubit server. To use this ,call initialize and then + // cubit server. To use this, call initialize and then // start_servants method. public: Server (void); - // default constructor + // Default constructor. int initialize (int argc, char **argv); - // initialize the server state. + // Initialize the server state. int start_servants (ACE_Thread_Manager *serv_thr_mgr); - // start the high and low priority servants. + // Start the high and low priority servants. private: void prelim_args_process (void); - // preliminary argument processing code. + // Preliminary argument processing code. void init_low_priority (void); // sets the priority to be used for the low priority servants. void write_iors (void); - // writes the iors of the servants to a file + // Writes the iors of the servants to a file int activate_high_servant (ACE_Thread_Manager *serv_thr_mgr); - // activates the high priority servant. + // Activates the high priority servant. int activate_low_servants (ACE_Thread_Manager *serv_thr_mgr); - // activates the low priority servants. + // Activates the low priority servants. int argc_; - // number of arguments for the servant. + // Number of arguments for the servant. char **argv_; - // arguments for the ORB. + // Arguments for the ORB. CORBA::String *cubits_; - // array to hold pointers to the Cubit objects. + // Array to hold pointers to the Cubit objects. Cubit_Task *high_priority_task_; - // pointer to the high priority task + // Pointer to the high priority task Cubit_Task **low_priority_tasks_; - // array to hold pointers to the low priority tasks. + // Array to hold pointers to the low priority tasks. ACE_Sched_Priority high_priority_; - // priority used for the high priority servant. + // Priority used for the high priority servant. ACE_Sched_Priority low_priority_; - // priority used by the low priority servants. + // Priority used by the low priority servants. u_int num_low_priority_; - // number of low priority servants + // Number of low priority servants u_int num_priorities_; - // number of priorities used. + // Number of priorities used. u_int grain_; - // Granularity of the assignment of the priorities. Some OSs - // have fewer levels of priorities than we have threads in our - // test, so with this mechanism we assign priorities to groups - // of threads when there are more threads than priorities. + // Granularity of the assignment of the priorities. Some OSs have + // fewer levels of priorities than we have threads in our test, so + // with this mechanism we assign priorities to groups of threads + // when there are more threads than priorities. u_int counter_; + // @@ Naga, can you please comment this? ACE_ARGV *high_argv_; // argv passed to the high priority servant. @@ -206,7 +203,9 @@ private: // argv passed to the low priority servants. MT_Priority priority_; - // priority helper object. + // Priority helper object. + // @@ Naga, why do we both inherit from MT_Priority and also define + // an instance of it? }; #endif /* SERVER_H */ diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/client.h b/TAO/tests/Cubit/TAO/MT_Cubit/client.h index cdf3b29a302..99e3591122c 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/client.h +++ b/TAO/tests/Cubit/TAO/MT_Cubit/client.h @@ -43,12 +43,13 @@ public: ~Client_i (void); // destructor. - int init (int argc,char **argv); - // initialize the state of Client_i. + int init (int argc, char *argv[]); + // Initialize the state of <Client_i>. void run (void); - // run the tests. + // Run the tests. + // @@ Naga, can you please add comments for these methods? int do_priority_inversion_test (ACE_Thread_Manager *thread_manager); int do_thread_per_rate_test (ACE_Thread_Manager *thread_manager); @@ -60,45 +61,46 @@ public: #if defined (VXWORKS) void output_taskinfo (void); #endif /* VXWORKS */ + private: void init_low_priority (void); - // sets the priority to be used for the low priority clients. + // Sets the priority to be used for the low priority clients. void calc_util_time (void); - // calculate the time for one util computation. + // Calculate the time for one util computation. int activate_high_client (ACE_Thread_Manager *thread_manager); - // activates the high priority client. + // Activates the high priority client. int activate_low_client (ACE_Thread_Manager *thread_manager); - // activates the low priority client. + // Activates the low priority client. int activate_util_thread (void); - // activates the utilization thread. + // Activates the utilization thread. void print_priority_inversion_stats (void); - // prints the results of the tests. + // Prints the results of the tests. void print_context_stats (void); - // prints the context switch results. + // Prints the context switch results. void print_util_stats (void); - // prints the utilization test results. + // Prints the utilization test results. void print_latency_stats (void); - // prints the latency and jitter results. + // Prints the latency and jitter results. Client *high_priority_client_; - // pointer to the high priority client object. + // Pointer to the high priority client object. Client **low_priority_client_; - // array to hold pointers to the low priority tasks. + // Array to hold pointers to the low priority tasks. ACE_High_Res_Timer timer_; // Timer for timing the tests. MT_Priority priority_; - // priority helper object. + // Priority helper object. Util_Thread *util_thread_; // Utilization thread. @@ -107,30 +109,31 @@ private: // Utilization thread manager. ACE_timer_t util_task_duration_; - // time for one computation of utilization thread. + // Time for one computation of utilization thread. Task_State *ts_; - // pointer to task state. + // Pointer to task state. ACE_Sched_Priority high_priority_; - // priority used for the high priority client. + // Priority used for the high priority client. ACE_Sched_Priority low_priority_; - // priority used by the low priority clients. + // Priority used by the low priority clients. u_int num_low_priority_; - // number of low priority clients + // Number of low priority clients u_int num_priorities_; - // number of priorities used. + // Number of priorities used. u_int grain_; - // Granularity of the assignment of the priorities. Some OSs - // have fewer levels of priorities than we have threads in our - // test, so with this mechanism we assign priorities to groups - // of threads when there are more threads than priorities. + // Granularity of the assignment of the priorities. Some OSs have + // fewer levels of priorities than we have threads in our test, so + // with this mechanism we assign priorities to groups of threads + // when there are more threads than priorities. u_int counter_; + // @@ Naga, can you please add a comment here? char *task_id_; // Set a task_id string starting with "@", so we are able to @@ -140,17 +143,24 @@ private: // elapsed time for the latency tests. int argc_; + // @@ Naga, can you please add a comment here? char **argv_; + // @@ Naga, can you please add a comment here? ACE_Thread_Manager client_thread_manager_; - // Create a separate manager for the client. This allows the use - // of its wait () method on VxWorks, without interfering with the + // Create a separate manager for the client. This allows the use of + // its wait () method on VxWorks, without interfering with the // server's (global) thread manager. ACE_timer_t total_latency_; + // @@ Naga, can you please add a comment here? + ACE_timer_t total_latency_high_; + // @@ Naga, can you please add a comment here? + ACE_timer_t total_util_task_duration_; + // @@ Naga, can you please add a comment here? u_int context_switch_; // Stores the total number of context switches incurred by the @@ -159,7 +169,7 @@ private: #if (defined (ACE_HAS_PRUSAGE_T) || defined (ACE_HAS_GETRUSAGE)) && !defined (ACE_WIN32) ACE_Profile_Timer timer_for_context_switch; ACE_Profile_Timer::Rusage usage; -#endif +#endif /* (defined (ACE_HAS_PRUSAGE_T) || defined (ACE_HAS_GETRUSAGE)) && !defined (ACE_WIN32) */ }; diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/cubit.idl b/TAO/tests/Cubit/TAO/MT_Cubit/cubit.idl index 74041bad851..113c7e24697 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/cubit.idl +++ b/TAO/tests/Cubit/TAO/MT_Cubit/cubit.idl @@ -18,19 +18,19 @@ interface Cubit }; octet cube_octet (in octet o); - // cube an octet + // Cube an octet. short cube_short (in short s); - // cube a short + // Cube a short. long cube_long (in long l); - // cube a long + // Cube a long. Many cube_struct (in Many values); - // cube each of the members of a struct + // Cube each of the members of a struct. oneway void noop (); - // null operation + // Null operation. oneway void shutdown (); // shut down the application diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.cpp b/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.cpp index 493a65e0b60..a5dfc6bcf11 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.cpp +++ b/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.cpp @@ -41,6 +41,7 @@ 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; diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.h b/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.h index e48f6a0633d..a0f58ba2c30 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.h +++ b/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.h @@ -14,8 +14,8 @@ // // ============================================================================ -#if !defined (_CUBIT_I_HH) -#define _CUBIT_I_HH +#if !defined (_CUBIT_I_H) +#define _CUBIT_I_H #include "cubitS.h" @@ -24,6 +24,7 @@ class Cubit_i : public POA_Cubit // = TITLE // Cubit implementation class. public: + // = Initialization and termination methods. Cubit_i (CORBA::ORB_ptr orb); ~Cubit_i (void); @@ -48,4 +49,4 @@ protected: // Keep a pointer to the ORB so we can shut it down. }; -#endif /* _CUBIT_I_HH */ +#endif /* _CUBIT_I_H */ diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/server.cpp b/TAO/tests/Cubit/TAO/MT_Cubit/server.cpp index 230d7c0e666..530b51ee34e 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/server.cpp +++ b/TAO/tests/Cubit/TAO/MT_Cubit/server.cpp @@ -25,6 +25,7 @@ ACE_RCSID(MT_Cubit, server, "$Id$") +#if defined (VXWORKS) && defined (FORCE_ARGS) char *force_argv[]= { "server", @@ -32,6 +33,7 @@ char *force_argv[]= "-f", "ior.txt" }; +#endif /* defined (VXWORKS) && defined (FORCE_ARGS) */ Server::Server (void) :argc_ (0), @@ -49,20 +51,18 @@ Server::initialize (int argc, char **argv) { #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, + if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO, #if defined (__Lynx__) - 30, + 30, #elif defined (VXWORKS) /* ! __Lynx__ */ - 6, + 6, #elif defined (ACE_WIN32) - ACE_Sched_Params::priority_max (ACE_SCHED_FIFO, - ACE_SCOPE_THREAD), + ACE_Sched_Params::priority_max + (ACE_SCHED_FIFO, ACE_SCOPE_THREAD), #else - ACE_THR_PRI_FIFO_DEF + 25, + ACE_THR_PRI_FIFO_DEF + 25, #endif /* ! __Lynx__ */ - ACE_SCOPE_PROCESS)) != 0) + ACE_SCOPE_PROCESS)) != 0) { if (ACE_OS::last_error () == EPERM) ACE_DEBUG ((LM_MAX, @@ -89,9 +89,10 @@ Server::initialize (int argc, char **argv) this->argv_ = force_argv; #endif /* VXWORKS && FORCE_ARGS */ - // Make sure we've got plenty of socket handles. This call will - // use the default maximum. + // Make sure we've got plenty of socket handles. This call will use + // the default maximum. ACE::set_handle_limit (); + return 0; } @@ -126,7 +127,8 @@ void Server::init_low_priority (void) { ACE_Sched_Priority prev_priority = this->high_priority_; - // Drop the priority + + // Drop the priority. if (GLOBALS::instance ()->thread_per_rate == 1 || GLOBALS::instance ()->use_multiple_priority == 1) this->low_priority_ = @@ -138,30 +140,32 @@ Server::init_low_priority (void) this->priority_.get_low_priority (this->num_low_priority_, prev_priority, 0); + this->num_priorities_ = this->priority_.number_of_priorities (); this->grain_ = this->priority_.grain (); this->counter_ = 0; } // Write the ior's to a file so the client can read them. + void Server::write_iors (void) { u_int j; + this->cubits_[0] = ACE_OS::strdup (this->high_priority_task_->get_servant_ior (0)); for (j = 1; j < GLOBALS::instance ()->num_of_objs; ++j) - this->cubits_[j] = ACE_OS::strdup (this->low_priority_tasks_[j-1]->get_servant_ior (0)); + this->cubits_[j] = + ACE_OS::strdup (this->low_priority_tasks_[j-1]->get_servant_ior (0)); FILE *ior_f = 0; if (GLOBALS::instance ()->ior_file != 0) - { - // ACE_DEBUG ((LM_DEBUG,"(%P|%t) Opening file:%s\n",GLOBALS::instance ()->ior_file)); - ior_f = ACE_OS::fopen (GLOBALS::instance ()->ior_file, "w"); - } + ior_f = ACE_OS::fopen (GLOBALS::instance ()->ior_file, + "w"); for (j = 0; j < GLOBALS::instance ()->num_of_objs; @@ -169,19 +173,16 @@ Server::write_iors (void) { if (ior_f != 0) { - // ACE_DEBUG ((LM_DEBUG,"(%P|%t) ior_file is open :%s",GLOBALS::instance ()->ior_file)); ACE_OS::fprintf (ior_f, "%s\n", this->cubits_[j]); - ACE_OS::printf ("this->cubits_[%d] ior = %s\n", - j, - this->cubits_[j]); + ACE_DEBUG ((LM_DEBUG, + "this->cubits_[%d] ior = %s\n", + j, + this->cubits_[j])); } } if (ior_f != 0) - { - // ACE_DEBUG ((LM_DEBUG,"(%P|%t) Closing ior file\n")); - ACE_OS::fclose (ior_f); - } + ACE_OS::fclose (ior_f); } int @@ -203,9 +204,11 @@ Server::activate_high_servant (ACE_Thread_Manager *serv_thr_mgr) "-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", @@ -213,11 +216,13 @@ Server::activate_high_servant (ACE_Thread_Manager *serv_thr_mgr) serv_thr_mgr, 0), //task id 0. -1); + // Make the high priority task an active object. - if (this->high_priority_task_->activate (THR_BOUND | ACE_SCHED_FIFO, - 1, - 0, - this->high_priority_) == -1) + if (this->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")); @@ -225,15 +230,14 @@ Server::activate_high_servant (ACE_Thread_Manager *serv_thr_mgr) ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ready_mon, GLOBALS::instance ()->ready_mtx_, - -1) - ); + -1)); - // wait on the condition variable for the high priority client to + // Wait on the condition variable for the high priority client to // finish parsing the arguments. while (!GLOBALS::instance ()->ready_) GLOBALS::instance ()->ready_cnd_.wait (); - // default return success. + // Default return success. return 0; } @@ -247,6 +251,7 @@ Server::activate_low_servants (ACE_Thread_Manager *serv_thr_mgr) 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_, @@ -256,7 +261,10 @@ Server::activate_low_servants (ACE_Thread_Manager *serv_thr_mgr) ACE_NEW_RETURN (this->low_priority_tasks_, Cubit_Task *[GLOBALS::instance ()->num_of_objs], -1); - for (i = this->num_low_priority_; i > 0; i--) + + for (i = this->num_low_priority_; + i > 0; + i--) { ACE_OS::sprintf (orbport, "-ORBport %d", @@ -274,6 +282,7 @@ Server::activate_low_servants (ACE_Thread_Manager *serv_thr_mgr) ACE_ARGV (this->argv_, low_second_argv), -1); + ACE_NEW_RETURN (this->low_priority_tasks_ [i - 1], Cubit_Task (this->low_argv_->buf (), "internet", @@ -281,6 +290,7 @@ Server::activate_low_servants (ACE_Thread_Manager *serv_thr_mgr) serv_thr_mgr, i), -1); + // Make the low priority task an active object. if (this->low_priority_tasks_ [i - 1]->activate (THR_BOUND | ACE_SCHED_FIFO, 1, @@ -300,11 +310,11 @@ Server::activate_low_servants (ACE_Thread_Manager *serv_thr_mgr) || GLOBALS::instance ()->thread_per_rate == 1) { this->counter_ = (this->counter_ + 1) % this->grain_; + if (this->counter_ == 0 - && //Just so when we distribute the priorities among the //threads, we make sure we don't go overboard. - this->num_priorities_ * this->grain_ > this->num_low_priority_ - (i - 1)) + && 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_, @@ -333,7 +343,7 @@ Server::start_servants (ACE_Thread_Manager *serv_thr_mgr) "Creating servant 0 with high priority %d\n", this->high_priority_)); - // activate the high priority servant task + // Activate the high priority servant task if (this->activate_high_servant (serv_thr_mgr) < 0) ACE_ERROR_RETURN ((LM_ERROR, "Failure in activating high priority servant\n"), @@ -342,23 +352,22 @@ Server::start_servants (ACE_Thread_Manager *serv_thr_mgr) this->num_low_priority_ = GLOBALS::instance ()->num_of_objs - 1; - // initialize the priority of the low priority servants. + // Initialize the priority of the low priority servants. this->init_low_priority (); - // activate the low priority servants. + // Activate the low priority servants. if (this->activate_low_servants (serv_thr_mgr) < 0) ACE_ERROR_RETURN ((LM_ERROR, "Failure in activating low priority servant\n"), -1); - // wait in the barrier. + // Wait in the barrier. GLOBALS::instance ()->barrier_->wait (); - this->write_iors (); return 0; } -// main routine. +// The main() function. #if defined (VXWORKS) // Rename main to server to make it easier to run both client and diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/server.h b/TAO/tests/Cubit/TAO/MT_Cubit/server.h index d270381632e..d24a89df6eb 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/server.h +++ b/TAO/tests/Cubit/TAO/MT_Cubit/server.h @@ -1,8 +1,6 @@ /* -*- C++ -*- */ // $Id$ -#if !defined (SERVER_H) -#define SERVER_H // ============================================================================ // // = LIBRARY @@ -16,13 +14,17 @@ // // ============================================================================ +#if !defined (SERVER_H) +#define SERVER_H + // ACE includes. #if defined (TAO_PLATFORM_SVC_CONF_FILE_NOTSUP) -#define TAO_DEFAULT_SERVER_STRATEGY_FACTORY_ARGS { "-ORBconcurrency", "thread-per-connection", \ +#define TAO_DEFAULT_SERVER_STRATEGY_FACTORY_ARGS \ +{ "-ORBconcurrency", "thread-per-connection", \ "-ORBdemuxstrategy", "dynamic", \ "-ORBtablesize", "128" } -#endif +#endif /* TAO_PLATFORM_SVC_CONF_FILE_NOTSUP */ #include "ace/OS.h" #include "ace/Get_Opt.h" @@ -48,16 +50,7 @@ extern "C" STATUS vmeDrv (void); extern "C" STATUS vmeDevCreate (char *); #endif /* VME_DRIVER */ -#if !defined (ACE_HAS_THREADS) -class NOOP_ACE_Barrier -{ -public: - NOOP_ACE_Barrier (int ) {} - void wait (void) {} -}; -#define ACE_Barrier NOOP_ACE_Barrier -#endif /* ACE_HAS_THREADS */ - +// Make the globals a Singleton. typedef ACE_Singleton<Globals,ACE_Null_Mutex> GLOBALS; // @@ Naga, can you please split this class into a separate file @@ -79,6 +72,7 @@ public: // Active Object entry point. CORBA::String get_servant_ior (u_int index); + // @@ Naga, can you please comment this? protected: Cubit_Task (void); @@ -89,7 +83,7 @@ private: // Initialize the ORB, and POA. int create_servants (void); - // Create the servants + // Create the servants. CORBA::String key_; // All cubit objects will have this as prefix to its key. @@ -107,97 +101,100 @@ private: // Pointer to the ORB Cubit_i **servants_; - // Array to hold the servants + // Array to hold the servants. CORBA::String *servants_iors_; - // ior strings of the servants + // IOR strings of the servants. //CosNaming::NamingContext_var naming_context_; - // Object reference to the naming service + // Object reference to the naming service. u_int task_id_; - // id used for naming service object name. + // ID used for naming service object name. CosNaming::NamingContext_var mt_cubit_context_; - // context where all MT Cubit objects will be created. + // Context where all MT Cubit objects will be created. TAO_ORB_Manager orb_manager_; - // The TAO ORB Manager + // The TAO ORB Manager. TAO_Naming_Client my_name_client_; // An instance of the name client used for resolving the factory // objects. }; -class Server - :public virtual MT_Priority +// @@ Naga, why do we inherit this "public virtual?" Isn't "virtual" +// good enough? +class Server : public virtual MT_Priority { // = TITLE // A multithreaded cubit server class. + // // = DESCRIPTION // This class encapsulates the functionality of a multi-threaded - // cubit server. To use this ,call initialize and then + // cubit server. To use this, call initialize and then // start_servants method. public: Server (void); - // default constructor + // Default constructor. int initialize (int argc, char **argv); - // initialize the server state. + // Initialize the server state. int start_servants (ACE_Thread_Manager *serv_thr_mgr); - // start the high and low priority servants. + // Start the high and low priority servants. private: void prelim_args_process (void); - // preliminary argument processing code. + // Preliminary argument processing code. void init_low_priority (void); // sets the priority to be used for the low priority servants. void write_iors (void); - // writes the iors of the servants to a file + // Writes the iors of the servants to a file int activate_high_servant (ACE_Thread_Manager *serv_thr_mgr); - // activates the high priority servant. + // Activates the high priority servant. int activate_low_servants (ACE_Thread_Manager *serv_thr_mgr); - // activates the low priority servants. + // Activates the low priority servants. int argc_; - // number of arguments for the servant. + // Number of arguments for the servant. char **argv_; - // arguments for the ORB. + // Arguments for the ORB. CORBA::String *cubits_; - // array to hold pointers to the Cubit objects. + // Array to hold pointers to the Cubit objects. Cubit_Task *high_priority_task_; - // pointer to the high priority task + // Pointer to the high priority task Cubit_Task **low_priority_tasks_; - // array to hold pointers to the low priority tasks. + // Array to hold pointers to the low priority tasks. ACE_Sched_Priority high_priority_; - // priority used for the high priority servant. + // Priority used for the high priority servant. ACE_Sched_Priority low_priority_; - // priority used by the low priority servants. + // Priority used by the low priority servants. u_int num_low_priority_; - // number of low priority servants + // Number of low priority servants u_int num_priorities_; - // number of priorities used. + // Number of priorities used. u_int grain_; - // Granularity of the assignment of the priorities. Some OSs - // have fewer levels of priorities than we have threads in our - // test, so with this mechanism we assign priorities to groups - // of threads when there are more threads than priorities. + // Granularity of the assignment of the priorities. Some OSs have + // fewer levels of priorities than we have threads in our test, so + // with this mechanism we assign priorities to groups of threads + // when there are more threads than priorities. u_int counter_; + // @@ Naga, can you please comment this? ACE_ARGV *high_argv_; // argv passed to the high priority servant. @@ -206,7 +203,9 @@ private: // argv passed to the low priority servants. MT_Priority priority_; - // priority helper object. + // Priority helper object. + // @@ Naga, why do we both inherit from MT_Priority and also define + // an instance of it? }; #endif /* SERVER_H */ |