diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ChangeLogs/ChangeLog-03a | 5 | ||||
-rw-r--r-- | TAO/ChangeLog | 26 | ||||
-rw-r--r-- | TAO/examples/RTCORBA/Activity/Activity.cpp | 66 | ||||
-rw-r--r-- | TAO/examples/RTCORBA/Activity/Activity.h | 8 | ||||
-rw-r--r-- | TAO/examples/RTCORBA/Activity/Periodic_Task.h | 3 | ||||
-rwxr-xr-x | TAO/examples/RTCORBA/Activity/README | 11 | ||||
-rw-r--r-- | TAO/examples/RTCORBA/Activity/Thread_Task.cpp | 16 | ||||
-rw-r--r-- | TAO/examples/RTCORBA/Activity/Thread_Task.h | 2 | ||||
-rw-r--r-- | TAO/examples/RTCORBA/Activity/client.conf | 5 | ||||
-rwxr-xr-x | TAO/examples/RTCORBA/Activity/run_test.pl | 67 | ||||
-rw-r--r-- | TAO/examples/RTCORBA/Activity/server.conf | 6 | ||||
-rw-r--r-- | bin/auto_run_tests.lst | 1 |
13 files changed, 205 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog index 87720dc586f..6f75c55f3ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Feb 13 12:43:27 2003 Pradeep Gore <pradeep@oomworks.com> + + * bin/auto_run_tests.lst: + Added TAO/examples/RTCORBA/Activity/run_test.pl to this list. + Thu Feb 13 07:36:40 2003 Balachandran Natarajan <bala@isis-server.isis.vanderbilt.edu> * THANKS: Added Dmitri Belogaj to the hall of fame. diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a index 87720dc586f..6f75c55f3ba 100644 --- a/ChangeLogs/ChangeLog-03a +++ b/ChangeLogs/ChangeLog-03a @@ -1,3 +1,8 @@ +Thu Feb 13 12:43:27 2003 Pradeep Gore <pradeep@oomworks.com> + + * bin/auto_run_tests.lst: + Added TAO/examples/RTCORBA/Activity/run_test.pl to this list. + Thu Feb 13 07:36:40 2003 Balachandran Natarajan <bala@isis-server.isis.vanderbilt.edu> * THANKS: Added Dmitri Belogaj to the hall of fame. diff --git a/TAO/ChangeLog b/TAO/ChangeLog index b745d551132..2d4b29e1fdb 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,29 @@ +Thu Feb 13 12:43:27 2003 Pradeep Gore <pradeep@oomworks.com> + + * examples/RTCORBA/Activity/Periodic_Task.h: + * examples/RTCORBA/Activity/Thread_Task.cpp: + * examples/RTCORBA/Activity/Thread_Task.h: + Added missing code to convert CORBA priority to native priority + when activating the thread task. + + Made the following changes to get the example running in the + autobuilds: + * examples/RTCORBA/Activity/run_test.pl: + This runs a simple test of the activity example. This test is + meant to be run in non-root mode. + * examples/RTCORBA/Activity/Activity.cpp: + * examples/RTCORBA/Activity/Activity.h: + - Added code to obtain the Priority Mapping Manager. + - Added a "-Started_Flag <file_name> " option. When an activity instance + completes its setup, it generates a file to signal the perl + script that it has finished initialization. + * examples/RTCORBA/Activity/README: + Added a new section on the new command-line option. + * examples/RTCORBA/Activity/server.conf: + * examples/RTCORBA/Activity/client.conf: + These conf files are read by run_test.pl to make a sanity check + on the activity program. + Thu Feb 13 10:30:56 2003 Jeff Parsons <j.parsons@vanderbilt.edu> * TAO_IDL/ast/ast_module.cpp: diff --git a/TAO/examples/RTCORBA/Activity/Activity.cpp b/TAO/examples/RTCORBA/Activity/Activity.cpp index 1d9a3966392..4a5f500f5b2 100644 --- a/TAO/examples/RTCORBA/Activity/Activity.cpp +++ b/TAO/examples/RTCORBA/Activity/Activity.cpp @@ -5,6 +5,9 @@ #include "ace/Synch.h" #include "ace/Timer_Heap.h" #include "ace/Service_Config.h" +#include "ace/Arg_Shifter.h" +#include "ace/Get_Opt.h" +#include "ace/Argv_Type_Converter.h" #include "tao/ORB_Core.h" #include "Thread_Task.h" @@ -69,11 +72,13 @@ int Activity::init (int& argc, char *argv [] ACE_ENV_ARG_DECL) { - this->orb_ = - CORBA::ORB_init (argc, - argv, - "" - ACE_ENV_ARG_PARAMETER); + // Copy command line parameter. + ACE_Argv_Type_Converter command_line(argc, argv); + + this->orb_ = CORBA::ORB_init (command_line.get_argc(), + command_line.get_ASCII_argv(), + "" + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); this->init_sched (); @@ -115,6 +120,16 @@ Activity::init (int& argc, char *argv [] poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (-1); + object = this->orb_->resolve_initial_references ("PriorityMappingManager" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + RTCORBA::PriorityMappingManager_var mapping_manager = + RTCORBA::PriorityMappingManager::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + this->priority_mapping_ = mapping_manager->mapping (); + return 0; } @@ -279,15 +294,15 @@ Activity::activate_schedule (ACE_ENV_SINGLE_ARG_DECL) } /* if (TAO_debug_level > 0) */ task->job (job.in ()); - task->activate_task (barrier_); + task->activate_task (this->barrier_, this->priority_mapping_); active_task_count_++; ACE_DEBUG ((LM_DEBUG, "Job %s scheduled\n", task->job ())); } - ACE_DEBUG ((LM_DEBUG, "Waiting for tasks to synch...")); + ACE_DEBUG ((LM_DEBUG, "(%P,%t) Waiting for tasks to synch...\n")); barrier_->wait (); - ACE_DEBUG ((LM_DEBUG, "Tasks have synched...")); + ACE_DEBUG ((LM_DEBUG, "(%P,%t) Tasks have synched...\n")); } void @@ -444,9 +459,11 @@ Activity::run (int argc, char *argv[] ACE_ENV_ARG_DECL) this->activate_job_list (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; - this->activate_schedule (ACE_ENV_SINGLE_ARG_PARAMETER); + this->activate_schedule (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; + this->create_started_flag_file (argc, argv ACE_ENV_ARG_PARAMETER); + orb_->run (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; @@ -455,6 +472,37 @@ Activity::run (int argc, char *argv[] ACE_ENV_ARG_DECL) ACE_Thread_Manager::instance ()->wait (); } +void +Activity::create_started_flag_file (int argc, char *argv[] ACE_ENV_ARG_DECL) +{ + ACE_Arg_Shifter arg_shifter (argc, argv); + + const ACE_TCHAR* current_arg = 0; + + while (arg_shifter.is_anything_left ()) + { + if ((current_arg = arg_shifter.get_the_parameter (ACE_LIB_TEXT("-Started_Flag")))) + { + FILE *file = ACE_OS::fopen (current_arg, ACE_LIB_TEXT("w")); + + if (file == 0) + ACE_ERROR ((LM_ERROR, + "Unable to open %s for writing: %p\n", + current_arg)); + + ACE_OS::fprintf (file, "ignore"); + + ACE_OS::fclose (file); + + arg_shifter.consume_arg (); + } + else + { + arg_shifter.ignore_arg (); + } + } +} + int main (int argc, char *argv[]) { diff --git a/TAO/examples/RTCORBA/Activity/Activity.h b/TAO/examples/RTCORBA/Activity/Activity.h index f26bf91a408..ee55b454744 100644 --- a/TAO/examples/RTCORBA/Activity/Activity.h +++ b/TAO/examples/RTCORBA/Activity/Activity.h @@ -20,6 +20,7 @@ #include "ace/Sched_Params.h" #include "orbsvcs/CosNamingC.h" #include "tao/RTPortableServer/RTPortableServer.h" +#include "tao/RTCORBA/Priority_Mapping_Manager.h" #include "activity_export.h" class ACE_Barrier; @@ -87,6 +88,10 @@ public: /// Check if we should process exit void check_ifexit (void); + /// Create a file whose name is specified in the -Started_Flag <file_name> argument at startup. + /// This file flags that the Activity has finished its bootstrapping step. + void create_started_flag_file (int argc, char *argv[] ACE_ENV_ARG_DECL); + /// = Data members /// The Builder object. @@ -118,6 +123,9 @@ public: /// A naming context. CosNaming::NamingContextExt_var naming_; + /// The Priority Mapping helper. + RTCORBA::PriorityMapping *priority_mapping_; + /// Count the number of periodic tasks active. int active_task_count_; diff --git a/TAO/examples/RTCORBA/Activity/Periodic_Task.h b/TAO/examples/RTCORBA/Activity/Periodic_Task.h index 0c82ad4b87c..ee0796aef57 100644 --- a/TAO/examples/RTCORBA/Activity/Periodic_Task.h +++ b/TAO/examples/RTCORBA/Activity/Periodic_Task.h @@ -14,6 +14,7 @@ #define PERIODIC_TASK_H #include "tao/RTCORBA/RTCORBA.h" +#include "tao/RTCORBA/Priority_Mapping_Manager.h" #include "ace/Task.h" #include "JobC.h" #include "activity_export.h" @@ -39,7 +40,7 @@ class activity_Export Periodic_Task : public ACE_Task <ACE_SYNCH> int init_task (ACE_Arg_Shifter& arg_shifter); /// Activate this task, synch on the given barrier. - virtual int activate_task (ACE_Barrier* barrier) = 0; + virtual int activate_task (ACE_Barrier* barrier, RTCORBA::PriorityMapping *priority_mapping) = 0; /// Dump the stats collected. void dump_stats (ACE_TCHAR* msg); diff --git a/TAO/examples/RTCORBA/Activity/README b/TAO/examples/RTCORBA/Activity/README index dcf7f24af22..32264d094e1 100755 --- a/TAO/examples/RTCORBA/Activity/README +++ b/TAO/examples/RTCORBA/Activity/README @@ -1,4 +1,4 @@ - +//$Id$ =================== RT CORBA capabilities demo =================== Table of contents @@ -109,7 +109,14 @@ JobName = job_10 -Iter = 20 iterations -Load = 1000 -3. Running the example +4. Command-Line Options +---------------------- +-Started_Flag <file_name> : When a particular activity instance has +finished bootstrapping, it will create a file specified by <file_name> +to signal that it has started. This allows scripts to synchronize when +other instances of activity can be started. + +4. Running the example ---------------------- a). The activated Jobs are registered with a Naming service, so we need an NS running diff --git a/TAO/examples/RTCORBA/Activity/Thread_Task.cpp b/TAO/examples/RTCORBA/Activity/Thread_Task.cpp index 49beaae62f5..ec5c23f3c4f 100644 --- a/TAO/examples/RTCORBA/Activity/Thread_Task.cpp +++ b/TAO/examples/RTCORBA/Activity/Thread_Task.cpp @@ -12,10 +12,19 @@ Thread_Task::Thread_Task (void) } int -Thread_Task::activate_task (ACE_Barrier* barrier) +Thread_Task::activate_task (ACE_Barrier* barrier, RTCORBA::PriorityMapping *priority_mapping) { barrier_ = barrier; + // Convert the priority specified to this class to its native number. + RTCORBA::NativePriority native_priority; + + if (priority_mapping->to_native (this->task_priority_, native_priority) == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot convert CORBA priority %d to native priority\n", + this->task_priority_), + -1); + long flags = THR_NEW_LWP | THR_JOINABLE; flags |= @@ -26,7 +35,7 @@ Thread_Task::activate_task (ACE_Barrier* barrier) if (this->ACE_Task <ACE_SYNCH>::activate (flags, 1, 0, - this->task_priority_) == -1) + native_priority) == -1) { if (ACE_OS::last_error () == EPERM) ACE_ERROR_RETURN ((LM_ERROR, @@ -36,7 +45,7 @@ Thread_Task::activate_task (ACE_Barrier* barrier) ACE_DEBUG ((LM_ERROR, ACE_TEXT ("(%t) task activation at priority %d failed, ") ACE_TEXT ("exiting!\n%a"), - this->task_priority_, + native_priority, -1)); } return 0; @@ -49,6 +58,7 @@ Thread_Task::svc (void) if (TAO_debug_level > 0) { ACE_DECLARE_NEW_CORBA_ENV; + // Get the priority of the current thread. RTCORBA::Priority prio = ACTIVITY::instance()->current ()->the_priority (ACE_ENV_SINGLE_ARG_PARAMETER); diff --git a/TAO/examples/RTCORBA/Activity/Thread_Task.h b/TAO/examples/RTCORBA/Activity/Thread_Task.h index e1d470d7753..ae8f3a3ef2a 100644 --- a/TAO/examples/RTCORBA/Activity/Thread_Task.h +++ b/TAO/examples/RTCORBA/Activity/Thread_Task.h @@ -34,7 +34,7 @@ class activity_Export Thread_Task : public Periodic_Task Thread_Task (void); /// Activate thread(s). - virtual int activate_task (ACE_Barrier* barrier); + virtual int activate_task (ACE_Barrier* barrier, RTCORBA::PriorityMapping *priority_mapping); protected: diff --git a/TAO/examples/RTCORBA/Activity/client.conf b/TAO/examples/RTCORBA/Activity/client.conf new file mode 100644 index 00000000000..196de98c87d --- /dev/null +++ b/TAO/examples/RTCORBA/Activity/client.conf @@ -0,0 +1,5 @@ +## Sanity check Client conf file to be run for SCHED_OTHER policy + +static RT_ORB_Loader "-ORBSchedPolicy SCHED_OTHER -ORBScopePolicy PROCESS -ORBPriorityMapping linear" + +static Builder "-TaskCount 1 -ThreadTask -JobName job_0 -Priority 0 -Period 1 -ExecTime 10000 -Phase 0 -Iter 20 -Load 1000" diff --git a/TAO/examples/RTCORBA/Activity/run_test.pl b/TAO/examples/RTCORBA/Activity/run_test.pl new file mode 100755 index 00000000000..6ae5b48a3b6 --- /dev/null +++ b/TAO/examples/RTCORBA/Activity/run_test.pl @@ -0,0 +1,67 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "../../../../bin"; +use PerlACE::Run_Test; + +$status = 0; +$startup_timeout = 60; +$experiment_timeout = 60; +$naming_ior = PerlACE::LocalFile ("naming.ior"); +$server_flag_file = PerlACE::LocalFile ("server.flag"); +$server_conf = PerlACE::LocalFile ("server.conf"); +$client_conf = PerlACE::LocalFile ("client.conf"); + +$Naming = new PerlACE::Process ("../../../orbsvcs/Naming_Service/Naming_Service", + "-o $naming_ior"); + +$Activity_Client = new PerlACE::Process ("activity", + "-ORBInitRef NameService=file://$naming_ior " . + "-ORBSvcConf $client_conf"); + +$Activity_Server = new PerlACE::Process ("activity", + "-ORBInitRef NameService=file://$naming_ior " . + "-ORBSvcConf $server_conf " . + "-Started_Flag $server_flag_file"); + +unlink $naming_ior; +unlink $server_flag_file; + +print STDERR "Running Naming_Service\n"; + +$Naming->Spawn (); + +if (PerlACE::waitforfile_timed ($naming_ior, $startup_timeout) == -1) { + print STDERR "ERROR: waiting for the naming service to start\n"; + $Naming->Kill (); + exit 1; +} + + +print STDERR "Running Activity Server\n"; +$Activity_Server->Spawn (); + +if (PerlACE::waitforfile_timed ($server_flag_file, $startup_timeout) == -1) { + print STDERR "ERROR: waiting for the server to start\n"; + $Activity_Server->Kill (); + $Naming->Kill (); + exit 1; +} + +print STDERR "Running Activity Client\n"; + +$status = $Activity_Client->SpawnWaitKill ($experiment_timeout); + +if ($status != 0) + { + print STDERR "ERROR: Client Activity returned $status\n"; + } + +$Activity_Server->Kill (); +$Naming->Kill (); + +exit $status; diff --git a/TAO/examples/RTCORBA/Activity/server.conf b/TAO/examples/RTCORBA/Activity/server.conf new file mode 100644 index 00000000000..e375a3fb8c1 --- /dev/null +++ b/TAO/examples/RTCORBA/Activity/server.conf @@ -0,0 +1,6 @@ +## Sanity check Server conf file to be run for SCHED_OTHER policy + +static RT_ORB_Loader "-ORBSchedPolicy SCHED_OTHER -ORBScopePolicy PROCESS -ORBPriorityMapping linear" + +static Builder "-POACount 1 -POA poa1 -PriorityModel CLIENT 0 -Lanes 1 -Lane 0 1 0 -JobCount 1 -Job job_0 poa1" + diff --git a/bin/auto_run_tests.lst b/bin/auto_run_tests.lst index a0eab61862f..7f306cf8a09 100644 --- a/bin/auto_run_tests.lst +++ b/bin/auto_run_tests.lst @@ -228,3 +228,4 @@ TAO/orbsvcs/tests/Miop/McastHello/run_test.pl: !MINIMUM !STATIC !SUNCC5_1 TAO/orbsvcs/tests/LoadBalancing/GenericFactory/Application_Controlled/run_test.pl: !MINIMUM !DISABLE_INTERCEPTORS TAO/tests/Two_Objects/run_test.pl: !ST +TAO/examples/RTCORBA/Activity/run_test.pl: !MINIMUM
\ No newline at end of file |