diff options
author | storri <storri@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-01-30 22:38:02 +0000 |
---|---|---|
committer | storri <storri@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-01-30 22:38:02 +0000 |
commit | cdd0661aaa60b46ee748fe9b68ac3d632bb86d00 (patch) | |
tree | 0bd2d2e8edbd79c61a3018c83eaeeb00e203f3d6 | |
parent | 69bec0a544f67d41f45eee85845a93be3f9e678d (diff) | |
download | ATCD-cdd0661aaa60b46ee748fe9b68ac3d632bb86d00.tar.gz |
Adding missing files to EC_DT_RTAS branch.
6 files changed, 29 insertions, 292 deletions
diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway_server.cpp b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway_server.cpp deleted file mode 100644 index 001d7a5163f..00000000000 --- a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_oneway_server.cpp +++ /dev/null @@ -1,263 +0,0 @@ -//$Id$ - -#include "test1_i.h" -#include "ace/Get_Opt.h" -#include "ace/Task.h" -#include "ace/High_Res_Timer.h" -#include "tao/RTScheduling/RTScheduler_Manager.h" -#include "EDF_Scheduler.h" -#include "Task_Stats.h" - -#include <dsui.h> - -ACE_RCSID(MT_Server, server, "server.cpp,v 1.3 2003/10/14 05:57:01 jwillemsen Exp") - -const char *ior_output_file = "test1.ior"; - -int nthreads = 1; -int enable_dynamic_scheduling = 1; -const CORBA::Short max_importance = 100; -int enable_yield = 1; - -int -parse_args (int argc, char *argv[]) -{ - ACE_Get_Opt get_opts (argc, argv, "o:n:s"); - int c; - - while ((c = get_opts ()) != -1) - switch (c) - { - case 'o': - ior_output_file = get_opts.opt_arg (); - break; - - case 'n': - nthreads = ACE_OS::atoi (get_opts.opt_arg ()); - break; - - case 's': - enable_yield = 0; - break; - - case '?': - default: - ACE_ERROR_RETURN ((LM_ERROR, - "usage: %s " - "-o <iorfile>" - "-n (thread num)" - "-s (disable yield)" - "\n", - argv [0]), - -1); - } - // Indicates sucessful parsing of the command line - return 0; -} - -class Worker : public ACE_Task_Base -{ - // = TITLE - // Run a server thread - // - // = DESCRIPTION - // Use the ACE_Task_Base class to run server threads - // -public: - Worker (CORBA::ORB_ptr orb); - // ctor - - virtual int svc (void); - // The thread entry point. - -private: - CORBA::ORB_var orb_; - // The orb -}; - -Task_Stats task_stats; - -int -main (int argc, char *argv[]) -{ - - ds_control ds_cntrl ("DT_Oneway", "dt_oneway_enable.dsui"); - - EDF_Scheduler* scheduler = 0; - RTScheduling::Current_var current; - long flags; - int sched_policy = ACE_SCHED_RR; - int sched_scope = ACE_SCOPE_THREAD; - - if (sched_policy == ACE_SCHED_RR) - flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_RR; - else - flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_FIFO; - - task_stats.init (100000); - - ACE_TRY_NEW_ENV - { - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - CORBA::Object_var poa_object = - orb->resolve_initial_references("RootPOA" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (poa_object.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - " (%P|%t) Unable to initialize the POA.\n"), - 1); - - PortableServer::POA_var root_poa = - PortableServer::POA::_narrow (poa_object.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - PortableServer::POAManager_var poa_manager = - root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (parse_args (argc, argv) != 0) - return 1; - - if (enable_dynamic_scheduling) - { - CORBA::Object_ptr manager_obj = - orb->resolve_initial_references ("RTSchedulerManager" - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - TAO_RTScheduler_Manager_var manager = - TAO_RTScheduler_Manager::_narrow (manager_obj - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type; - if (enable_yield) - { - disp_impl_type = Kokyu::DSRT_CV_BASED; - } - else - { - disp_impl_type = Kokyu::DSRT_OS_BASED; - } - - ACE_NEW_RETURN (scheduler, - EDF_Scheduler (orb.in (), - disp_impl_type, - sched_policy, - sched_scope), -1); - - manager->rtscheduler (scheduler); - - CORBA::Object_var object = - orb->resolve_initial_references ("RTScheduler_Current" - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - current = - RTScheduling::Current::_narrow (object.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - - Simple_Server1_i server_impl (orb.in (), - current.in (), - task_stats, - enable_yield); - - Simple_Server1_var server = - server_impl._this (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - CORBA::String_var ior = - orb->object_to_string (server.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_DEBUG ((LM_DEBUG, "Activated as <%s>\n", ior.in ())); - - // If the ior_output_file exists, output the ior to it - if (ior_output_file != 0) - { - FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); - if (output_file == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "Cannot open output file for writing IOR: %s", - ior_output_file), - 1); - ACE_OS::fprintf (output_file, "%s", ior.in ()); - ACE_OS::fclose (output_file); - } - - poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - -// TAO_debug_level = 1; - Worker worker (orb.in ()); - if (worker.activate (flags, - nthreads, - 0, - ACE_Sched_Params::priority_max(sched_policy, - sched_scope)) != 0) - { - ACE_ERROR ((LM_ERROR, - "Cannot activate threads in RT class.", - "Trying to activate in non-RT class\n")); - - flags = THR_NEW_LWP | THR_JOINABLE | THR_BOUND; - if (worker.activate (flags, nthreads) != 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "Cannot activate server threads\n"), - 1); - } - } - - worker.wait (); - - ACE_DEBUG ((LM_DEBUG, "event loop finished\n")); - - ACE_DEBUG ((LM_DEBUG, "shutting down scheduler\n")); - scheduler->shutdown (); - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Exception caught:"); - return 1; - } - ACE_ENDTRY; - - ACE_DEBUG ((LM_DEBUG, "Exiting main...\n")); - task_stats.dump_samples ("timeline.txt", - "Time\t\tGUID", - ACE_High_Res_Timer::global_scale_factor ()); - return 0; -} - -// **************************************************************** - -Worker::Worker (CORBA::ORB_ptr orb) - : orb_ (CORBA::ORB::_duplicate (orb)) -{ -} - -int -Worker::svc (void) -{ - ACE_DECLARE_NEW_CORBA_ENV; - ACE_Time_Value tv(5000); - - ACE_TRY - { - this->orb_->run (tv ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - } - ACE_ENDTRY; - ACE_DEBUG ((LM_DEBUG, "(%t|%T): Worker thread exiting...\n")); - return 0; -} diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_twoway_client.cpp b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_twoway_client.cpp index 28bbf435d87..8cf2f59104a 100644 --- a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_twoway_client.cpp +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_twoway_client.cpp @@ -75,7 +75,7 @@ parse_args (int argc, char *argv[]) default: ACE_ERROR_RETURN ((LM_ERROR, "usage: %s " - "-x (do shutdown)" + "-x (do shutdown)" "-k <ior> " "-s (disable yield)" "\n", @@ -99,7 +99,7 @@ main (int argc, char *argv[]) if (sched_policy == ACE_SCHED_RR) flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_RR; - else + else flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_FIFO; ACE_hthread_t main_thr_handle; @@ -177,9 +177,9 @@ main (int argc, char *argv[]) { disp_impl_type = Kokyu::DSRT_OS_BASED; } - + ACE_NEW_RETURN (scheduler, - EDF_Scheduler (orb.in (), + EDF_Scheduler (orb.in (), disp_impl_type, sched_policy, sched_scope), -1); @@ -201,13 +201,13 @@ main (int argc, char *argv[]) int importance=0; ORBSVCS_Time::Time_Value_to_TimeT (deadline, - ACE_OS::gettimeofday () + + ACE_OS::gettimeofday () + ACE_Time_Value (50,0) ); - Worker worker1 (orb.in (), - server.in (), - current.in (), - scheduler, + Worker worker1 (orb.in (), + server.in (), + current.in (), + scheduler, deadline, importance, 30); @@ -221,7 +221,7 @@ main (int argc, char *argv[]) worker1.wait (); - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t): wait for worker threads done in main thread\n")); if (do_shutdown) diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_twoway_server.cpp b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_twoway_server.cpp index 1c0f7c52ef9..52967371edf 100644 --- a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_twoway_server.cpp +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/dt_twoway_server.cpp @@ -1,4 +1,4 @@ -//$Id$ +//$Id$ #include "test_i.h" #include "ace/Get_Opt.h" @@ -43,7 +43,7 @@ parse_args (int argc, char *argv[]) ACE_ERROR_RETURN ((LM_ERROR, "usage: %s " "-o <iorfile>" - "-n (thread num)" + "-n (thread num)" "-s (disable yield)" "\n", argv [0]), diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.cpp b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.cpp index baf9408678b..6b9bd1add1f 100644 --- a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.cpp +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.cpp @@ -48,16 +48,16 @@ Simple_Server1_i::test_method (CORBA::Long exec_duration, CORBA::Long deadline A if (ACE_Thread::getprio (thr_handle, prio) == -1) { if (errno == ENOTSUP) - { - ACE_DEBUG((LM_DEBUG, - ACE_TEXT ("getprio not supported on this platform\n") - )); - return; - } + { + ACE_DEBUG((LM_DEBUG, + ACE_TEXT ("getprio not supported on this platform\n") + )); + return; + } ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("getprio failed")) - ); + ACE_TEXT ("%p\n"), + ACE_TEXT ("getprio failed")) + ); } ACE_DEBUG ((LM_DEBUG, @@ -81,8 +81,8 @@ Simple_Server1_i::test_method (CORBA::Long exec_duration, CORBA::Long deadline A while (compute_count_down_time > ACE_Time_Value::zero) { ACE::is_prime (prime_number, - 2, - prime_number / 2); + 2, + prime_number / 2); ++j; @@ -134,9 +134,9 @@ Simple_Server1_i::test_method (CORBA::Long exec_duration, CORBA::Long deadline A ACE_DEBUG ((LM_DEBUG, - "Request processing in thread %t done, " - "prio = %d, load = %d, elapsed time = %umsec, deadline_missed = %d\n", - prio, exec_duration, elapsed_time.msec (),Deadline_missed )); + "Request processing in thread %t done, " + "prio = %d, load = %d, elapsed time = %umsec, deadline_missed = %d\n", + prio, exec_duration, elapsed_time.msec (),Deadline_missed )); /*DTTIME: recording the finishing time on the server side. please also record the deadline_missed variable. */ diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.h b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.h index 7b016ec37ab..d3b83c9b470 100644 --- a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.h +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.h @@ -29,7 +29,7 @@ class Simple_Server1_i : public POA_Simple_Server1 // Implements the Simple_Server1 interface in test1.idl // public: - Simple_Server1_i (CORBA::ORB_ptr orb, + Simple_Server1_i (CORBA::ORB_ptr orb, RTScheduling::Current_ptr current, Task_Stats&, int); diff --git a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.i b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.i index 484e00ec734..eadf635456d 100644 --- a/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.i +++ b/TAO/examples/Kokyu_dsrt_schedulers/edf_example/test1_i.i @@ -1,13 +1,13 @@ //$Id$ ACE_INLINE -Simple_Server1_i::Simple_Server1_i (CORBA::ORB_ptr orb, +Simple_Server1_i::Simple_Server1_i (CORBA::ORB_ptr orb, RTScheduling::Current_ptr current, Task_Stats& task_stats, int enable_yield) : orb_ (CORBA::ORB::_duplicate (orb)), current_ (RTScheduling::Current::_duplicate (current)), task_stats_ (task_stats), - enable_yield_ (enable_yield) + enable_yield_ (enable_yield) { } |