diff options
author | sergio <sergio@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-06-07 00:13:39 +0000 |
---|---|---|
committer | sergio <sergio@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-06-07 00:13:39 +0000 |
commit | 3c46fa3a56d3193ae10d6719821b2c86ee2b271c (patch) | |
tree | 49bdc4cef320b0419cc95fb98921cac4fd962e35 /TAO/tests/Cubit | |
parent | ac8c5ebe02f83c6321e2582ab4a28e069e2280b4 (diff) | |
download | ATCD-3c46fa3a56d3193ae10d6719821b2c86ee2b271c.tar.gz |
*** empty log message ***
Diffstat (limited to 'TAO/tests/Cubit')
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.cpp | 142 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.h | 5 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/client.cpp | 145 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/cubit.idl | 9 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.cpp | 42 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.h | 24 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/server.cpp | 318 | ||||
-rw-r--r-- | TAO/tests/Cubit/TAO/MT_Cubit/server.h | 53 |
8 files changed, 140 insertions, 598 deletions
diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.cpp b/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.cpp index 831fae044a0..c2539d1c655 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.cpp +++ b/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.cpp @@ -13,7 +13,6 @@ Task_State::Task_State (int argc, char **argv) argv_ (argv), thread_per_rate_ (0), global_jitter_array_ (0), - factory_ior_ (0), shutdown_ (0), oneway_ (0), use_name_service_ (1), @@ -24,7 +23,7 @@ Task_State::Task_State (int argc, char **argv) use_utilization_test_ (0), high_priority_loop_count_ (0) { - ACE_Get_Opt opts (argc, argv, "usn:t:d:rk:xof:g:1c"); + ACE_Get_Opt opts (argc, argv, "usn:t:d:rxof:g:1c"); int c; int datatype; @@ -47,9 +46,6 @@ Task_State::Task_State (int argc, char **argv) case 's': use_name_service_ = 0; break; - case 'k': - factory_ior_ = ACE_OS::strdup (opts.optarg); - break; case 'f': ior_file_ = ACE_OS::strdup (opts.optarg); break; @@ -97,12 +93,11 @@ Task_State::Task_State (int argc, char **argv) "[-d datatype Octet=0, Short=1, Long=2, Struct=3]" " [-n num_calls]" " [-t num_threads]" - " [-k factory_ior_key]" " [-f ior_file]" " [-x] // makes a call to servant to shutdown" " [-o] // makes client use oneway calls instead" " [-s] // makes client *NOT* use the name service" - " [-g granularity_of_request_timing]" + " [-g granularity_of_timing]" "\n", argv [0])); } @@ -132,19 +127,26 @@ Task_State::Task_State (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 (use_utilization_test_ == 1) - // If we are to use the utilization test, include it in the - // barrier count. See description of this variable in header - // file. + if (thread_per_rate_ == 0) { - ACE_NEW (barrier_, - ACE_Barrier (thread_count_ + 2)); + if (use_utilization_test_ == 1) + // If we are to use the utilization test, include it in the + // barrier count. See description of this variable in header + // file. + { + ACE_NEW (barrier_, + ACE_Barrier (thread_count_ + 2)); + } + else + { + ACE_NEW (barrier_, + ACE_Barrier (thread_count_ + 1)); + } } else { ACE_NEW (barrier_, - ACE_Barrier (thread_count_ + 1)); + ACE_Barrier (thread_count_)); } ACE_NEW (semaphore_, @@ -203,10 +205,10 @@ Client::get_low_priority_latency (void) return l / (double) (ts_->thread_count_ - 1); } -u_int +double Client::get_latency (u_int thread_id) { - return ACE_static_cast (u_int, ts_->latency_ [thread_id]); + return ACE_static_cast (double, ts_->latency_ [thread_id]); } double @@ -447,75 +449,24 @@ Client::svc (void) } if (naming_success == CORBA::B_FALSE) - { - if (ts_->factory_ior_ != 0) - { - ACE_DEBUG ((LM_DEBUG, - " (%t) ----- Using the factory IOR method to get cubit objects -----\n")); - - objref = - orb->string_to_object (ts_->factory_ior_, TAO_TRY_ENV); - TAO_CHECK_ENV; - - if (CORBA::is_nil (objref.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - "%s: must identify non-null target objref\n", - ts_->argv_ [0]), - 1); - - // 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); - TAO_CHECK_ENV; - - if (CORBA::is_nil (cb_factory.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - "Create cubit factory failed\n"), - 1); - - ACE_DEBUG ((LM_DEBUG, - "(%t) >>> Factory binding succeeded\n")); - - - char * tmp_ior = cb_factory->create_cubit (this->id_, - TAO_TRY_ENV); - TAO_CHECK_ENV; + { + char *my_ior = ts_->iors_[this->id_]; - if (tmp_ior == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "create_cubit() returned a null pointer!\n"), - -1); + // if we are running the "1 to n" test make sure all low + // priority clients use only 1 low priority servant. + if (this->id_ > 0 && ts_->one_to_n_test_ == 1) + my_ior = ts_->iors_[1]; - char *my_ior = ACE_OS::strdup (tmp_ior); + if (my_ior == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Must specify valid factory ior key with -k option," + " naming service, or ior filename\n"), + -1); - TAO_CHECK_ENV; - - objref = orb->string_to_object (my_ior, - TAO_TRY_ENV); - TAO_CHECK_ENV; - } - else - { - char *my_ior = ts_->iors_[this->id_]; - - // if we are running the "1 to n" test make sure all low - // priority clients use only 1 low priority servant. - if (this->id_ > 0 && ts_->one_to_n_test_ == 1) - my_ior = ts_->iors_[1]; - - if (my_ior == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "Must specify valid factory ior key with -k option," - " naming service, or ior filename\n"), - -1); - - objref = orb->string_to_object (my_ior, - TAO_TRY_ENV); - TAO_CHECK_ENV; - } - } + objref = orb->string_to_object (my_ior, + TAO_TRY_ENV); + TAO_CHECK_ENV; + } if (CORBA::is_nil (objref.in ())) ACE_ERROR_RETURN ((LM_ERROR, @@ -651,15 +602,12 @@ Client::run_tests (Cubit_ptr cb, (u_long) ((sleep_time - delta) < 0 ? 0 : (sleep_time - delta))); - ACE_OS::sleep (tv); + ACE_OS::sleep (tv); } #if defined (CHORUS) pstartTime = pccTime1Get(); #else /* CHORUS */ -// ACE_NEW_RETURN (timer_, -// ACE_High_Res_Timer, -// -1); timer_.start (); #endif /* !CHORUS */ } @@ -902,16 +850,16 @@ Client::run_tests (Cubit_ptr cb, // 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 && ts_->thread_count_ > 1) - { - if (ts_->semaphore_->tryacquire () != -1) - { - low_priority_client_count --; - // if all clients are done then break out of loop. - if (low_priority_client_count <= 0) - break; - } - } + if (id_ == 0 && ts_->thread_count_ > 1) + { + if (ts_->semaphore_->tryacquire () != -1) + { + low_priority_client_count --; + // if all clients are done then break out of loop. + if (low_priority_client_count <= 0) + break; + } + } } if (id_ == 0) diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.h b/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.h index 35b18af0fe5..187a78bab92 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.h +++ b/TAO/tests/Cubit/TAO/MT_Cubit/Task_Client.h @@ -153,9 +153,6 @@ public: // This array stores the latency seen by each client for each // request, to be used later to compute jitter. - char *factory_ior_; - // Object reference string for the cubit factory. - u_int shutdown_; // Flag that indicates if we are going to call the shutdown methos // for the servant. @@ -222,7 +219,7 @@ public: double get_low_priority_latency (void); double get_high_priority_jitter (void); double get_low_priority_jitter (void); - u_int get_latency (u_int thread_id); + double get_latency (u_int thread_id); // Accessors to get the various measured quantities. private: diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/client.cpp b/TAO/tests/Cubit/TAO/MT_Cubit/client.cpp index 6967b73864f..245fa24566a 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/client.cpp +++ b/TAO/tests/Cubit/TAO/MT_Cubit/client.cpp @@ -21,13 +21,16 @@ double csw = 0.0; #if defined (VXWORKS) u_int ctx = 0; -void +extern "C" +int switchHook ( WIND_TCB *pOldTcb, /* pointer to old task's WIND_TCB */ WIND_TCB *pNewTcb ) /* pointer to new task's WIND_TCB */ { // We create the client threads with names starting with "@". if ( pNewTcb->name[0] == '@') ctx++; + + return 0; } #endif /* VXWORKS */ @@ -124,13 +127,10 @@ do_priority_inversion_test (ACE_Thread_Manager &thread_manager, util_task_duration = delta_t.sec () * ACE_ONE_SECOND_IN_MSECS + (double)delta_t.usec () / ACE_ONE_SECOND_IN_MSECS; #endif /* !CHORUS */ - // The minimum priority thread is the utilization thread. + // The thread priority ACE_Sched_Priority priority; #if defined (VXWORKS) - if (ts.context_switch_test_ == 1) - taskSwitchHookAdd ((FUNCPTR)switchHook); - // set a task_id string startiing with "@", so we are able to // accurately count the number of context switches. strcpy (task_id, "@High"); @@ -138,7 +138,7 @@ do_priority_inversion_test (ACE_Thread_Manager &thread_manager, // Now activate the high priority client. #if defined (VXWORKS) - priority = ACE_THR_PRI_FIFO_DEF; + priority = 101; #elif defined (ACE_WIN32) priority = ACE_Sched_Params::priority_max (ACE_SCHED_FIFO, ACE_SCOPE_THREAD); @@ -168,58 +168,16 @@ do_priority_inversion_test (ACE_Thread_Manager &thread_manager, "%p; priority is %d\n", "activate failed", priority)); - - ACE_Sched_Priority_Iterator priority_iterator (ACE_SCHED_FIFO, - ACE_SCOPE_THREAD); - - u_int number_of_priorities = 0; - while (priority_iterator.more ()) - { - number_of_priorities ++; - priority_iterator.next (); - } - - // 1 priority is exclusive for the high priority client. - number_of_priorities --; - - // if utilization thread is present, reduce in 1 the available priorities. - if (ts.use_utilization_test_ == 1) - { - number_of_priorities --; - } - + u_int number_of_low_priority_client = ts.thread_count_ - 1; - // Drop the priority, so that the priority of clients will increase - // with increasing client number. - for (j = 0; j < number_of_low_priority_client + 1; j++) - priority = ACE_Sched_Params::previous_priority (ACE_SCHED_FIFO, - priority, - ACE_SCOPE_THREAD); - - // if the lowest priority of the "low priority clients" is the minimum, - // and we are running the utilization thread, increment the priority, - // since we don't want the utlization thread and a "low priority thread" - // to have the same priority. - if ( priority == ACE_Sched_Params::priority_min (ACE_SCHED_FIFO, - ACE_SCOPE_THREAD) && - ts.use_utilization_test_ == 1) - priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO, - priority, - ACE_SCOPE_THREAD); - - // 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 grain = number_of_low_priority_client / number_of_priorities; - u_int counter = 0; - - if (grain <= 0) - grain = 1; + // Drop the priority + priority = ACE_Sched_Params::previous_priority (ACE_SCHED_FIFO, + priority, + ACE_SCOPE_THREAD); ACE_DEBUG ((LM_DEBUG, - "Creating %d clients starting at low priority %d\n", + "Creating %d clients at priority %d\n", ts.thread_count_ - 1, priority)); @@ -240,15 +198,14 @@ do_priority_inversion_test (ACE_Thread_Manager &thread_manager, #endif /* VXWORKS */ ACE_DEBUG ((LM_DEBUG, - "Creating client with thread ID %d and priority %d\n", - i, - priority)); + "Creating client with thread ID %d\n", + i)); // The first thread starts at the lowest priority of all the low // priority clients. if (low_priority_client[i - 1]->activate (THR_BOUND | ACE_SCHED_FIFO, 1, - 1, + 0, #if !defined (VXWORKS) priority) == -1) #else @@ -266,16 +223,6 @@ do_priority_inversion_test (ACE_Thread_Manager &thread_manager, "activate failed", priority)); - counter = (counter + 1) % grain; - if ( (counter == 0) && - //Just so when we distribute the priorities among the threads, we make sure we don't go overboard. - ((number_of_priorities * grain) > (number_of_low_priority_client - (i - 1))) ) - { - // Get the next higher priority. - priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO, - priority, - ACE_SCOPE_THREAD); - } } if (ts.use_utilization_test_ == 1) @@ -305,8 +252,7 @@ do_priority_inversion_test (ACE_Thread_Manager &thread_manager, // any further. ts.barrier_->wait (); - -#if defined (ACE_HAS_PRUSAGE_T) || defined (ACE_HAS_GETRUSAGE) +#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; @@ -314,7 +260,7 @@ do_priority_inversion_test (ACE_Thread_Manager &thread_manager, { timer_for_context_switch.start (); timer_for_context_switch.get_rusage (usage); -# if defined (ACE_HAS_PRUSAGE_T) +# if defined (ACE_HAS_PRUSAGE_T) context_switch = usage.pr_vctx + usage.pr_ictx; # else /* ACE_HAS_PRUSAGE_T */ context_switch = usage.ru_nvcsw + usage.ru_nivcsw; @@ -322,6 +268,14 @@ do_priority_inversion_test (ACE_Thread_Manager &thread_manager, } #endif /* ACE_HAS_PRUSAGE_T || ACE_HAS_GETRUSAGE */ +#if defined (VXWORKS) + if (ts.context_switch_test_ == 1) + { + fprintf(stderr, "Adding the context switch hook!\n"); + taskSwitchHookAdd ((FUNCPTR)&switchHook); + } +#endif + // Wait for all the client threads to exit (except the utilization thread). thread_manager.wait (); @@ -352,7 +306,7 @@ do_priority_inversion_test (ACE_Thread_Manager &thread_manager, "Voluntary context switches=%d, Involuntary context switches=%d\n", usage.pr_vctx, usage.pr_ictx)); -#elif defined (ACE_HAS_GETRUSAGE) +#elif defined (ACE_HAS_GETRUSAGE) && !defined (ACE_WIN32) timer_for_context_switch.stop (); timer_for_context_switch.get_rusage (usage); // Add up the voluntary context switches & involuntary context switches @@ -362,10 +316,10 @@ do_priority_inversion_test (ACE_Thread_Manager &thread_manager, usage.ru_nvcsw, usage.ru_nivcsw)); #elif defined (VXWORKS) /* ACE_HAS_GETRUSAGE */ - taskSwitchHookDelete ((FUNCPTR)switchHook); - ACE_DEBUG ((LM_DEBUG, - "Context switches=%d\n", - ctx)); + taskSwitchHookDelete ((FUNCPTR)&switchHook); + ACE_DEBUG ((LM_DEBUG, + "Context switches=%d\n", + ctx)); #endif } @@ -535,15 +489,24 @@ do_thread_per_rate_test (ACE_Thread_Manager &thread_manager, Client CB_5Hz_client (thread_manager, &ts, CB_5HZ_CONSUMER); Client CB_1Hz_client (thread_manager, &ts, CB_1HZ_CONSUMER); - ACE_Sched_Priority priority = ACE_THR_PRI_FIFO_DEF; + ACE_Sched_Priority priority; - ACE_DEBUG ((LM_DEBUG, - "Creating 40 Hz client with priority %d\n", - priority)); - if (CB_40Hz_client.activate (THR_BOUND | ACE_SCHED_FIFO, 1, 0, priority) == -1) - ACE_ERROR ((LM_ERROR, - "%p\n", - "activate failed")); +#if defined (VXWORKS) + priority = 101; +#elif defined (ACE_WIN32) + priority = ACE_Sched_Params::priority_max (ACE_SCHED_FIFO, + ACE_SCOPE_THREAD); +#else /* ! VXWORKS */ + priority = ACE_THR_PRI_FIFO_DEF + 25; +#endif /* ! ACE_WIN32 */ + + ACE_DEBUG ((LM_DEBUG, + "Creating 40 Hz client with priority %d\n", + priority)); + if (CB_40Hz_client.activate (THR_BOUND | ACE_SCHED_FIFO, 1, 1, priority) == -1) + ACE_ERROR ((LM_ERROR, + "%p\n", + "activate failed")); priority = ACE_Sched_Params::previous_priority (ACE_SCHED_FIFO, priority, @@ -551,7 +514,7 @@ do_thread_per_rate_test (ACE_Thread_Manager &thread_manager, ACE_DEBUG ((LM_DEBUG, "Creating 20 Hz client with priority %d\n", priority)); - if (CB_20Hz_client.activate (THR_BOUND | ACE_SCHED_FIFO, 1, 0, priority) == -1) + if (CB_20Hz_client.activate (THR_BOUND | ACE_SCHED_FIFO, 1, 1, priority) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "activate failed")); @@ -562,7 +525,7 @@ do_thread_per_rate_test (ACE_Thread_Manager &thread_manager, ACE_DEBUG ((LM_DEBUG, "Creating 10 Hz client with priority %d\n", priority)); - if (CB_10Hz_client.activate (THR_BOUND | ACE_SCHED_FIFO, 1, 0, priority) == -1) + if (CB_10Hz_client.activate (THR_BOUND | ACE_SCHED_FIFO, 1, 1, priority) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "activate failed")); @@ -573,7 +536,7 @@ do_thread_per_rate_test (ACE_Thread_Manager &thread_manager, ACE_DEBUG ((LM_DEBUG, "Creating 5 Hz client with priority %d\n", priority)); - if (CB_5Hz_client.activate (THR_BOUND | ACE_SCHED_FIFO, 1, 0, priority) == -1) + if (CB_5Hz_client.activate (THR_BOUND | ACE_SCHED_FIFO, 1, 1, priority) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "activate failed")); @@ -584,13 +547,13 @@ do_thread_per_rate_test (ACE_Thread_Manager &thread_manager, ACE_DEBUG ((LM_DEBUG, "Creating 1 Hz client with priority %d\n", priority)); - if (CB_1Hz_client.activate (THR_BOUND | ACE_SCHED_FIFO, 1, 0, priority) == -1) + if (CB_1Hz_client.activate (THR_BOUND | ACE_SCHED_FIFO, 1, 1, priority) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "activate failed")); // Wait for all the threads to exit. - ACE_Thread_Manager::instance ()->wait (); + thread_manager.wait (); ACE_DEBUG ((LM_DEBUG, "Test done.\n" @@ -599,7 +562,7 @@ do_thread_per_rate_test (ACE_Thread_Manager &thread_manager, "10Hz client latency : %u usec\n" "5Hz client latency : %u usec\n" "1Hz client latency : %u usec\n", - CB_40Hz_client.get_latency (0), + CB_40Hz_client.get_latency (0), CB_20Hz_client.get_latency (1), CB_10Hz_client.get_latency (2), CB_5Hz_client.get_latency (3), @@ -641,7 +604,7 @@ main (int argc, char *argv[]) #if defined (__Lynx__) 30, #else /* ! __Lynx__ */ - ACE_Sched_Params::priority_min (ACE_SCHED_FIFO), + ACE_THR_PRI_FIFO_DEF,// ACE_Sched_Params::priority_min (ACE_SCHED_FIFO), #endif /* ! __Lynx__ */ ACE_SCOPE_PROCESS)) != 0) { diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/cubit.idl b/TAO/tests/Cubit/TAO/MT_Cubit/cubit.idl index 5bdf1645870..74041bad851 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/cubit.idl +++ b/TAO/tests/Cubit/TAO/MT_Cubit/cubit.idl @@ -36,12 +36,3 @@ interface Cubit // shut down the application }; -interface Cubit_Factory -{ - // = TITLE - // Creates Cubit objects. - - string create_cubit (in unsigned short index); - // Factory method that creates an string containing the IOR of the - // designated Cubit object. -}; diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.cpp b/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.cpp index 51ceb3704f3..bf7b61790c9 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.cpp +++ b/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.cpp @@ -55,45 +55,3 @@ void Cubit_i::shutdown (CORBA::Environment &) { TAO_ORB_Core_instance ()->orb ()->shutdown (); } - -// Constructor - -Cubit_Factory_i::Cubit_Factory_i (CORBA::String *cubits, - u_int num_of_objs) - : num_of_objs_ (num_of_objs) -{ - 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]); -} - -// Destructor - -Cubit_Factory_i::~Cubit_Factory_i (void) -{ -} - -CORBA::String -Cubit_Factory_i::create_cubit (CORBA::UShort orb_index, - CORBA::Environment &env) -{ - // if out of range, return a nil string. - if (orb_index >= num_of_objs_) - { - env.clear (); - env.exception (new CORBA::BAD_PARAM (CORBA::COMPLETED_NO)); - return 0; - } - - ACE_DEBUG ((LM_DEBUG, - "(%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 96bbd22d62d..bad9543cd81 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.h +++ b/TAO/tests/Cubit/TAO/MT_Cubit/cubit_i.h @@ -44,28 +44,4 @@ public: virtual void shutdown (CORBA::Environment &env); }; -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); - // Constructor. - - ~Cubit_Factory_i (void); - // Destructor. - - virtual CORBA::String create_cubit (CORBA::UShort index, - CORBA::Environment &env); - // Make the cubit object whose priority is "priority". - -private: - CORBA::String * my_cubit_; - // Array of cubit iors. - - u_int num_of_objs_; - // Number of cubit objects we have ior's for. -}; - #endif /* _CUBIT_I_HH */ diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/server.cpp b/TAO/tests/Cubit/TAO/MT_Cubit/server.cpp index 9a852a7abea..a784fa9fc6a 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/server.cpp +++ b/TAO/tests/Cubit/TAO/MT_Cubit/server.cpp @@ -22,7 +22,7 @@ static char *ior_file = 0; static int base_port = ACE_DEFAULT_SERVER_PORT; static int num_of_objs = 2; static u_int use_name_service = 1; - + Cubit_Task::Cubit_Task (void) { // No-op. @@ -342,184 +342,6 @@ Cubit_Task::create_servants () return 0; } -Cubit_Factory_Task::Cubit_Factory_Task (void) -{ - // No-op. -} - -Cubit_Factory_Task::Cubit_Factory_Task (const char *args, - const char *orbname, - CORBA::String * cubits, - u_int num_of_objs) - : orbname_ ((char *) orbname), - orbargs_ ((char *) args), - cubits_ (cubits), - cubit_factory_ (0), - num_of_objs_ (num_of_objs) -{ -} - -int -Cubit_Factory_Task::create_factory (void) -{ - TAO_TRY - { - // Create implementation object with user specified key. - ACE_NEW_RETURN (this->cubit_factory_, - Cubit_Factory_i (cubits_, num_of_objs_), - -1); - - PortableServer::ObjectId_var id = - PortableServer::string_to_ObjectId ("Cubit_Factory"); - - this->poa_->activate_object_with_id (id.in (), - this->cubit_factory_, - TAO_TRY_ENV); - TAO_CHECK_ENV; - - // Stringify the objref we'll be implementing, and print it - // to stdout. Someone will take that string and give it to - // some client. Then release the object. - - Cubit_Factory_var cubit_factory = - this->cubit_factory_->_this (TAO_TRY_ENV); - TAO_CHECK_ENV; - - CORBA::String_var str = - this->orb_->object_to_string (cubit_factory.in (), - TAO_TRY_ENV); - TAO_CHECK_ENV; - - ACE_DEBUG ((LM_DEBUG, - ">>> (%P|%t) Cubit Factory Object created with IOR <%s>\n", - str.in ())); - } - TAO_CATCHANY - { - TAO_TRY_ENV.print_exception ("print IOR"); - return -1; - } - TAO_ENDTRY; - return 0; -} - -int -Cubit_Factory_Task::svc (void) -{ - ACE_DEBUG ((LM_DEBUG, - ">>> (%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 (); - - TAO_TRY - { - this->poa_manager_->activate (TAO_TRY_ENV); - TAO_CHECK_ENV; - - // Handle requests for this object until we're killed, or one of - // the methods asks us to exit. - if (this->orb_->run () == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "run"), - -1); - - // Shut down the OA. - this->poa_->destroy (CORBA::B_TRUE, - CORBA::B_TRUE, - TAO_TRY_ENV); - TAO_CHECK_ENV; - } - TAO_CATCHANY - { - TAO_TRY_ENV.print_exception ("poa->destroy()"); - } - TAO_ENDTRY; - - return 0; -} - -int -Cubit_Factory_Task::initialize_orb (void) -{ - TAO_TRY - { - ACE_ARGV args (this->orbargs_); - - int argc = args.argc (); - char **argv = args.argv (); - - // Initialize the ORB. - this->orb_ = CORBA::ORB_init (argc, - argv, - this->orbname_, - TAO_TRY_ENV); - TAO_CHECK_ENV; - - // Initialize the Object Adapter - CORBA::Object_var poa_object = - this->orb_->resolve_initial_references("RootPOA"); - if (CORBA::is_nil (poa_object.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - " (%P|%t) Unable to initialize the POA.\n"), - 1); - - this->root_poa_ = - PortableServer::POA::_narrow (poa_object.in(), - TAO_TRY_ENV); - TAO_CHECK_ENV; - - this->poa_manager_ = - this->root_poa_->the_POAManager (TAO_TRY_ENV); - TAO_CHECK_ENV; - - CORBA::PolicyList policies (2); - policies.length (2); - - // Id Assignment policy - policies[0] = - this->root_poa_->create_id_assignment_policy (PortableServer::USER_ID, - TAO_TRY_ENV); - TAO_CHECK_ENV; - - // Lifespan policy - policies[1] = - this->root_poa_->create_lifespan_policy (PortableServer::PERSISTENT, - TAO_TRY_ENV); - TAO_CHECK_ENV; - - // We use a different POA, otherwise the user would have to - // change the object key each time it invokes the server. - this->poa_ = - this->root_poa_->create_POA ("Persistent_POA", - this->poa_manager_.in (), - policies, - TAO_TRY_ENV); - TAO_CHECK_ENV; - - // Creation of the new POAs over, so destroy the Policy_ptr's. - for (CORBA::ULong i = 0; - i < policies.length () && TAO_TRY_ENV.exception () == 0; - ++i) - { - CORBA::Policy_ptr policy = policies[i]; - policy->destroy (TAO_TRY_ENV); - } - TAO_CHECK_ENV; - } - TAO_CATCHANY - { - TAO_TRY_ENV.print_exception ("orb_init"); - return -1; - } - TAO_ENDTRY; - - return 0; -} - // 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 @@ -647,7 +469,11 @@ start_servants (ACE_Barrier &start_barrier) -1); ACE_OS::sprintf (args1, - "rate20 -ORBport %d -ORBhost %s -ORBobjrefstyle URL ", + "rate20 -ORBport %d " + "-ORBhost %s " + "-ORBobjrefstyle URL " + "-ORBsndsock 32768 " + "-ORBrcvsock 32768 ", base_port, hostname); @@ -662,7 +488,7 @@ start_servants (ACE_Barrier &start_barrier) -1); #if defined (VXWORKS) - ACE_Sched_Priority priority = ACE_THR_PRI_FIFO_DEF; + ACE_Sched_Priority priority = 101; #elif defined (ACE_WIN32) ACE_Sched_Priority priority = ACE_Sched_Params::priority_max (ACE_SCHED_FIFO, ACE_SCOPE_THREAD); @@ -691,40 +517,13 @@ start_servants (ACE_Barrier &start_barrier) Cubit_Task *[num_of_objs], -1); - ACE_Sched_Priority_Iterator priority_iterator (ACE_SCHED_FIFO, - ACE_SCOPE_THREAD); - - u_int number_of_priorities = 0; - while (priority_iterator.more ()) - { - number_of_priorities ++; - priority_iterator.next (); - } - - // 1 priority is exclusive for the high priority client. - number_of_priorities --; - - u_int number_of_low_priority_client = num_of_objs - 1; - - // Drop the priority, so that the priority of clients will increase - // with increasing client number. - for (i = 0; i < (int) (number_of_low_priority_client + 1); i++) - priority = ACE_Sched_Params::previous_priority (ACE_SCHED_FIFO, + // Drop the priority + priority = ACE_Sched_Params::previous_priority (ACE_SCHED_FIFO, priority, ACE_SCOPE_THREAD); - // 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 grain = number_of_low_priority_client / number_of_priorities; - u_int counter = 0; - - if (grain <= 0) - grain = 1; - ACE_DEBUG ((LM_DEBUG, - "Creating %d servants starting at priority %d\n", + "Creating %d servants with priority %d\n", num_of_objs - 1, priority)); @@ -739,7 +538,11 @@ start_servants (ACE_Barrier &start_barrier) -1); ACE_OS::sprintf (args, - "rate10 -ORBport %d -ORBhost %s -ORBobjrefstyle URL ", + "rate10 -ORBport %d " + "-ORBhost %s " + "-ORBobjrefstyle URL " + "-ORBsndsock 32768 " + "-ORBrcvsock 32768 ", base_port + 1 + i, hostname); @@ -758,81 +561,40 @@ start_servants (ACE_Barrier &start_barrier) } ACE_DEBUG ((LM_DEBUG, - "Created servant %d with priority %d\n", - i, - priority)); - - counter = (counter + 1) % grain; - if ( (counter == 0) && - //Just so when we distribute the priorities among the threads, we make sure we don't go overboard. - ((number_of_priorities * grain) > (number_of_low_priority_client - (i - 1))) ) - { - // Get the next higher priority. - priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO, - priority, - ACE_SCOPE_THREAD); - } - } - - char *args; + "Created servant %d\n", + i)); - ACE_NEW_RETURN (args, - char [BUFSIZ], - -1); - - ACE_OS::sprintf (args, - "rate10 -ORBport %d -ORBhost %s -ORBobjrefstyle URL ", - base_port + num_of_objs, - hostname); + } start_barrier.wait (); - cubits[0] = high_priority_task->get_servant_ior (0); - - for (i = 0; i < num_of_objs-1; ++i) - cubits[i + 1] = low_priority_task[i]->get_servant_ior (0); - - FILE *ior_f = 0; - - if (ior_file != 0) - ior_f = ACE_OS::fopen (ior_file, "w+"); - - for (i = 0; i < num_of_objs; ++i) - { - if (ior_f != 0) - { - ACE_OS::fprintf (ior_f, "%s\n", cubits[i]); - } - ACE_OS::printf ("cubits[%d] ior = %s\n", - i, - cubits[i]); - } - if (ior_f != 0) - ACE_OS::fclose (ior_f); + // Write the ior's to a file so the client can read them. + { + cubits[0] = high_priority_task->get_servant_ior (0); -#if 0 - Cubit_Factory_Task * factory_task; + for (i = 0; i < num_of_objs-1; ++i) + cubits[i + 1] = low_priority_task[i]->get_servant_ior (0); - ACE_NEW_RETURN (factory_task, - Cubit_Factory_Task (args, "internet", cubits, num_of_objs), - -1); + FILE *ior_f = 0; - priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO, - priority, - ACE_SCOPE_THREAD); + if (ior_file != 0) + ior_f = ACE_OS::fopen (ior_file, "w+"); - // Make the factory low priority task an active object. - if (factory_task->activate (THR_BOUND | ACE_SCHED_FIFO, - 1, - 0, - priority) == -1) - { - ACE_ERROR ((LM_ERROR, "(%P|%t; %p\n", - "factory_task->activate")); - } -#endif + for (i = 0; i < num_of_objs; ++i) + { + if (ior_f != 0) + { + ACE_OS::fprintf (ior_f, "%s\n", cubits[i]); + } + ACE_OS::printf ("cubits[%d] ior = %s\n", + i, + cubits[i]); + } + if (ior_f != 0) + ACE_OS::fclose (ior_f); + } return 0; } @@ -860,7 +622,7 @@ main (int argc, char *argv[]) #if defined (__Lynx__) 30, #else /* ! __Lynx__ */ - ACE_Sched_Params::priority_min (ACE_SCHED_FIFO), + ACE_THR_PRI_FIFO_DEF, //ACE_Sched_Params::priority_min (ACE_SCHED_FIFO), #endif /* ! __Lynx__ */ ACE_SCOPE_PROCESS)) != 0) { diff --git a/TAO/tests/Cubit/TAO/MT_Cubit/server.h b/TAO/tests/Cubit/TAO/MT_Cubit/server.h index b655b72f744..3176067327e 100644 --- a/TAO/tests/Cubit/TAO/MT_Cubit/server.h +++ b/TAO/tests/Cubit/TAO/MT_Cubit/server.h @@ -114,56 +114,3 @@ private: // context where all MT Cubit objects will be created. }; -class Cubit_Factory_Task : public ACE_Task<ACE_NULL_SYNCH> -{ - // = TITLE - // Encapsulates an ORB for the Cubit Factory application. -public: - Cubit_Factory_Task (const char *args, - const char* orbname, - CORBA::String * cubits, - u_int num_of_objs); - // Constructor. - - virtual int svc (void); - // Active Object entry point. - -protected: - Cubit_Factory_Task (void); - // No-op constructor. - -private: - int initialize_orb (void); - // Initialize the ORB, and POA. - - int create_factory (void); - // activates the factory in the poa. - - char *orbname_; - // Name of the ORB. - - char *orbargs_; - // ORB arguments. - - CORBA::ORB_var orb_; - // Pointer to the ORB - - PortableServer::POA_var root_poa_; - // Pointer to the Root POA - - PortableServer::POA_var poa_; - // Pointer to the child POA used on the application. - - PortableServer::POAManager_var poa_manager_; - // The POA Manager for both the root POA and the child POA. - - CORBA::String *cubits_; - // Array of cubit ior strings - - Cubit_Factory_i *cubit_factory_; - // cubit factory object - - u_int num_of_objs_; - // number of cubit objects we have ior's for. -}; - |